remove static geom space
This commit is contained in:
parent
aa0956477d
commit
1e113d8598
@ -120,11 +120,6 @@ public class CollisionEngine {
|
||||
*/
|
||||
protected DBhvSpace space;
|
||||
|
||||
/**
|
||||
* Space for storing static geoms
|
||||
*/
|
||||
protected DSpace staticGeomSpace;
|
||||
|
||||
/**
|
||||
* Lock for thread-safeing all ODE calls
|
||||
*/
|
||||
@ -256,8 +251,6 @@ public class CollisionEngine {
|
||||
CollisionEngine rVal = new CollisionEngine(name);
|
||||
rVal.nearCallback = callback;
|
||||
callback.engine = rVal;
|
||||
rVal.staticGeomSpace = OdeHelper.createBHVSpace(Collidable.TYPE_STATIC_BIT);
|
||||
rVal.staticGeomSpace.setCategoryBits(Collidable.TYPE_STATIC_BIT);
|
||||
return rVal;
|
||||
}
|
||||
|
||||
@ -526,58 +519,6 @@ public class CollisionEngine {
|
||||
for(int i=0; i<numc; i++){
|
||||
DContact contact = contacts.get(i);
|
||||
|
||||
//this triggers if o2 is the static geom space and we did an inner collide to find the geom within that space to collide with
|
||||
if(o2 == this.staticGeomSpace){
|
||||
//get the opposite geom from the collision
|
||||
if(contact.geom.g1 == o1){
|
||||
o2 = contact.geom.g2;
|
||||
} else if(contact.geom.g2 == o1){
|
||||
o2 = contact.geom.g1;
|
||||
} else {
|
||||
String message = "Failed to get collidable from geom within static geom space!\n" +
|
||||
"Geoms:\n" +
|
||||
o1 + " \n" +
|
||||
o2 + " \n" +
|
||||
"Bodies:\n" +
|
||||
b1 + " \n" +
|
||||
b2 + " \n" +
|
||||
"Colliders:\n" +
|
||||
c1 + " \n" +
|
||||
c2 + " \n" +
|
||||
"Obj 1 pointers:\n" +
|
||||
this.bodyPointerMap.get(b1) + " \n" +
|
||||
this.geomPointerMap.get(o1) + " \n" +
|
||||
"Obj 2 pointers:\n" +
|
||||
this.bodyPointerMap.get(b2) + " \n" +
|
||||
this.geomPointerMap.get(o2) + " \n" +
|
||||
"Contact geoms:\n" +
|
||||
contact.geom.g1 + "\n" +
|
||||
contact.geom.g2 + "\n" +
|
||||
"";
|
||||
throw new Error(message);
|
||||
}
|
||||
c2 = geomPointerMap.get(o2);
|
||||
if(c2 == null){
|
||||
String message = "Failed to get collidable from geom within static geom space!\n" +
|
||||
"Geoms:\n" +
|
||||
o1 + " \n" +
|
||||
o2 + " \n" +
|
||||
"Bodies:\n" +
|
||||
b1 + " \n" +
|
||||
b2 + " \n" +
|
||||
"Colliders:\n" +
|
||||
c1 + " \n" +
|
||||
c2 + " \n" +
|
||||
"Obj 1 pointers:\n" +
|
||||
this.bodyPointerMap.get(b1) + " \n" +
|
||||
this.geomPointerMap.get(o1) + " \n" +
|
||||
"Obj 2 pointers:\n" +
|
||||
this.bodyPointerMap.get(b2) + " \n" +
|
||||
this.geomPointerMap.get(o2) + " \n" +
|
||||
"";
|
||||
throw new Error(message);
|
||||
}
|
||||
}
|
||||
|
||||
//special code for ray casting
|
||||
if (o1 instanceof DRay || o2 instanceof DRay){
|
||||
@ -1682,19 +1623,6 @@ public class CollisionEngine {
|
||||
geom.setBody(body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the geometry to the static geom space
|
||||
* @param staticGeom The geom (ie a cylinder, cube, etc)
|
||||
*/
|
||||
protected void addToStaticSpace(DGeom staticGeom){
|
||||
// spaceLock.lock();
|
||||
// if(staticGeom.getSpace() != null){
|
||||
// staticGeom.getSpace().remove(staticGeom);
|
||||
// }
|
||||
// this.staticGeomSpace.add(staticGeom);
|
||||
// spaceLock.unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
* Locks the ode library
|
||||
*/
|
||||
|
||||
@ -54,15 +54,6 @@ public class PhysicsCallback implements DNearCallback {
|
||||
return;
|
||||
}
|
||||
|
||||
if(o1 == engine.staticGeomSpace){
|
||||
OdeHelper.spaceCollide2(o2, engine.staticGeomSpace, 0, this);
|
||||
return;
|
||||
}
|
||||
if(o2 == engine.staticGeomSpace){
|
||||
OdeHelper.spaceCollide2(o1, engine.staticGeomSpace, 0, this);
|
||||
return;
|
||||
}
|
||||
|
||||
//get the collidables for each geom
|
||||
Collidable c1 = null;
|
||||
if(b1 != null){
|
||||
|
||||
@ -399,8 +399,7 @@ public class PhysicsEntityUtils {
|
||||
}
|
||||
CollisionEngine.lockOde();
|
||||
if(physicsTemplate.getKinematic()){
|
||||
DGeom geom = PhysicsEntityUtils.serverAttachGeom(realm,rVal,physicsTemplate);
|
||||
PhysicsUtils.makeGeomStatic(realm.getCollisionEngine(), geom);
|
||||
PhysicsEntityUtils.serverAttachGeom(realm,rVal,physicsTemplate);
|
||||
} else {
|
||||
DBody rigidBody = null;
|
||||
switch(physicsTemplate.getType()){
|
||||
@ -724,9 +723,6 @@ public class PhysicsEntityUtils {
|
||||
realm.getCollisionEngine().registerCollisionObject(geom, collidable);
|
||||
} break;
|
||||
}
|
||||
if(geom != null){
|
||||
realm.getCollisionEngine().addToStaticSpace(geom);
|
||||
}
|
||||
CollisionEngine.unlockOde();
|
||||
return geom;
|
||||
}
|
||||
@ -826,7 +822,6 @@ public class PhysicsEntityUtils {
|
||||
PhysicsEntityUtils.setCollidable(terrain, collidable);
|
||||
realm.getCollisionEngine().registerCollisionObject(terrainCollider, collidable);
|
||||
PhysicsEntityUtils.setDGeom(terrain,terrainCollider);
|
||||
PhysicsUtils.makeGeomStatic(realm.getCollisionEngine(), terrainCollider);
|
||||
|
||||
return terrainCollider;
|
||||
}
|
||||
@ -862,7 +857,6 @@ public class PhysicsEntityUtils {
|
||||
PhysicsEntityUtils.setCollidable(terrain, collidable);
|
||||
realm.getCollisionEngine().registerCollisionObject(terrainBody, collidable);
|
||||
PhysicsEntityUtils.setDGeom(terrain,terrainBody);
|
||||
PhysicsUtils.makeGeomStatic(realm.getCollisionEngine(), terrainBody);
|
||||
|
||||
return terrainBody;
|
||||
}
|
||||
|
||||
@ -136,15 +136,6 @@ public class PhysicsUtils {
|
||||
collisionEngine.synchronizeData(body, position, rotation, linearVel, angularVel, linearForce, angularForce);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a geom to the static geom space
|
||||
* @param collisionEngine The collision engine
|
||||
* @param geom The geom
|
||||
*/
|
||||
public static void makeGeomStatic(CollisionEngine collisionEngine, DGeom geom){
|
||||
collisionEngine.addToStaticSpace(geom);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the position + rotation + scale of a body
|
||||
|
||||
@ -5,7 +5,6 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3i;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
|
||||
@ -3,7 +3,6 @@ package electrosphere.collision;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.joml.Vector3d;
|
||||
import org.ode4j.ode.DBox;
|
||||
|
||||
import electrosphere.data.entity.collidable.CollidableTemplate;
|
||||
import electrosphere.engine.Globals;
|
||||
@ -45,8 +44,7 @@ public class CollisionEngineStaticSpaceTests extends EntityTestTemplate {
|
||||
Realm realm = Globals.serverState.realmManager.first();
|
||||
CollisionEngine collisionEngine = realm.getCollisionEngine();
|
||||
|
||||
DBox box = collisionEngine.createCubeGeom(new Vector3d(1,1,1), 0);
|
||||
collisionEngine.addToStaticSpace(box);
|
||||
collisionEngine.createCubeGeom(new Vector3d(1,1,1), 0);
|
||||
|
||||
//simulate the physics
|
||||
collisionEngine.simulatePhysics();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user