示例#1
0
 private static void SetCommonProperties(PhysxScene scene, PhysicsShape shape, OpenMetaverse.Vector3 position, OpenMetaverse.Quaternion rotation, PhysX.RigidActor physActor,
                                         bool physical, Material material)
 {
     shape.AssignToActor(physActor, material.PhyMaterial, physical);
     physActor.GlobalPose =
         PhysX.Math.Matrix.RotationQuaternion(new PhysX.Math.Quaternion(rotation.X, rotation.Y, rotation.Z, rotation.W)) *
         PhysX.Math.Matrix.Translation(position.X, position.Y, position.Z);
 }
示例#2
0
        private void CombineChildShape(PhysicsShape childShape, PhysxPrim newChild, OpenMetaverse.Vector3 localPos, OpenMetaverse.Quaternion localRot, 
            bool delayInertiaRecalc)
        {
            //calculate the local rotation for the new shape we'll add to replace the combined child
            PhysX.Math.Matrix localPose = PhysUtil.PositionToMatrix(localPos, localRot);

            if (!_isPhysical || this.CheckComplexityLimitsWithNewChild(childShape))
            {
                try
                {
                    List<PhysX.Shape> actorShapes = childShape.AssignToActor(_actor, newChild.PhysxProperties.PhysxMaterial.PhyMaterial, localPose, _isPhysical);

                    _childShapes.Add(newChild, new RelatedShapes { ChildShape = childShape, PhyShapes = actorShapes });
                    foreach (PhysX.Shape shape in actorShapes)
                    {
                        _shapeToPrimIndex.Add(shape, newChild);
                    }

                    CollisionGroup.SetCollisionGroup(_collisionGroup, actorShapes);

                    if (!delayInertiaRecalc) UpdateMassAndInertia();

                    if (newChild.Properties.WantsCollisionNotification)
                    {
                        this.EnableChildCollisionEventsSync(newChild, true);
                    }

                    newChild._isPhysical = _isPhysical;
                }
                catch (NullReferenceException e) //this catch is in place to try and find an obscure bug where a cast inside the C++/CLI side of the physx sdk throws
                {
                    m_log.ErrorFormat("[InWorldz.PhysX] Unable to assign child shapes to a physactor: {0}, Material: {1}, Pose: {2}", e, newChild.PhysxProperties.PhysxMaterial.PhyMaterial, localPose);
                    _childShapes.Add(newChild, new RelatedShapes { ChildShape = childShape, PhyShapes = new List<PhysX.Shape>(0) });
                    childShape.DecRef();
                }
            }
            else
            {
                //too complex, free the child shape and issue a warning to the owner
                _childShapes.Add(newChild, new RelatedShapes { ChildShape = childShape, PhyShapes = new List<PhysX.Shape>(0) });

                childShape.DecRef();
            }
        }
示例#3
0
 private static void SetCommonProperties(PhysxScene scene, PhysicsShape shape, OpenMetaverse.Vector3 position, OpenMetaverse.Quaternion rotation, PhysX.RigidActor physActor,
     bool physical, Material material)
 {
     shape.AssignToActor(physActor, material.PhyMaterial, physical);
     physActor.GlobalPose =
         PhysX.Math.Matrix.RotationQuaternion(new PhysX.Math.Quaternion(rotation.X, rotation.Y, rotation.Z, rotation.W)) *
         PhysX.Math.Matrix.Translation(position.X, position.Y, position.Z);
 }