I am working on an offline collision program. The meshes are rigid bodies of a complex machine moving (models are convex meshes converted from creo/proe cad systems).
I have positions of each mesh depending on the time. For optimisation reasons, I have positions only when something is moving at least 0.5mm. This implies non constant delta times.
eg , positions for t0=0ms , t1=4ms, t2=10ms,t3=50ms ......(this is not real , but to illustrate ....)
I started with a basic collide algorithm in which at each time frame I am computing and setting a new physics world with the whole scene to perform collisions.
It works, but I is not really efficient regarding performance.
I would like now migrate to a continuous detection collision mode, in which I will set positions (transformation matrix) of each mesh, without reconstructiong the whole physics world. Which orientations and modifications should be involved regarding my initial implementation ?
Here is basically the code I am using for each frame (with ammojs but does not sound being a pb).
Code: Select all
this._broadphase = new this.ammoInjection.btDbvtBroadphase();
this._collisionConfiguration = new this.ammoInjection.btDefaultCollisionConfiguration();
this._dispatcher = new this.ammoInjection.btCollisionDispatcher(this._collisionConfiguration);
this._physicsWorld = new this.ammoInjection.btCollisionWorld(
this._dispatcher,
this._broadphase,
this._collisionConfiguration
);
for each mesh:
const shape = new this.ammoInjection.btConvexTriangleMeshShape(trimesh, true);
const m = new this.ammoInjection.btCollisionObject();
m.setCollisionShape(shape);
this._physicsWorld.addCollisionObject(m, mesh.collisionGroup, mesh.collisionMask);
this._physicsWorld.performDiscreteCollisionDetection();
// collect manifolds
...