Exemplo n.º 1
0
        public override void ContactPointCallback(ref MyGridContactInfo value)
        {
            HkContactPointProperties contactProperties = value.Event.ContactProperties;

            contactProperties.Friction    = 0.85f;
            contactProperties.Restitution = 0.2f;
            value.EnableParticles         = false;
            value.RubberDeformation       = true;
        }
Exemplo n.º 2
0
        public override void ContactPointCallback(ref MyGridContactInfo value)
        {
            Vector3 normal = value.Event.ContactPoint.Normal;

            this.m_contactNormals.PushNext(ref normal);
            MyVoxelMaterialDefinition voxelSurfaceMaterial = value.VoxelSurfaceMaterial;

            if (voxelSurfaceMaterial != null)
            {
                this.m_frictionCollector = voxelSurfaceMaterial.Friction;
            }
            float friction = this.Friction;

            if ((this.m_isSuspensionMounted && ((value.CollidingEntity is MyCubeGrid) && (value.OtherBlock != null))) && (value.OtherBlock.FatBlock == null))
            {
                friction *= 0.07f;
                this.m_frictionCollector = 0.7f;
            }
            HkContactPointProperties contactProperties = value.Event.ContactProperties;

            contactProperties.Friction    = friction;
            contactProperties.Restitution = 0.5f;
            value.EnableParticles         = false;
            value.RubberDeformation       = true;
            ulong simulationFrameCounter = MySandboxGame.Static.SimulationFrameCounter;

            if (simulationFrameCounter != this.LastContactFrameNumber)
            {
                Vector3 vector2;
                this.LastContactFrameNumber = simulationFrameCounter;
                Vector3D contactPosition = value.ContactPosition;
                if (this.m_contactNormals.GetAvgNormalCached(out vector2))
                {
                    normal = vector2;
                }
                string particleName = null;
                if (!(value.CollidingEntity is MyVoxelBase) || !MyFakes.ENABLE_DRIVING_PARTICLES)
                {
                    if ((value.CollidingEntity is MyCubeGrid) && MyFakes.ENABLE_DRIVING_PARTICLES)
                    {
                        MyStringHash materialAt = (value.CollidingEntity as MyCubeGrid).Physics.GetMaterialAt(contactPosition);
                        particleName = MyMaterialPropertiesHelper.Static.GetCollisionEffect(MyMaterialPropertiesHelper.CollisionType.Start, this.m_wheelStringHash, materialAt);
                    }
                }
                else if (voxelSurfaceMaterial != null)
                {
                    MyStringHash materialTypeNameHash = voxelSurfaceMaterial.MaterialTypeNameHash;
                    particleName = MyMaterialPropertiesHelper.Static.GetCollisionEffect(MyMaterialPropertiesHelper.CollisionType.Start, this.m_wheelStringHash, materialTypeNameHash);
                }
                if (this.Render != null)
                {
                    if (particleName != null)
                    {
                        this.Render.TrySpawnParticle(particleName, ref contactPosition, ref normal);
                    }
                    this.Render.UpdateParticle(ref contactPosition, ref normal);
                }
                if (((particleName != null) && Sync.IsServer) && (MySession.Static.Settings.OnlineMode != MyOnlineModeEnum.OFFLINE))
                {
                    ParticleData data = new ParticleData {
                        EffectName       = particleName,
                        PositionRelative = (Vector3)(contactPosition - base.PositionComp.WorldMatrix.Translation),
                        Normal           = value.Event.ContactPoint.Normal
                    };
                    this.m_particleData.Value = data;
                }
                this.RegisterPerFrameUpdate();
            }
        }