bones are fps eating packmans!

Posted By: Random

bones are fps eating packmans! - 04/14/12 12:11

here an example code of an entity looking at the player constantly.
Everything works fine and here. (a bit slow but ok):

Code:
action look_at_player()
{
	while(1)
	{
		VECTOR temp_vec; 
		ANGLE temp_angle;
		ANGLE head_angle;

		vec_set(temp_vec,player.x); 
		vec_sub(temp_vec,my.x); 
		vec_to_angle(temp_angle,temp_vec);
		vec_sub(temp_angle, my.pan);    
		//head
		head_angle.pan = temp_angle.pan;
		head_angle.tilt = temp_angle.tilt;
		head_angle.roll = 0;
		head_angle.tilt = clamp(head_angle.tilt, -80, 80);
		head_angle.pan = clamp(head_angle.pan, -90, 90);
		ent_bonereset(my,"Head");    
		ent_bonerotate(my,"Head",head_angle);

		wait(1);
	}
}



But now I don`t only need the head to rotate, but also the (lets say) right arm and left arm.
Then it would look like this;

Code:
action look_at_player()
{
	while(1)
	{
		VECTOR temp_vec; 
		ANGLE temp_angle;
		ANGLE head_angle;
		ANGLE right_arm_angle;
		ANGLE left_arm_angle;

		vec_set(temp_vec,player.x); 
		vec_sub(temp_vec,my.x); 
		vec_to_angle(temp_angle,temp_vec);
		vec_sub(temp_angle, my.pan);    
		
		//head
		head_angle.pan = temp_angle.pan;
		head_angle.tilt = temp_angle.tilt;
		head_angle.roll = 0;
		ent_bonereset(my,"Head");    
		ent_bonerotate(my,"Head",head_angle);

		//right arm
		right_arm_angle.pan = temp_angle.pan;
		right_arm_angle.tilt = temp_angle.tilt;
		right_arm_angle.roll = 0;
		ent_bonereset(my,"right_arm");    
		ent_bonerotate(my,"right_arm",right_arm_angle);

		//left arm
		left_arm_angle.pan = temp_angle.pan;
		left_arm_angle.tilt = temp_angle.tilt;
		left_arm_angle.roll = 0;
		ent_bonereset(my,"left_arm");    
		ent_bonerotate(my,"left_arm",left_arm_angle);

		wait(1);
	}
}



And that is a real fps killer.
Is there any way to save fps in that example?
I needs alot more ghosts to stop this fps packman!
Posted By: EvilSOB

Re: bones are fps eating packmans! - 04/14/12 12:25

Try this and see if it makes a difference in FPS...
Code:
action look_at_player()
{
	ANGLE temp;
	while(1)
	{
		vec_sub(vec_set(temp, player.x), my.x);
		vec_to_angle(temp, temp);
		vec_sub(temp, my.pan);    
		
		//head
		ent_bonereset(my,"Head");    
		ent_bonerotate(my,"Head", vector(temp.pan, temp.tilt, 0));

		//right arm
		ent_bonereset(my,"right_arm");    
		ent_bonerotate(my,"right_arm", vector(temp.pan, temp.tilt, 0));

		//left arm
		ent_bonereset(my,"left_arm");    
		ent_bonerotate(my,"left_arm", vector(temp.pan, temp.tilt, 0));

		wait(1);
	}
}


Posted By: JibbSmart

Re: bones are fps eating packmans! - 04/14/12 23:18

Every time you move a bone you're also updating every vertex attached to that bone (and any attached to children of that bone). By default GS does this on the CPU, but you can look at matBones to find a much faster alternative -- the vertices are only moved in the shader (GPU is much better suited to this kind of thing), but it means if you use vec_for_vertex or something similar you won't get the correct position.

I love matBones. It makes a huge difference to performance with bones-animation.
Posted By: sivan

Re: bones are fps eating packmans! - 04/15/12 07:46

hi JibbSmart,
is there any better example than crowd.c of this shader based bone animation? I'm planning to upgrade to commercial because I really need this feature to handle my crowd of similar characters. (and of course I badly need some other shaders...)
Posted By: Rei_Ayanami

Re: bones are fps eating packmans! - 04/15/12 08:07

matBones is "A8 P" - A8 Pro, not commercial smirk
Posted By: sivan

Re: bones are fps eating packmans! - 04/15/12 09:25

arrrgghh, that costs too much. as I read somewhere it's in commercial...
but thanks laugh

okay finally found the matBones page in the manual, really Pro.
Posted By: JibbSmart

Re: bones are fps eating packmans! - 04/15/12 11:36

Sorry. I forgot about version differences.
Posted By: 3run

Re: bones are fps eating packmans! - 04/15/12 12:38

Yeah, it's really easy to forget if you own pro version grin
Posted By: Random

Re: bones are fps eating packmans! - 05/14/12 22:02

JippSmart, could you show me how you would use "matBones" to solve this FPS problem?
© 2023 lite-C Forums