T3D 1.1 Beta 3 - ShapeBase::setVelocity and ::applyImpulse - not coded ? / not working - NOT A BUG
by James Novosel · in Torque 3D Professional · 03/16/2011 (3:27 pm) · 10 replies
Build 1.1 Beta 3, 1.1 Release
Platform: Windows XP 32 bit
Target: shapebase.cpp's setVelocity and applyImpulse are currently empty (I added the console logging):
void ShapeBase::setVelocity(const VectorF&)
{
Con::errorf(ConsoleLogEntry::General, "ShapeBase setVelocity - called "); // added this
}
void ShapeBase::applyImpulse(const Point3F&,const VectorF&)
{
Con::errorf(ConsoleLogEntry::General, "ShapeBase applyImpulse - called"); // added this - did not test
}
Disclaimer :), I am a C#/VB/SQL programmer by trade, so attempting to claim any competency at C++/C would be misleading on my part - (Correct me if I am wrong, but shouldn't there be code in setVelocity and applyImpulse ?, it is being called - ConsoleLogEntry values appear... and methods show up in %obj.dump() )
Issues: Attempting to stop a rolling rigidshape (inherits from shapeBase) on flat surface by using object.setVelocity("0 0 0") in script. Object does not stop, in fact using object.getVelocity() immediately after setVelocity("0 0 0") shows values (eg - %obj velocity = 6.94283 -10.8694 -2.07741).
Steps to Repeat: Use setVelocity on any moving shapebase object - it does not appear to work, my rigidshape continues moving right along.
Suggested fix: Not sure, not sure if this was ever present - I see the same code in the TGE 1.52 code base as well ( if I missed something let me know ).
Link to Console Log: Nothing unusual in the console.log
Platform: Windows XP 32 bit
Target: shapebase.cpp's setVelocity and applyImpulse are currently empty (I added the console logging):
void ShapeBase::setVelocity(const VectorF&)
{
Con::errorf(ConsoleLogEntry::General, "ShapeBase setVelocity - called "); // added this
}
void ShapeBase::applyImpulse(const Point3F&,const VectorF&)
{
Con::errorf(ConsoleLogEntry::General, "ShapeBase applyImpulse - called"); // added this - did not test
}
Disclaimer :), I am a C#/VB/SQL programmer by trade, so attempting to claim any competency at C++/C would be misleading on my part - (Correct me if I am wrong, but shouldn't there be code in setVelocity and applyImpulse ?, it is being called - ConsoleLogEntry values appear... and methods show up in %obj.dump() )
Issues: Attempting to stop a rolling rigidshape (inherits from shapeBase) on flat surface by using object.setVelocity("0 0 0") in script. Object does not stop, in fact using object.getVelocity() immediately after setVelocity("0 0 0") shows values (eg - %obj velocity = 6.94283 -10.8694 -2.07741).
Steps to Repeat: Use setVelocity on any moving shapebase object - it does not appear to work, my rigidshape continues moving right along.
Suggested fix: Not sure, not sure if this was ever present - I see the same code in the TGE 1.52 code base as well ( if I missed something let me know ).
Link to Console Log: Nothing unusual in the console.log
#2
03/17/2011 (2:05 am)
Ivan, you should add, that in most virtual functions of T3D the parent virtual function is called as well, to inherit parent function behaviour, e.g. look in processTick. So it should be normal that the call ends up in an empty function!
#5
HTH
03/17/2011 (3:44 am)
On his specular problem, I would suggest, he uses an item. Rigidshape or StaticShape don't have any defined functions for setting velocity or impulse. But an Item has... HTH
#6
to reset velocity on rigids,you have to zero the linear and angular velocity and momentum.
03/17/2011 (3:53 am)
rigids have freezeSim() methodto reset velocity on rigids,you have to zero the linear and angular velocity and momentum.
#7
I usually design base classes this way, but if the base class is not intended to be used as more than a template I usually make these pure virtual methods so that you must override them in your derived classes and cannot instantiate the base class.
03/17/2011 (7:36 am)
The point is that they are empty because it's a base class and there is no default behavior for those methods. Just derive a new class and override the methods (as intended) or use an existing derived class that has these methods implemented. Or, find a derived class that has these implemented in a way that you like and move those methods to the base class so that this becomes the default behavior....I usually design base classes this way, but if the base class is not intended to be used as more than a template I usually make these pure virtual methods so that you must override them in your derived classes and cannot instantiate the base class.
#8
03/17/2011 (6:32 pm)
Or, implement the methods yourself in RigidShape. ShapeBase most likely doesn't define these methods because ShapeBase objects themselves do not move - derived classes handle motion. In classes such as RigidShape, it's not unreasonable to expect setVelocity to work as intended.
#9
FYI - I tried using freezeSim(1), that stops it for sure and for good, it will not move after that unless you freezeSim(0) and then it begins moving again at the velocity and vector it was originally moving.
I basically have a ball that can hit a teleport pad while rolling and once teleported I need it to teleport to a spot and be motionless.
I'll try placing the code in RigidShape, or, not sure about implementing as an item (would it behave as a rigidshape does).
Appreciate the feedback, sorry for the false alarm/bug report...
03/17/2011 (7:22 pm)
Thanks for the input, I figured it was something related to my c++ skillset (thats why I included a disclaimer).FYI - I tried using freezeSim(1), that stops it for sure and for good, it will not move after that unless you freezeSim(0) and then it begins moving again at the velocity and vector it was originally moving.
I basically have a ball that can hit a teleport pad while rolling and once teleported I need it to teleport to a spot and be motionless.
I'll try placing the code in RigidShape, or, not sure about implementing as an item (would it behave as a rigidshape does).
Appreciate the feedback, sorry for the false alarm/bug report...
#10
03/18/2011 (2:43 am)
Quote:not sure about implementing as an item (would it behave as a rigidshape does).Items, as far as I remember, have simplified physics. They bounce around and stuff, but don't do rotation.
Torque Owner Ivan Mandzhukov
Liman3D