Search in sources :

Example 21 with Collidable

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;
}
Also used : Collidable(spacegraph.space3d.phys.Collidable) ClosestRay(spacegraph.space3d.phys.collision.ClosestRay)

Example 22 with Collidable

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;
}
Also used : Collidable(spacegraph.space3d.phys.Collidable) PersistentManifold(spacegraph.space3d.phys.collision.narrow.PersistentManifold)

Example 23 with Collidable

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;
}
Also used : Collidable(spacegraph.space3d.phys.Collidable)

Example 24 with Collidable

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);
    }
}
Also used : Collidable(spacegraph.space3d.phys.Collidable) ManifoldPoint(spacegraph.space3d.phys.collision.narrow.ManifoldPoint) spacegraph.util.math.v3(spacegraph.util.math.v3) ManifoldPoint(spacegraph.space3d.phys.collision.narrow.ManifoldPoint)

Example 25 with Collidable

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);
    }
}
Also used : Collidable(spacegraph.space3d.phys.Collidable) Broadphasing(spacegraph.space3d.phys.collision.broad.Broadphasing)

Aggregations

Collidable (spacegraph.space3d.phys.Collidable)26 Transform (spacegraph.space3d.phys.math.Transform)6 spacegraph.util.math.v3 (spacegraph.util.math.v3)6 CollisionShape (spacegraph.space3d.phys.shape.CollisionShape)4 PersistentManifold (spacegraph.space3d.phys.collision.narrow.PersistentManifold)3 CompoundShape (spacegraph.space3d.phys.shape.CompoundShape)3 Broadphasing (spacegraph.space3d.phys.collision.broad.Broadphasing)2 ManifoldPoint (spacegraph.space3d.phys.collision.narrow.ManifoldPoint)2 ConcaveShape (spacegraph.space3d.phys.shape.ConcaveShape)2 SimpleSpatial (spacegraph.space3d.SimpleSpatial)1 Spatial (spacegraph.space3d.Spatial)1 Body3D (spacegraph.space3d.phys.Body3D)1 ClosestRay (spacegraph.space3d.phys.collision.ClosestRay)1 BroadphasePair (spacegraph.space3d.phys.collision.broad.BroadphasePair)1 CollisionAlgorithm (spacegraph.space3d.phys.collision.broad.CollisionAlgorithm)1 VoronoiSimplexSolver (spacegraph.space3d.phys.collision.narrow.VoronoiSimplexSolver)1 ContactConstraint (spacegraph.space3d.phys.constraint.ContactConstraint)1 SolverConstraint (spacegraph.space3d.phys.constraint.SolverConstraint)1 TypedConstraint (spacegraph.space3d.phys.constraint.TypedConstraint)1 ConvexShape (spacegraph.space3d.phys.shape.ConvexShape)1