Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 18,008 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Updating Attached Entities #331232
07/02/10 19:13
07/02/10 19:13
Joined: Feb 2005
Posts: 647
Williamsburg, VA USA
draculaFactory Offline OP
User
draculaFactory  Offline OP
User

Joined: Feb 2005
Posts: 647
Williamsburg, VA USA
I need some advice. I placed bone joints around a model and use script to attach other models to the joints in my game. Is it better to have each attached entity run in a loop to update its position or is it better to have one function that updates them all? I have done it both ways and wanted to know which sounds faster.

Currently, a handle is set to a created entity; later, in the main loop, the handle is restored to a temporary pointer; the script then uses vec_for_bone and ang_for_bone to update the position. This repeats for every attachment down the list.


Making dreams come true... And being erroneously accused of software piracy by Conitec in the process.
Re: Updating Attached Entities [Re: draculaFactory] #331247
07/02/10 21:25
07/02/10 21:25
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
Press F11 and look, which one takes more to calculate.
It´s shown unter the "Fnc" thing.


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: Updating Attached Entities [Re: alibaba] #331249
07/02/10 21:30
07/02/10 21:30
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
One function is definitely better than many functions.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Updating Attached Entities [Re: Superku] #331295
07/03/10 08:01
07/03/10 08:01
Joined: Feb 2005
Posts: 647
Williamsburg, VA USA
draculaFactory Offline OP
User
draculaFactory  Offline OP
User

Joined: Feb 2005
Posts: 647
Williamsburg, VA USA
What I meant was, is the constant use of ptr_for_handle in a single loop better or worse than running a loop for each attachment? Both methods seem about the same, but would there be problems later if I use, say, 15 attachments. I would basically be using ptr_for_handle 15 times in a row.


Making dreams come true... And being erroneously accused of software piracy by Conitec in the process.
Re: Updating Attached Entities [Re: draculaFactory] #331311
07/03/10 10:59
07/03/10 10:59
Joined: Jan 2002
Posts: 300
Usa
Rich Offline
Senior Member
Rich  Offline
Senior Member

Joined: Jan 2002
Posts: 300
Usa
I might have the syntax wrong (if I do hopefully someone will correct me) but you can store a pointer's address in a var and restore it with a cast operation (lite C).


((ENTITY*)you) = var_x;
you = ((ENTITY*)var_x);

Pros and cons vs a handle, I'm not sure...

Last edited by Rich; 07/03/10 11:01.

A8 com / A7 free
Re: Updating Attached Entities [Re: Rich] #331354
07/03/10 18:12
07/03/10 18:12
Joined: Feb 2005
Posts: 647
Williamsburg, VA USA
draculaFactory Offline OP
User
draculaFactory  Offline OP
User

Joined: Feb 2005
Posts: 647
Williamsburg, VA USA
I get no errors, but the attachment doesn't update either; we're probably doing it wrong, but thanks for the help. As it is right now, I have no problems, I was just curious if anyone had done this in a similar way before. I was trying to avoid using loops at all costs.


Making dreams come true... And being erroneously accused of software piracy by Conitec in the process.
Re: Updating Attached Entities [Re: draculaFactory] #331463
07/04/10 12:16
07/04/10 12:16
Joined: Jan 2002
Posts: 300
Usa
Rich Offline
Senior Member
Rich  Offline
Senior Member

Joined: Jan 2002
Posts: 300
Usa
Hmmm... This little snip of code is from my project, and it is working. Just to give you another example.


This piece of code stores a pointer (address) of an entity in one of it's skills.
Code:
if(platform.skill[i] == 0) //cycle through the allocated slots
		{
			platform.skill[i] = (ENTITY*)me; //store my pointer for later manipulation
			return(0);
		}

		i++; //move up one skill slot



In this piece, the stored pointer is used.
Code:
vec_add(((ENTITY*)my.skill[i]).x,vector(0,0,-1000));



The manual lists ptr_for_handle as having a speed of medium. I'm not sure if using a cast is actually faster, but I would guess so. A good way to test the speed is to use the timer() function.

Good luck!


A8 com / A7 free

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1