Esempio n. 1
0
 GoalCI(btScalar goal_width, btScalar goal_depth, btScalar goal_height,
        btScalar wall_width)
     : btRigidBodyCI(0, nullptr, &goal_shape, {0, 0, 0}),
       wall_side{
           {goal_depth / 2 + wall_width / 2, wall_width / 2, goal_height / 2}},
       wall_rear{{wall_width / 2, goal_width / 2, goal_height / 2}},
       goal_shape{} {
   goal_shape.addChildShape(
       btTransform({0, 0, 0, 1},
                   {-goal_depth / 2 - wall_width / 2,
                    -goal_width / 2 - wall_width / 2, goal_height / 2}),
       &wall_side);
   goal_shape.addChildShape(
       btTransform({0, 0, 0, 1},
                   {-goal_depth / 2 - wall_width / 2,
                    +goal_width / 2 + wall_width / 2, goal_height / 2}),
       &wall_side);
   goal_shape.addChildShape(
       btTransform({0, 0, 0, 1},
                   {-goal_depth - wall_width / 2, 0, goal_height / 2}),
       &wall_rear);
 }
Esempio n. 2
0
					void Process(int i)
					{
						const btCollisionShape* childCollisionShape = m_compoundShape->getChildShape(i);
						const btTransform& childTrans = m_compoundShape->getChildTransform(i);
						btTransform childWorldTrans = m_colObjWorldTransform * childTrans;
						
						// replace collision shape so that callback can determine the triangle
						btCollisionShape* saveCollisionShape = m_collisionObject->getCollisionShape();
						m_collisionObject->internalSetTemporaryCollisionShape((btCollisionShape*)childCollisionShape);

						LocalInfoAdder2 my_cb(i, &m_resultCallback);

						rayTestSingle(
							m_rayFromTrans,
							m_rayToTrans,
							m_collisionObject,
							childCollisionShape,
							childWorldTrans,
							my_cb);
						
						// restore
						m_collisionObject->internalSetTemporaryCollisionShape(saveCollisionShape);
					}
Esempio n. 3
0
		virtual void processTriangle(btVector3* triangleVerts, int partId, int triangleIndex)
		{
			if (!m_oncePerSphere)
			{
				btTransform tr;
				tr.setIdentity();
				tr.setOrigin(m_curSpherePos);

				btTriangleShape triangleShape(triangleVerts[0],triangleVerts[1],triangleVerts[2]);
				SphereTriangleDetector detector(m_sphereChildShape,&triangleShape,0.);
				btVector3 hitPos,hitNormal;
				btScalar hitDepth,timeOfImpact;
				if (detector.collide(m_curSpherePos,hitPos,hitNormal,hitDepth,timeOfImpact,0.))
				{
					m_oncePerSphere = true;
					m_bunnyCompound->addChildShape(tr,m_sphereChildShape);
				}
			}
		}