Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, VoroneTZ, dpn), 1,346 guests, and 10 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19053 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 | chip programmers | 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