question

Mischa Spelt avatar image
0 Likes"
Mischa Spelt asked Phil BoBo edited

Draw surrogates 'wobbly' at high speeds when location set before rotation

OK so this is a bit of a weird issue and I already know the solution, but I am curious about the explanation.

I simplified the following model from a more complex object which tries to update the position of its drawsurrogates in the OnPreDraw event. It calculates a new position and rotation, then sets

box.setLocation( x, y, z, 0, 0.5, 0 );
box.setRotation( 0, 0, 90 - angle );    

At low run speeds, this works fine, but if you crank the speed up to, say, 16,000x you will see the animation go all jumpy or the circle become wobbly.

What really surprised me (you won't believe it! read it now!) is: when I swapped the order of the setLocation and setRotation statements, everything works smoothly for me... at all run speeds.

Note that this only works in combination with the setLocation using non-zero factors, so I guess it's related to that... but then I thought that this behavior would maybe change if I changed the centroid property of the boxes which it doesn't seem to.

Here is the demo model to try it out: BoxPreDrawTest.fsm

FlexSim 22.0.4
rotationonpredraw
boxpredrawtest.fsm (30.9 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Phil BoBo avatar image
1 Like"
Phil BoBo answered Phil BoBo edited

The boxes in your attached model are using a shape that isn't packed into the model, so we can't see what you are talking about using the model you attached:

1654814702165.png

Even without replicating the issue in your model though, it is easy to explain what's happening.

When you set a location using factors, then the rotation of the object affects the position that it will be set to. In your example code, you are setting the center of the bottom left edge of the object to a particular location. That point of the object represents a different absolute location in space based on the object's rotation.

1654815713124.png

If you are setting the location first and then the rotation, then the location's position will be based on the rotation that the object was during the previous call, which will vary by run speed. Longer run speeds will have more time between frames.

Attached is a simplified sample model that can help explain.

location_factors.fsm

1654815264769.png

If you execute the top scripts multiple times, each script always puts the box into the same absolute position.

If you execute the bottom scripts multiple times, then the first execution of the script may put the box into a different absolute position depending on what the box's last rotation was before you executed the script.


1654814702165.png (349.7 KiB)
1654815264769.png (191.4 KiB)
1654815713124.png (50.4 KiB)
· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Phil BoBo avatar image Phil BoBo ♦♦ commented ·

In addition to the picture above, here's another picture with more explanation:

1654816958102.png

1 Like 1 ·
1654816958102.png (145.2 KiB)
Mischa Spelt avatar image Mischa Spelt commented ·

it is easy to explain what's happening.

Once you see it, it's easy :-) Thanks!

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.