本文整理汇总了C++中btManifoldPoint类的典型用法代码示例。如果您正苦于以下问题:C++ btManifoldPoint类的具体用法?C++ btManifoldPoint怎么用?C++ btManifoldPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了btManifoldPoint类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: addSingleResult
virtual btScalar addSingleResult(btManifoldPoint& cp, const btCollisionObjectWrapper* colObj0Wrap,int partId0,int index0,const btCollisionObjectWrapper* colObj1Wrap,int partId1,int index1)
{
glBegin(GL_LINES);
glColor3f(0, 0, 0);
btVector3 ptA = cp.getPositionWorldOnA();
btVector3 ptB = cp.getPositionWorldOnB();
glVertex3d(ptA.x(),ptA.y(),ptA.z());
glVertex3d(ptB.x(),ptB.y(),ptB.z());
glEnd();
return 0;
}
开发者ID:Lunavast,项目名称:bullet-physics,代码行数:15,代码来源:CollisionInterfaceDemo.cpp
示例2: addSingleResult
btScalar GodotAllContactResultCallback::addSingleResult(btManifoldPoint &cp, const btCollisionObjectWrapper *colObj0Wrap, int partId0, int index0, const btCollisionObjectWrapper *colObj1Wrap, int partId1, int index1) {
if (cp.getDistance() <= 0) {
PhysicsDirectSpaceState::ShapeResult &result = m_results[m_count];
// Penetrated
CollisionObjectBullet *colObj;
if (m_self_object == colObj0Wrap->getCollisionObject()) {
colObj = static_cast<CollisionObjectBullet *>(colObj1Wrap->getCollisionObject()->getUserPointer());
result.shape = cp.m_index1;
} else {
colObj = static_cast<CollisionObjectBullet *>(colObj0Wrap->getCollisionObject()->getUserPointer());
result.shape = cp.m_index0;
}
if (colObj)
result.collider_id = colObj->get_instance_id();
else
result.collider_id = 0;
result.collider = 0 == result.collider_id ? NULL : ObjectDB::get_instance(result.collider_id);
result.rid = colObj->get_self();
++m_count;
}
return m_count < m_resultMax;
}
开发者ID:KelinciFX,项目名称:godot,代码行数:27,代码来源:godot_result_callbacks.cpp
示例3: addSingleResult
virtual btScalar addSingleResult(btManifoldPoint& cp, const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1)
{
distance = cp.getDistance();
positionWorldOnA = Vector3d(cp.m_positionWorldOnA.getX(),cp.m_positionWorldOnA.getY(),cp.m_positionWorldOnA.getZ());
positionWorldOnB = Vector3d(cp.m_positionWorldOnB.getX(),cp.m_positionWorldOnB.getY(),cp.m_positionWorldOnB.getZ());
return 1.f;
}
开发者ID:bo-wu,项目名称:surgical,代码行数:8,代码来源:collisionUtils.cpp
示例4: addSingleResult
virtual btScalar addSingleResult(btManifoldPoint& cp,
const btCollisionObject* col0, int partId0, int index0,
const btCollisionObject* col1, int partId1, int index1)
{
const RigidBody* body = dynamic_cast<const RigidBody*>(col1);
if(body && body->mName != mFilter)
{
btScalar distsqr = mOrigin.distance2(cp.getPositionWorldOnA());
if(!mObject || distsqr < mLeastDistSqr)
{
mObject = body;
mLeastDistSqr = distsqr;
mContactPoint = cp.getPositionWorldOnA();
}
}
return 0.f;
}
开发者ID:0xmono,项目名称:openmw,代码行数:18,代码来源:physic.cpp
示例5: sortCachedPoints
int btPersistentManifold::sortCachedPoints(const btManifoldPoint& pt)
{
//calculate 4 possible cases areas, and take biggest area
//also need to keep 'deepest'
int maxPenetrationIndex = -1;
#define KEEP_DEEPEST_POINT 1
#ifdef KEEP_DEEPEST_POINT
btScalar maxPenetration = pt.getDistance();
for (int i=0;i<4;i++)
{
if (m_pointCache[i].getDistance() < maxPenetration)
{
maxPenetrationIndex = i;
maxPenetration = m_pointCache[i].getDistance();
}
}
#endif //KEEP_DEEPEST_POINT
btScalar res0(btScalar(0.)),res1(btScalar(0.)),res2(btScalar(0.)),res3(btScalar(0.));
if (maxPenetrationIndex != 0)
{
btVector3 a0 = pt.m_localPointA-m_pointCache[1].m_localPointA;
btVector3 b0 = m_pointCache[3].m_localPointA-m_pointCache[2].m_localPointA;
btVector3 cross = a0.cross(b0);
res0 = cross.length2();
}
if (maxPenetrationIndex != 1)
{
btVector3 a1 = pt.m_localPointA-m_pointCache[0].m_localPointA;
btVector3 b1 = m_pointCache[3].m_localPointA-m_pointCache[2].m_localPointA;
btVector3 cross = a1.cross(b1);
res1 = cross.length2();
}
if (maxPenetrationIndex != 2)
{
btVector3 a2 = pt.m_localPointA-m_pointCache[0].m_localPointA;
btVector3 b2 = m_pointCache[3].m_localPointA-m_pointCache[1].m_localPointA;
btVector3 cross = a2.cross(b2);
res2 = cross.length2();
}
if (maxPenetrationIndex != 3)
{
btVector3 a3 = pt.m_localPointA-m_pointCache[0].m_localPointA;
btVector3 b3 = m_pointCache[2].m_localPointA-m_pointCache[1].m_localPointA;
btVector3 cross = a3.cross(b3);
res3 = cross.length2();
}
btVector4 maxvec(res0,res1,res2,res3);
int biggestarea = maxvec.closestAxis4();
return biggestarea;
}
开发者ID:hulefei,项目名称:Game-and-Graphics-Programming-for-iOS-and-Android-with-OpenGL-ES-2.0,代码行数:56,代码来源:btPersistentManifold.cpp
示例6: addSingleResult
virtual btScalar addSingleResult(btManifoldPoint& cp,
const btCollisionObjectWrapper* colObj0Wrap, int partId0, int index0,
const btCollisionObjectWrapper* colObj1Wrap, int partId1, int index1)
{
//if (!colObj0Wrap->m_collisionObject->checkCollideWith(colObj1Wrap->m_collisionObject) ||
// !colObj1Wrap->m_collisionObject->checkCollideWith(colObj0Wrap->m_collisionObject))
// return 1.0f;
if (cp.getDistance() < 0.05f)
{
mHasCollision = true;
if (colObj0Wrap->m_collisionObject->getUserPointer() == mMe)
{
mCollided.push_back((RigidBody*)colObj1Wrap->m_collisionObject->getUserPointer());
}
else if (colObj1Wrap->m_collisionObject->getUserPointer() == mMe)
{
mCollided.push_back((RigidBody*)colObj0Wrap->m_collisionObject->getUserPointer());
}
}
return 1.0f;
}
开发者ID:fastbird,项目名称:fastbirdEngine_NewAPI,代码行数:22,代码来源:RigidBodyImpl.cpp
示例7: GameContactAddedCallback
bool GameContactAddedCallback( btManifoldPoint& cp,
const btCollisionObject* colObj0, int partId0 , int index0,
const btCollisionObject* colObj1, int partId1 , int index1)
{
float dist = cp.m_distance1;
TActor* obj0 = (TActor*) colObj0->getUserPointer();
TActor* obj1 = (TActor*) colObj1->getUserPointer();
if ( obj0 == NULL || obj1 == NULL )
return false;
if ( dist > 0 )
return false;
if ( obj0->getModelData().mass >= obj1->getModelData().mass )
{
Vec3D pos = obj1->getPosition();
obj1->setPosition( pos + dist * cp.m_normalWorldOnB );
}
else
{
Vec3D pos = obj0->getPosition();
obj0->setPosition( pos - dist * cp.m_normalWorldOnB );
}
cp.setDistance( 0 );
cp.m_appliedImpulseLateral1 = 0;
cp.m_appliedImpulseLateral2 = 0;
return true;
}
开发者ID:uvbs,项目名称:GameProject,代码行数:37,代码来源:TPhySystem.cpp
示例8: materialCombinerCallback
bool materialCombinerCallback(btManifoldPoint& cp,
const btCollisionObject* colObj0,
int partId0,
int index0,
const btCollisionObject* colObj1,
int partId1,
int index1)
{
btVector3 impact_point = cp.getPositionWorldOnA();
if (!colObj0->isStaticObject() && colObj0->isActive())
{
osg::Node *n0 = static_cast<osg::Node*>(colObj0->getUserPointer());
osg::Node *n1 = static_cast<osg::Node*>(colObj1->getUserPointer());
std::cout << "Hit at ["<< impact_point.getX() << ", " << impact_point.getY() << ", " << impact_point.getZ() << "] "<< std::endl;
//if (n0 && !n0->getName().empty()) std::cout << " obj0: " << n0->getName() << std::endl;
if (n1 && !n1->getName().empty()) std::cout << " obj1: " << n1->getName() << std::endl;
//std::cout << "Hit between " << static_cast<osg::Node *> (colObj0->getUserPointer())->getName() << " and " << static_cast<osg::Node *> (colObj1->getUserPointer())->getName() << " at ["<< impact_point.getX() << ", " << impact_point.getY() << ", " << impact_point.getZ() << "] "<< std::endl;
}
return false;
}
开发者ID:mikewoz,项目名称:spinframework,代码行数:24,代码来源:bullettest.cpp
示例9: handleVehicleResponse
void handleVehicleResponse(GameObject* object, btManifoldPoint& mp, bool isA)
{
bool isVehicle = object->type() == GameObject::Vehicle;
if(! isVehicle) return;
if( mp.getAppliedImpulse() <= 100.f ) return;
btVector3 src, dmg;
if(isA) {
src = mp.getPositionWorldOnB();
dmg = mp.getPositionWorldOnA();
}
else {
src = mp.getPositionWorldOnA();
dmg = mp.getPositionWorldOnB();
}
object->takeDamage({
{dmg.x(), dmg.y(), dmg.z()},
{src.x(), src.y(), src.z()},
0.f,
GameObject::DamageInfo::Physics,
mp.getAppliedImpulse()
});
}
开发者ID:CyberSys,项目名称:openrw,代码行数:24,代码来源:GameWorld.cpp
示例10: addSingleResult
virtual btScalar addSingleResult(btManifoldPoint& cp, const btCollisionObjectWrapper* colObj0Wrap,int partId0,int index0,const btCollisionObjectWrapper* colObj1Wrap,int partId1,int index1)
{
if (cp.getDistance()<=m_margin)
m_connected = true;
return 1.f;
}
开发者ID:Ochakko,项目名称:MameBake3D,代码行数:6,代码来源:btFractureBody.cpp
示例11: btAdjustInternalEdgeContacts
/// Changes a btManifoldPoint collision normal to the normal from the mesh.
void btAdjustInternalEdgeContacts(btManifoldPoint& cp, const btCollisionObject* colObj0,const btCollisionObject* colObj1, int partId0, int index0, int normalAdjustFlags)
{
//btAssert(colObj0->getCollisionShape()->getShapeType() == TRIANGLE_SHAPE_PROXYTYPE);
if (colObj0->getCollisionShape()->getShapeType() != TRIANGLE_SHAPE_PROXYTYPE)
return;
btBvhTriangleMeshShape* trimesh = (btBvhTriangleMeshShape*)colObj0->getRootCollisionShape();
btTriangleInfoMap* triangleInfoMapPtr = (btTriangleInfoMap*) trimesh->getTriangleInfoMap();
if (!triangleInfoMapPtr)
return;
int hash = btGetHash(partId0,index0);
btTriangleInfo* info = triangleInfoMapPtr->find(hash);
if (!info)
return;
btScalar frontFacing = (normalAdjustFlags & BT_TRIANGLE_CONVEX_BACKFACE_MODE)==0? 1.f : -1.f;
const btTriangleShape* tri_shape = static_cast<const btTriangleShape*>(colObj0->getCollisionShape());
btVector3 v0,v1,v2;
tri_shape->getVertex(0,v0);
tri_shape->getVertex(1,v1);
tri_shape->getVertex(2,v2);
btVector3 center = (v0+v1+v2)*btScalar(1./3.);
btVector3 red(1,0,0), green(0,1,0),blue(0,0,1),white(1,1,1),black(0,0,0);
btVector3 tri_normal;
tri_shape->calcNormal(tri_normal);
//btScalar dot = tri_normal.dot(cp.m_normalWorldOnB);
btVector3 nearest;
btNearestPointInLineSegment(cp.m_localPointB,v0,v1,nearest);
btVector3 contact = cp.m_localPointB;
#ifdef BT_INTERNAL_EDGE_DEBUG_DRAW
const btTransform& tr = colObj0->getWorldTransform();
btDebugDrawLine(tr*nearest,tr*cp.m_localPointB,red);
#endif //BT_INTERNAL_EDGE_DEBUG_DRAW
bool isNearEdge = false;
int numConcaveEdgeHits = 0;
int numConvexEdgeHits = 0;
btVector3 localContactNormalOnB = colObj0->getWorldTransform().getBasis().transpose() * cp.m_normalWorldOnB;
localContactNormalOnB.normalize();//is this necessary?
if ((info->m_edgeV0V1Angle)< SIMD_2_PI)
{
#ifdef BT_INTERNAL_EDGE_DEBUG_DRAW
btDebugDrawLine(tr*contact,tr*(contact+cp.m_normalWorldOnB*10),black);
#endif
btScalar len = (contact-nearest).length();
if(len<triangleInfoMapPtr->m_edgeDistanceThreshold)
{
btVector3 edge(v0-v1);
isNearEdge = true;
if (info->m_edgeV0V1Angle==btScalar(0))
{
numConcaveEdgeHits++;
} else
{
bool isEdgeConvex = (info->m_flags & TRI_INFO_V0V1_CONVEX);
btScalar swapFactor = isEdgeConvex ? btScalar(1) : btScalar(-1);
#ifdef BT_INTERNAL_EDGE_DEBUG_DRAW
btDebugDrawLine(tr*nearest,tr*(nearest+swapFactor*tri_normal*10),white);
#endif //BT_INTERNAL_EDGE_DEBUG_DRAW
btVector3 nA = swapFactor * tri_normal;
btQuaternion orn(edge,info->m_edgeV0V1Angle);
btVector3 computedNormalB = quatRotate(orn,tri_normal);
if (info->m_flags & TRI_INFO_V0V1_SWAP_NORMALB)
computedNormalB*=-1;
btVector3 nB = swapFactor*computedNormalB;
btScalar NdotA = localContactNormalOnB.dot(nA);
btScalar NdotB = localContactNormalOnB.dot(nB);
bool backFacingNormal = (NdotA< triangleInfoMapPtr->m_convexEpsilon) && (NdotB<triangleInfoMapPtr->m_convexEpsilon);
#ifdef DEBUG_INTERNAL_EDGE
{
btDebugDrawLine(cp.getPositionWorldOnB(),cp.getPositionWorldOnB()+tr.getBasis()*(nB*20),red);
}
#endif //DEBUG_INTERNAL_EDGE
if (backFacingNormal)
{
numConcaveEdgeHits++;
}
//.........这里部分代码省略.........
开发者ID:Amplifying,项目名称:intensityengine,代码行数:101,代码来源:btInternalEdgeUtility.cpp
示例12: setupMultiBodyContactConstraint
void btMultiBodyConstraintSolver::setupMultiBodyContactConstraint(btMultiBodySolverConstraint& solverConstraint,
const btVector3& contactNormal,
btManifoldPoint& cp, const btContactSolverInfo& infoGlobal,
btScalar& relaxation,
bool isFriction, btScalar desiredVelocity, btScalar cfmSlip)
{
BT_PROFILE("setupMultiBodyContactConstraint");
btVector3 rel_pos1;
btVector3 rel_pos2;
btMultiBody* multiBodyA = solverConstraint.m_multiBodyA;
btMultiBody* multiBodyB = solverConstraint.m_multiBodyB;
const btVector3& pos1 = cp.getPositionWorldOnA();
const btVector3& pos2 = cp.getPositionWorldOnB();
btSolverBody* bodyA = multiBodyA ? 0 : &m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdA];
btSolverBody* bodyB = multiBodyB ? 0 : &m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdB];
btRigidBody* rb0 = multiBodyA ? 0 : bodyA->m_originalBody;
btRigidBody* rb1 = multiBodyB ? 0 : bodyB->m_originalBody;
if (bodyA)
rel_pos1 = pos1 - bodyA->getWorldTransform().getOrigin();
if (bodyB)
rel_pos2 = pos2 - bodyB->getWorldTransform().getOrigin();
relaxation = 1.f;
if (multiBodyA)
{
if (solverConstraint.m_linkA<0)
{
rel_pos1 = pos1 - multiBodyA->getBasePos();
} else
{
rel_pos1 = pos1 - multiBodyA->getLink(solverConstraint.m_linkA).m_cachedWorldTransform.getOrigin();
}
const int ndofA = (multiBodyA->isMultiDof() ? multiBodyA->getNumDofs() : multiBodyA->getNumLinks()) + 6;
solverConstraint.m_deltaVelAindex = multiBodyA->getCompanionId();
if (solverConstraint.m_deltaVelAindex <0)
{
solverConstraint.m_deltaVelAindex = m_data.m_deltaVelocities.size();
multiBodyA->setCompanionId(solverConstraint.m_deltaVelAindex);
m_data.m_deltaVelocities.resize(m_data.m_deltaVelocities.size()+ndofA);
} else
{
btAssert(m_data.m_deltaVelocities.size() >= solverConstraint.m_deltaVelAindex+ndofA);
}
solverConstraint.m_jacAindex = m_data.m_jacobians.size();
m_data.m_jacobians.resize(m_data.m_jacobians.size()+ndofA);
m_data.m_deltaVelocitiesUnitImpulse.resize(m_data.m_deltaVelocitiesUnitImpulse.size()+ndofA);
btAssert(m_data.m_jacobians.size() == m_data.m_deltaVelocitiesUnitImpulse.size());
btScalar* jac1=&m_data.m_jacobians[solverConstraint.m_jacAindex];
if(multiBodyA->isMultiDof())
multiBodyA->fillContactJacobianMultiDof(solverConstraint.m_linkA, cp.getPositionWorldOnA(), contactNormal, jac1, m_data.scratch_r, m_data.scratch_v, m_data.scratch_m);
else
multiBodyA->fillContactJacobian(solverConstraint.m_linkA, cp.getPositionWorldOnA(), contactNormal, jac1, m_data.scratch_r, m_data.scratch_v, m_data.scratch_m);
btScalar* delta = &m_data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacAindex];
if(multiBodyA->isMultiDof())
multiBodyA->calcAccelerationDeltasMultiDof(&m_data.m_jacobians[solverConstraint.m_jacAindex],delta,m_data.scratch_r, m_data.scratch_v);
else
multiBodyA->calcAccelerationDeltas(&m_data.m_jacobians[solverConstraint.m_jacAindex],delta,m_data.scratch_r, m_data.scratch_v);
btVector3 torqueAxis0 = rel_pos1.cross(contactNormal);
solverConstraint.m_relpos1CrossNormal = torqueAxis0;
solverConstraint.m_contactNormal1 = contactNormal;
} else
{
btVector3 torqueAxis0 = rel_pos1.cross(contactNormal);
solverConstraint.m_relpos1CrossNormal = torqueAxis0;
solverConstraint.m_contactNormal1 = contactNormal;
solverConstraint.m_angularComponentA = rb0 ? rb0->getInvInertiaTensorWorld()*torqueAxis0*rb0->getAngularFactor() : btVector3(0,0,0);
}
if (multiBodyB)
{
if (solverConstraint.m_linkB<0)
{
rel_pos2 = pos2 - multiBodyB->getBasePos();
} else
{
rel_pos2 = pos2 - multiBodyB->getLink(solverConstraint.m_linkB).m_cachedWorldTransform.getOrigin();
}
const int ndofB = (multiBodyB->isMultiDof() ? multiBodyB->getNumDofs() : multiBodyB->getNumLinks()) + 6;
solverConstraint.m_deltaVelBindex = multiBodyB->getCompanionId();
if (solverConstraint.m_deltaVelBindex <0)
{
//.........这里部分代码省略.........
开发者ID:03050903,项目名称:Urho3D,代码行数:101,代码来源:btMultiBodyConstraintSolver.cpp
示例13: contactProcess
bool contactProcess(btManifoldPoint& cp, void *body0, void *body1)
{
if (true)
{
DEBUG_PRINTF("gContactProcessedCallback : process contactPoint : %p, distance %g\n", &cp, cp.getDistance());
}
return true;
}
开发者ID:bremond,项目名称:siconos,代码行数:8,代码来源:BulletSpaceFilter.cpp
示例14: ContactProcessedCallback
bool GameWorld::ContactProcessedCallback(btManifoldPoint &mp, void *body0, void *body1)
{
auto obA = static_cast<btCollisionObject*>(body0);
auto obB = static_cast<btCollisionObject*>(body1);
if( !( obA->getUserPointer() && obB->getUserPointer() ) ) {
return false;
}
GameObject* a = static_cast<GameObject*>(obA->getUserPointer());
GameObject* b = static_cast<GameObject*>(obB->getUserPointer());
bool valA = a && a->type() == GameObject::Instance;
bool valB = b && b->type() == GameObject::Instance;
if( ! (valA && valB) && (valB || valA) ) {
// Figure out which is the dynamic instance.
InstanceObject* dynInst = nullptr;
const btRigidBody* instBody = nullptr, * otherBody = nullptr;
btVector3 src, dmg;
if( valA ) {
dynInst = static_cast<InstanceObject*>(a);
instBody = static_cast<const btRigidBody*>(obA);
otherBody = static_cast<const btRigidBody*>(obB);
src = mp.getPositionWorldOnB();
dmg = mp.getPositionWorldOnA();
}
else {
dynInst = static_cast<InstanceObject*>(b);
instBody = static_cast<const btRigidBody*>(obB);
otherBody = static_cast<const btRigidBody*>(obA);
src = mp.getPositionWorldOnA();
dmg = mp.getPositionWorldOnB();
}
if( dynInst->dynamics != nullptr && instBody->isStaticObject() ) {
// Attempt to determine relative velocity.
auto dV = (otherBody->getLinearVelocity());
auto impulse = dV.length()/ (otherBody->getInvMass());
if( dynInst->dynamics->uprootForce <= impulse ) {
dynInst->takeDamage({
{dmg.x(), dmg.y(), dmg.z()},
{src.x(), src.y(), src.z()},
0.f,
GameObject::DamageInfo::Physics,
impulse
});
}
}
}
// Handle vehicles
if(a) handleVehicleResponse(a, mp, true);
if(b) handleVehicleResponse(b, mp, false);
return true;
}
开发者ID:CyberSys,项目名称:openrw,代码行数:61,代码来源:GameWorld.cpp
注:本文中的btManifoldPoint类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论