use of spacegraph.space3d.phys.Collidable in project narchy by automenta.
the class OrbMouse method mouseClick.
private boolean mouseClick(int button, int x, int y) {
switch(button) {
case MouseEvent.BUTTON3:
ClosestRay c = mousePick(x, y);
if (c.hasHit()) {
Collidable co = c.collidable;
// System.out.println("zooming to " + co);
// TODO compute new azi and ele that match the current viewing angle values by backcomputing the vector delta
space.camera(co.transform, co.shape().getBoundingRadius() * 2.5f);
return true;
}
break;
}
return false;
}
use of spacegraph.space3d.phys.Collidable in project narchy by automenta.
the class DefaultIntersecter method getNewManifold.
@Override
public PersistentManifold getNewManifold(Object b0, Object b1) {
// gNumManifold++;
// btAssert(gNumManifold < 65535);
Collidable body0 = (Collidable) b0;
Collidable body1 = (Collidable) b1;
/*
void* mem = 0;
if (m_persistentManifoldPoolAllocator->getFreeCount())
{
mem = m_persistentManifoldPoolAllocator->allocate(sizeof(btPersistentManifold));
} else
{
mem = btAlignedAlloc(sizeof(btPersistentManifold),16);
}
btPersistentManifold* manifold = new(mem) btPersistentManifold (body0,body1,0);
manifold->m_index1a = m_manifoldsPtr.size();
m_manifoldsPtr.push_back(manifold);
*/
PersistentManifold manifold = new PersistentManifold(BulletGlobals.the.get());
manifold.init(body0, body1, 0);
manifold.index1a = manifolds.size();
manifolds.add(manifold);
return manifold;
}
use of spacegraph.space3d.phys.Collidable in project narchy by automenta.
the class GhostPairCallback method removeOverlappingPair.
@Override
public Object removeOverlappingPair(Broadphasing proxy0, Broadphasing proxy1, Intersecter intersecter) {
Collidable colObj0 = proxy0.data;
Collidable colObj1 = proxy1.data;
GhostObject ghost0 = GhostObject.upcast(colObj0);
GhostObject ghost1 = GhostObject.upcast(colObj1);
if (ghost0 != null) {
ghost0.removeOverlappingObjectInternal(proxy1, intersecter, proxy0);
}
if (ghost1 != null) {
ghost1.removeOverlappingObjectInternal(proxy0, intersecter, proxy1);
}
return null;
}
use of spacegraph.space3d.phys.Collidable in project narchy by automenta.
the class ManifoldResult method addContactPoint.
@Override
public void addContactPoint(v3 normalOnBInWorld, v3 pointInWorld, float depth, float breakingThresh) {
assert (manifoldPtr != null);
if (depth > breakingThresh) {
return;
}
boolean isSwapped = manifoldPtr.getBody0() != body0;
v3 pointA = new v3();
pointA.scaleAdd(depth, normalOnBInWorld, pointInWorld);
v3 localA = new v3();
v3 localB = new v3();
if (isSwapped) {
rootTransB.invXform(pointA, localA);
rootTransA.invXform(pointInWorld, localB);
} else {
rootTransA.invXform(pointA, localA);
rootTransB.invXform(pointInWorld, localB);
}
ManifoldPoint newPt = new ManifoldPoint();
newPt.init(localA, localB, normalOnBInWorld, depth);
newPt.positionWorldOnA.set(pointA);
newPt.positionWorldOnB.set(pointInWorld);
int insertIndex = manifoldPtr.getCacheEntry(newPt, manifoldPtr.getContactBreakingThreshold());
newPt.combinedFriction = calculateCombinedFriction(body0, body1);
newPt.combinedRestitution = calculateCombinedRestitution(body0, body1);
// BP mod, store contact triangles.
newPt.partId0 = partId0;
newPt.partId1 = partId1;
newPt.index0 = index0;
newPt.index1 = index1;
// / todo, check this for any side effects
if (insertIndex >= 0) {
// const btManifoldPoint& oldPoint = m_manifoldPtr->getContactPoint(insertIndex);
manifoldPtr.replaceContactPoint(newPt, insertIndex);
} else {
insertIndex = manifoldPtr.addManifoldPoint(newPt);
}
// User can override friction and/or restitution
if (manifoldPtr.globals.getContactAddedCallback() != null && // and if either of the two bodies requires custom material
((body0.getCollisionFlags() & CollisionFlags.CUSTOM_MATERIAL_CALLBACK) != 0 || (body1.getCollisionFlags() & CollisionFlags.CUSTOM_MATERIAL_CALLBACK) != 0)) {
// experimental feature info, for per-triangle material etc.
Collidable obj0 = isSwapped ? body1 : body0;
Collidable obj1 = isSwapped ? body0 : body1;
manifoldPtr.globals.getContactAddedCallback().contactAdded(manifoldPtr.getContactPoint(insertIndex), obj0, partId0, index0, obj1, partId1, index1);
}
}
use of spacegraph.space3d.phys.Collidable in project narchy by automenta.
the class PairCachingGhostObject method addOverlappingObjectInternal.
/**
* This method is mainly for expert/internal use only.
*/
@Override
public void addOverlappingObjectInternal(Broadphasing otherProxy, Broadphasing thisProxy) {
Broadphasing actualThisProxy = thisProxy != null ? thisProxy : broadphase;
assert (actualThisProxy != null);
Collidable otherObject = otherProxy.data;
assert (otherObject != null);
// if this linearSearch becomes too slow (too many overlapping objects) we should add a more appropriate data structure
int index = overlappingObjects.indexOf(otherObject);
if (index == -1) {
overlappingObjects.add(otherObject);
hashPairCache.addOverlappingPair(actualThisProxy, otherProxy);
}
}
Aggregations