Why setRotation/setPosition takes effect 1 loop late?

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Nextor
Posts: 35
Joined: Wed Feb 16, 2005 9:06 am
Location: Madrid, SPAIN

Why setRotation/setPosition takes effect 1 loop late?

Post by Nextor »

I've been using Irrlicht for a while and I've found something that I'm not sure whether it's a bug in the engine or it's done on purpose and I'm missing something. Sorry if that's an old issue.

Let's put this example of the engine loop:

Code: Select all

while(device->run()){

	driver->beginScene(...);
	<<drawing stuff>>
	driver->endScene();

	if(someCondition)
		node->setRotation();
	}
Let's suppose that <someCondition> it's true and the node gets a new rotation. Well, I've noticed that the node DOESN'T show it's new rotation the next time the program gets to the drawing block (beginScene & endScene) BUT the second time the node it's drawn on screen.

It happens with setPosition too: The new position isn't taken into account (at least, when drawing the node) until the second loop is executed. Even when using animators there's that problem (the animation starts and ends 1 loop late). This ¿bug? is better noticed in a slow computer, since fps are much lower.

Does anyone know anything about that?

Thanks a lot! :)
Get away from her, you B*TCH !!! - Ellen Ripley
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The absolute position [world position] of every scene node is updated in ISceneNode::OnPostRender() when ISceneNode::updateAbsolutePosition() is called. If you make a change to the relative position or rotation, it isn't reflected until the next call to OnPostRender.

If it is important for the object to have the correct informatoin immediately, you can explicitly call updateAbsolutePosition() after changing the relative position.

Travis
Last edited by vitek on Wed Mar 15, 2006 10:49 pm, edited 1 time in total.
Nextor
Posts: 35
Joined: Wed Feb 16, 2005 9:06 am
Location: Madrid, SPAIN

Post by Nextor »

THANKS A LOT TRAVIS :D :D :D
But I'm not quite sure about that because this problem affects the rotation too and I don't think there is some method to update the rotation. Anyway, I'll have a try and I'll tell you if the problem is solved. Thanx again.
Last edited by Nextor on Wed Mar 15, 2006 9:19 pm, edited 1 time in total.
Get away from her, you B*TCH !!! - Ellen Ripley
kburkhart84
Posts: 277
Joined: Thu Dec 15, 2005 6:11 pm

Post by kburkhart84 »

I just wanted to confirm that this also happens if you initialize a node and then change it's position afterwards before you even draw yet. 1 frame, the node appears at the default position(0, 0, 0) then suddenly jumps. I fixed that by setting those parameters in the constructor, which avoids the need to call onpostrender() to get the positions to update.
Nextor
Posts: 35
Joined: Wed Feb 16, 2005 9:06 am
Location: Madrid, SPAIN

Post by Nextor »

Yes, kburkhart84, that's exactly what I mean! Even if you've changed the position/rotation before starting the while loop, it takes 2 frames to get the transformation correctly.
Get away from her, you B*TCH !!! - Ellen Ripley
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

I'm not quite sure about that because this problem affects the rotation too
The updateAbsolutePosition() call I mentioned above updates the absolute transformation matrix for the scene node [scale, translation and rotation].

The two problems mentioned above are actually the exact same problem. It has been discussed several times on this forum.

Travis
Nextor
Posts: 35
Joined: Wed Feb 16, 2005 9:06 am
Location: Madrid, SPAIN

Post by Nextor »

Thanks a lot again, Travis. Sorry if that was such an old known issue. :oops:
I haven't had the time to check it yet, but I guess you're right.
Get away from her, you B*TCH !!! - Ellen Ripley
Post Reply