4
« on: November 21, 2010, 04:15:26 pm »
oh it seems like I've found the problem:
public class JPCTBulletMotionState extends MotionState
{
private Object3D obj3d;
public JPCTBulletMotionState(Object3D obj)
{
this.obj3d = obj;
}
public JPCTBulletMotionState(Object3D obj, Transform startTrans)
{
this.obj3d = obj;
this.setGraphicFromTransform(startTrans);
}
public Transform getWorldTransform(Transform worldTrans)
{
this.setTransformFromGraphic(worldTrans);
return worldTrans;
}
public void setWorldTransform(Transform worldTrans)
{
this.setGraphicFromTransform(worldTrans);
}
private void setTransformFromGraphic(Transform tran)
{
SimpleVector p = this.obj3d.getTransformedCenter();
tran.origin.set(p.x, p.y, p.z); // not sure if translation or position
Matrix matrixGfx = this.obj3d.getRotationMatrix();
//matrixGfx.rotateX((float)Math.PI);
MatrixUtil.getOpenGLSubMatrix(tran.basis, matrixGfx.getDump());
}
private void setGraphicFromTransform(Transform tran)
{
SimpleVector pos = obj3d.getTransformedCenter();
this.obj3d.translate(tran.origin.x - pos.x,
tran.origin.y - pos.y,
tran.origin.z - pos.z);
float[] dump = this.obj3d.getRotationMatrix().getDump(); //new float[16];
Matrix matrixGfx = new Matrix();
MatrixUtil.getOpenGLSubMatrix(tran.basis, dump);
matrixGfx.setDump(dump);
//matrixGfx.rotateX((float)Math.PI);
this.obj3d.setRotationMatrix(matrixGfx);
}
}
Is there anything I can save here?
when I create DefaultMotionState instead of this one, I don't have GC working so hard
well at least it is freeing way less