Page MenuHome

Zeroing out angular velocity not possible
Closed, ResolvedPublic

Description

System Information
Windows 7 64 bit, Nvidia GeForce GT540M Cuda

Blender Version
I suppose the bug's there from the beginning. (tested with 2.57 up to 2.71)

Short description of error
Angular velocity magnitude can't be set to zero.

Exact steps for others to reproduce the error
Zeroing out angular velocity of Dynamic object with angular velocity magnitude > 0 has no effect.

Event Timeline

Raf Colson (raco) added a project: Game Engine.
Raf Colson (raco) set Type to Bug.
Raf Colson (raco) created this task.
Raf Colson (raco) raised the priority of this task from to Needs Triage by Developer.

I confirm the bug.

I have just checked the code and it seems that any value under a certain threshold (SIMD_EPSILON*SIMD_EPSILON) is totally ignored.

I attach a fix using the same solution that it was used for SetLinearVelocity (That is to comment the check for angular velocity min threshold).

I confirm the bug.
I have just checked the code and it seems that any value under a certain threshold (SIMD_EPSILON*SIMD_EPSILON) is totally ignored.
I attach a fix using the same solution that it was used for SetLinearVelocity (That is to comment the check for angular velocity min threshold).

I think the check exists to restrict the user from applying values that would be grossly impractical, like 1e-20. That said, if we want to keep the check, we could ask if the applied sum is zero;
float angvelsum = angvel.length2()
if (m_object && ( angvelsum == 0 || angvelsum > (SIMD_EPSILON*SIMD_EPSILON)))

I've got no idea how to submit patches, though.

It could be a good solution. When i come back from my easter holidays i will make a test blend to check it.

I think the check exists to restrict the user from applying values that would be grossly impractical, like 1e-20. That said, if we want to keep the check, we could ask if the applied sum is zero;
float angvelsum = angvel.length2()
if (m_object && ( angvelsum == 0 || angvelsum > (SIMD_EPSILON*SIMD_EPSILON)))
I've got no idea how to submit patches, though.

Actually, I think it would be much more appropriate to print a message to console if the value is too low. If we assume that printf() can be used here and that I still understand C++:

float angvelsum = angvel.length2()
if (m_object && ( angvelsum == 0 || angvelsum > (SIMD_EPSILON*SIMD_EPSILON)))
  // go ahead and apply the change
else
  printf("Ignoring setAngularVelocity() command. Input value is too small in magnitude.");

This way, the user immediately knows what's up. If printf() can't be used, then we'd use whatever command prints out "Game Engine Started" and "Game Engine Finished".

qubodup added a subscriber: qubodup.
Jorge Bernal (lordloki) triaged this task as Normal priority.May 15 2015, 3:22 PM

Why would we care about someone using 1e-20? If someone wants to, let them go ahead. Unless someone can prove that it actually causes a problem, I would suggest simply removing the check on magnitude.

Hi Sybren,

I was proposing the same in D952. I'm doing a complex demo to check if magnitude check removal affects to instability. Maybe, next week I can finish it.

I had a chat about this in IRC, it seems to me that we do want it to be possible to set angular and linear velocity (and more things) to zero.
Simply removing the check could, has mentioned, bring up performance and stability problems.
As for stability, I would suggest add a check if the value that the magnitude is being set to is within epsilon, if so, set to 0 instead epsilon.
For performance, I can't tell just by looking at it :)
What kind of tests are you preparing @Jorge Bernal (lordloki) ? Are they ready and could you share them in the test suite files?

I see this is already the solution in D952 .
As a side note, it is really good to see suggestions from new people and an active community around this.