sometimes strange behaviour of vec_for_vertex

Posted By: pegamode

sometimes strange behaviour of vec_for_vertex - 12/01/09 13:18

Hi,

our actors consist of 2 models: head and the rest.

We use vec_for_vertex to place the head onto the body.
This works fine, but in some few situations the head is set a few pixels too far in front.

We have some invisible dummies at every door in every room.
After loading the room we get the position of one of those dummies, create the actor with ent_create and set him to this position. Directly after this we create the head entity, use vec_for_vertex to place it and then the position of the head is updated every frame by also using vec_for_vertex.

This works fine in over 20 rooms ... but we have 2 positions in 2 rooms where the head is placed a few pixel away from the position he should be. As the actor plays a stand-animation you can see that the head also moves slightly with the animation, so that we can be sure head update is running.

It seems like we would not get the vertex position we requested, but the position of a vertex near to it.

Strange is also that once we move the actor the head position gets updated right. The described behaviour can only be seen while actor and head were created and the stand animation is playing. After moving the actor the head is placed right even when the stand animation is playing.

As those places are always the same and can be reproduced every time, there must be something special at this position, but I don't have any clue where to search.

Have you any idea why this could happen?

Best regards,
Pegamode.
Posted By: jcl

Re: sometimes strange behaviour of vec_for_vertex - 12/01/09 13:43

The first idea is that you move the head with some collision detection, instead of just placing it. This would explain that it's slightly off when it collides with some wall.
Posted By: pegamode

Re: sometimes strange behaviour of vec_for_vertex - 12/01/09 13:45

That was one of my first thoughts, too ... but the head is set to PASSABLE and the code looks like this:

Code:
void set_head_position(CHARACTER* c) {	
	if (c->head == NULL) return;	
	VECTOR tmp;
	vec_for_vertex(tmp, c.entity, c.headVertex);	
	c->head.x = tmp.x;
	c->head.y = tmp.y;
	c->head.z = tmp.z;	
}



So there should be no collision detection at all.
Posted By: jcl

Re: sometimes strange behaviour of vec_for_vertex - 12/02/09 12:49

Hmm, then I have no immediate idea.

The next strategy would be to find the difference of the 2 rooms where this happens. Maybe the actor is placed at a different height there, or it was not seen by the camera before the head was placed, or something like that. That could give a hint where to look further.
Posted By: tD_Datura_v

Re: sometimes strange behaviour of vec_for_vertex - 12/02/09 14:55

Some potentially irrelevant questions:
By default, what are local vars and structs initialized to?
"dplay_smooth", model attachment friend or foe?
Passable entities and water detection. My head is not an ocean. Or is it?
Dummy room placement. How many dummies are active? Which one is the right one? Do the old ones still linger in the room?




Posted By: pegamode

Re: sometimes strange behaviour of vec_for_vertex - 12/02/09 20:10

dplay_smooth is for multiplayer games ... this is a singleplayer game.

The head is passable ... so no collision detection.

The entities are the right ones ...
Posted By: pegamode

Re: sometimes strange behaviour of vec_for_vertex - 12/08/09 16:36

It seems like we solved the problem.

Even though the head is set directly by Entity.x and is set to PASSABLE it seems like we need to set also the POLYGON flag.

I'll check this within the next two days by switching the code.

Regards,
Pegamode.
Posted By: jcl

Re: sometimes strange behaviour of vec_for_vertex - 12/09/09 09:35

The POLYGON flag should have no influence on where you placed the head. Only when you move it with c_move, of course.

When you don't find the reason, you could contact Support and send them an example - they'll look into it to make sure that it's no engine bug. Which is however very unlikely in this case.
Posted By: pegamode

Re: sometimes strange behaviour of vec_for_vertex - 12/09/09 10:22

I agree ... I couldn't get any sense to this, too.

So I switched the code back and now the head's position is correct also without the POLYGON flag.

Currently I think that it's neither an engine bug nor something in the code, but something in the body model.
I'll check the svn-repository if there were any changes on the character-model during the same time I added the POLYGON flag.
© 2024 lite-C Forums