Пример #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);
 }
Пример #2
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);
				}
			}
		}