private bool CreateGeom(bool forceRebuild, BSPhysObject prim, PhysicalDestructionCallback shapeCallback) { bool ret = false; bool haveShape = false; bool nativeShapePossible = true; PrimitiveBaseShape pbs = prim.BaseShape; // Kludge to create the capsule for the avatar. // TDOD: Remove/redo this when BSShapeAvatar is working!! BSCharacter theChar = prim as BSCharacter; if (theChar != null) { DereferenceExistingShape(prim, shapeCallback); switch (BSParam.AvatarShape) { case AvatarShapeCapsule: prim.PhysShape = BSShapeNative.GetReference(m_physicsScene, prim, BSPhysicsShapeType.SHAPE_CAPSULE, FixedShapeKey.KEY_CAPSULE); ret = true; haveShape = true; break; case AvatarShapeCube: prim.PhysShape = BSShapeNative.GetReference(m_physicsScene, prim, BSPhysicsShapeType.SHAPE_BOX, FixedShapeKey.KEY_CAPSULE); ret = true; haveShape = true; break; case AvatarShapeOvoid: // Saddly, Bullet doesn't scale spheres so this doesn't work as an avatar shape prim.PhysShape = BSShapeNative.GetReference(m_physicsScene, prim, BSPhysicsShapeType.SHAPE_SPHERE, FixedShapeKey.KEY_CAPSULE); ret = true; haveShape = true; break; case AvatarShapeMesh: break; default: break; } } // If the prim attributes are simple, this could be a simple Bullet native shape // Native shapes work whether to object is static or physical. if (!haveShape && nativeShapePossible && pbs != null && PrimHasNoCuts(pbs) && (!pbs.SculptEntry || (pbs.SculptEntry && !BSParam.ShouldMeshSculptedPrim)) ) { // Get the scale of any existing shape so we can see if the new shape is same native type and same size. OMV.Vector3 scaleOfExistingShape = OMV.Vector3.Zero; if (prim.PhysShape.HasPhysicalShape) { scaleOfExistingShape = m_physicsScene.PE.GetLocalScaling(prim.PhysShape.physShapeInfo); } if (DDetail) { DetailLog("{0},BSShapeCollection.CreateGeom,maybeNative,force={1},primScale={2},primSize={3},primShape={4}", prim.LocalID, forceRebuild, prim.Scale, prim.Size, prim.PhysShape.physShapeInfo.shapeType); } // It doesn't look like Bullet scales native spheres so make sure the scales are all equal if ((pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1) && pbs.Scale.X == pbs.Scale.Y && pbs.Scale.Y == pbs.Scale.Z) { haveShape = true; if (forceRebuild || prim.PhysShape.ShapeType != BSPhysicsShapeType.SHAPE_SPHERE ) { DereferenceExistingShape(prim, shapeCallback); prim.PhysShape = BSShapeNative.GetReference(m_physicsScene, prim, BSPhysicsShapeType.SHAPE_SPHERE, FixedShapeKey.KEY_SPHERE); ret = true; } if (DDetail) { DetailLog("{0},BSShapeCollection.CreateGeom,sphere,force={1},rebuilt={2},shape={3}", prim.LocalID, forceRebuild, ret, prim.PhysShape); } } // If we didn't make a sphere, maybe a box will work. if (!haveShape && pbs.ProfileShape == ProfileShape.Square && pbs.PathCurve == (byte)Extrusion.Straight) { haveShape = true; if (forceRebuild || prim.Scale != scaleOfExistingShape || prim.PhysShape.ShapeType != BSPhysicsShapeType.SHAPE_BOX ) { DereferenceExistingShape(prim, shapeCallback); prim.PhysShape = BSShapeNative.GetReference(m_physicsScene, prim, BSPhysicsShapeType.SHAPE_BOX, FixedShapeKey.KEY_BOX); ret = true; } if (DDetail) { DetailLog("{0},BSShapeCollection.CreateGeom,box,force={1},rebuilt={2},shape={3}", prim.LocalID, forceRebuild, ret, prim.PhysShape); } } } // If a simple shape is not happening, create a mesh and possibly a hull. if (!haveShape && pbs != null) { ret = CreateGeomMeshOrHull(prim, shapeCallback); } m_physicsScene.PE.ResetBroadphasePool(m_physicsScene.World); // DEBUG DEBUG return(ret); }