BloodRedd / gamekit

Automatically exported from code.google.com/p/gamekit
1 stars 0 forks source link

call gameObject translate method will lose bullet physic effect #235

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.creat a blender file with a static plane  
2.add a always sensor with AND controller  and an motion actuator motion change 
location 
3.play the file with blender and ogre kit 

What is the expected output? What do you see instead?
 the cube will fall down when it is outside the plane. when play the file with blender it is all right, but in ogre kit the cube will keep moving even outside the plane, no gravity any more,all bullet physic effect have lost.

What version of the product are you using? On what operating system?
ogre kit most recent version :1084 
blender 2.61 or blender 2.59 

Please provide any additional information below.
I have written a script to test this method, it really cause this problem. 

Original issue reported on code.google.com by kizan...@gmail.com on 1 Jun 2012 at 6:34

Attachments:

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
gameObject is gkGameObject in file gkGameObject.cpp

Original comment by kizan...@gmail.com on 1 Jun 2012 at 6:38

GoogleCodeExporter commented 8 years ago
if I call the activate() method of gkPhysicsController in 
gkPhysicsController::updateTransform(void) after 
m_collisionObject->setWorldTransform(worldTrans); the problem above will not 
occur.

void gkPhysicsController::updateTransform(void)
{
    if (m_suspend || !m_collisionObject)
        return;

    btTransform worldTrans;
    worldTrans.setIdentity();

    gkQuaternion rot;
    gkVector3 loc;

    if (!m_object->getParent())
    {
        rot = m_object->getOrientation();
        loc = m_object->getPosition();
    }
    else
    {
        rot = m_object->getWorldOrientation();
        loc = m_object->getWorldPosition();
    }

    worldTrans.setRotation(btQuaternion(rot.x, rot.y, rot.z, rot.w));
    worldTrans.setOrigin(btVector3(loc.x, loc.y, loc.z));

    m_collisionObject->setWorldTransform(worldTrans);
+++++m_collisionObject->activate();
}

is this the solution?  any other suggestion?

Original comment by kizan...@gmail.com on 1 Jun 2012 at 8:18

GoogleCodeExporter commented 8 years ago
The problem is that you should not use translate for moving rigidbodies. You 
will get problems with collision-control and such. Use the "Dynamic Object 
Settings" with force, torque and linear velocity to move your object.

Original comment by thomas.t...@googlemail.com on 6 Jun 2012 at 1:17

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
thanks for you reply, thomas. :) 
I really get some collision problem, but I find in blender It work very well 
when I use the MotionActuator with location or rotate properties. 
what can I do if I want to get the same effect like blender ?And I doubt 
whether it is the user's responsibility to the collision problem.  
the collision problem  is just like to set two rigid body at the same position, 
this action is not right for user, but user can do it and the dynamic world 
should notify the user what he have done ,is this right?
in my game I want my player to move the game object to a exactly position to 
set some thing, if I use  "Dynamic Object Settings"  it is too difficult to 
control the destination of the game object, with translate methods it become 
easy. It is looks strange that the game  object will lose physic effect. 
now I fixed the collision problem with a ghost rigid  body translate first and 
then after a dynamicsWorld step update, I will translate my game object to the 
right place by query the collision test result of the  ghost rigid body .
is this right ? so confused am I.

Original comment by kizan...@gmail.com on 6 Jun 2012 at 5:09