|
3 registered members (AndrewAMD, Grant, Neb),
908
guests, and 6
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
bones are fps eating packmans!
#399340
04/14/12 12:11
04/14/12 12:11
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
here an example code of an entity looking at the player constantly. Everything works fine and here. (a bit slow but ok):
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;
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!
|
|
|
Re: bones are fps eating packmans!
[Re: Random]
#399342
04/14/12 12:25
04/14/12 12:25
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Try this and see if it makes a difference in FPS...
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);
}
}
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: bones are fps eating packmans!
[Re: EvilSOB]
#399405
04/14/12 23:18
04/14/12 23:18
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
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.
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
Re: bones are fps eating packmans!
[Re: Rei_Ayanami]
#399422
04/15/12 09:25
04/15/12 09:25
|
Joined: Mar 2011
Posts: 3,150 Budapest
sivan
Expert
|
Expert
Joined: Mar 2011
Posts: 3,150
Budapest
|
arrrgghh, that costs too much. as I read somewhere it's in commercial... but thanks  okay finally found the matBones page in the manual, really Pro.
Last edited by sivan; 04/15/12 11:02. Reason: I found it
|
|
|
Re: bones are fps eating packmans!
[Re: JibbSmart]
#401176
05/14/12 22:02
05/14/12 22:02
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
JippSmart, could you show me how you would use "matBones" to solve this FPS problem?
|
|
|
|