public override int GetHashCode() { unchecked { return((Block.GetHashCode() * 397) ^ AttachmentPoint.GetHashCode()); } }
void IMyDecalProxy.AddDecals(ref MyHitInfo hitInfo, MyStringHash source, object customdata, IMyDecalHandler decalHandler, MyStringHash material) { MyCubeGrid.MyCubeGridHitInfo gridHitInfo = customdata as MyCubeGrid.MyCubeGridHitInfo; if (gridHitInfo != null) { MyPhysicalMaterialDefinition physicalMaterial = this.m_mapIdToBlock.First <KeyValuePair <ushort, MySlimBlock> >().Value.BlockDefinition.PhysicalMaterial; MyDecalRenderInfo renderInfo = new MyDecalRenderInfo { Position = Vector3D.Transform(hitInfo.Position, base.CubeGrid.PositionComp.WorldMatrixInvScaled), Normal = (Vector3)Vector3D.TransformNormal(hitInfo.Normal, base.CubeGrid.PositionComp.WorldMatrixInvScaled), RenderObjectIds = base.CubeGrid.Render.RenderObjectIDs, Source = source }; VertexBoneIndicesWeights?affectingBoneIndicesWeights = gridHitInfo.Triangle.GetAffectingBoneIndicesWeights(ref m_boneIndexWeightTmp); if (affectingBoneIndicesWeights != null) { renderInfo.BoneIndices = affectingBoneIndicesWeights.Value.Indices; renderInfo.BoneWeights = affectingBoneIndicesWeights.Value.Weights; } renderInfo.Material = (material.GetHashCode() != 0) ? material : MyStringHash.GetOrCompute(physicalMaterial.Id.SubtypeName); m_tmpIds.Clear(); decalHandler.AddDecal(ref renderInfo, m_tmpIds); foreach (uint num in m_tmpIds) { base.CubeGrid.RenderData.AddDecal(base.Position, gridHitInfo, num); } } }
void IMyDecalProxy.AddDecals(ref MyHitInfo hitInfo, MyStringHash source, object customdata, IMyDecalHandler decalHandler, MyStringHash material) { MyDecalRenderInfo renderInfo = new MyDecalRenderInfo { Position = hitInfo.Position, Normal = hitInfo.Normal, RenderObjectIds = null, Flags = MyDecalFlags.World, Source = source }; renderInfo.Material = (material.GetHashCode() != 0) ? material : base.Physics.MaterialType; decalHandler.AddDecal(ref renderInfo, null); }
void IMyDecalProxy.AddDecals(MyHitInfo hitInfo, MyStringHash source, object customdata, IMyDecalHandler decalHandler, MyStringHash material) { Debug.Assert(m_mapIdToBlock.Count > 0); MyCubeGridHitInfo gridHitInfo = customdata as MyCubeGridHitInfo; if (gridHitInfo == null) { Debug.Fail("MyCubeGridHitInfo must not be null"); return; } MySlimBlock block = m_mapIdToBlock.First().Value; MyPhysicalMaterialDefinition physicalMaterial = block.BlockDefinition.PhysicalMaterial; MyDecalRenderInfo renderable = new MyDecalRenderInfo(); renderable.Position = Vector3D.Transform(hitInfo.Position, CubeGrid.PositionComp.WorldMatrixInvScaled); renderable.Normal = Vector3D.TransformNormal(hitInfo.Normal, CubeGrid.PositionComp.WorldMatrixInvScaled); renderable.RenderObjectId = CubeGrid.Render.GetRenderObjectID(); VertexBoneIndicesWeights?boneIndicesWeights = gridHitInfo.Triangle.GetAffectingBoneIndicesWeights(ref m_boneIndexWeightTmp); if (boneIndicesWeights.HasValue) { renderable.BoneIndices = boneIndicesWeights.Value.Indices; renderable.BoneWeights = boneIndicesWeights.Value.Weights; } if (material.GetHashCode() == 0) { renderable.Material = MyStringHash.GetOrCompute(physicalMaterial.Id.SubtypeName); } else { renderable.Material = material; } var decalId = decalHandler.AddDecal(ref renderable); if (decalId != null) { CubeGrid.RenderData.AddDecal(Position, gridHitInfo, decalId.Value); } }
void IMyDecalProxy.AddDecals(MyHitInfo hitInfo, MyStringHash source, object customdata, IMyDecalHandler decalHandler, MyStringHash material) { MyDecalRenderInfo info = new MyDecalRenderInfo(); info.Position = hitInfo.Position; info.Normal = hitInfo.Normal; info.RenderObjectId = -1; info.Flags = MyDecalFlags.World; if (material.GetHashCode() == 0) { info.Material = Physics.MaterialType; } else { info.Material = material; } decalHandler.AddDecal(ref info); }
void IMyDecalProxy.AddDecals(MyHitInfo hitInfo, MyStringHash source, object customdata, IMyDecalHandler decalHandler, MyStringHash material) { MyDecalRenderInfo renderable = new MyDecalRenderInfo(); renderable.Flags = MyDecalFlags.World; renderable.Position = hitInfo.Position; renderable.Normal = hitInfo.Normal; renderable.RenderObjectId = Render.GetRenderObjectID(); if (material.GetHashCode() == 0) { renderable.Material = Physics.GetMaterialAt(hitInfo.Position); } else { renderable.Material = material; } decalHandler.AddDecal(ref renderable); }
private static void GetSurfaceAndMaterial(IMyEntity entity, ref Vector3D hitPosition, out MySurfaceImpactEnum surfaceImpact, out MyStringHash materialType) { var voxelBase = entity as MyVoxelBase; if (voxelBase != null) { materialType = MyMaterialType.ROCK; surfaceImpact = MySurfaceImpactEnum.DESTRUCTIBLE; var voxelDefinition = voxelBase.GetMaterialAt(ref hitPosition); if(voxelDefinition != null) materialType = MyStringHash.GetOrCompute(voxelDefinition.MaterialTypeName); } else if (entity is MyCharacter) { surfaceImpact = MySurfaceImpactEnum.CHARACTER; materialType = MyMaterialType.CHARACTER; if ((entity as MyCharacter).Definition.PhysicalMaterial != null) materialType = MyStringHash.GetOrCompute((entity as MyCharacter).Definition.PhysicalMaterial); } else if (entity is MyFloatingObject) { MyFloatingObject obj = entity as MyFloatingObject; materialType = (obj.VoxelMaterial != null) ? MyMaterialType.ROCK : (obj.ItemDefinition != null && obj.ItemDefinition.PhysicalMaterial != MyStringHash.NullOrEmpty ? obj.ItemDefinition.PhysicalMaterial : MyMaterialType.METAL); surfaceImpact = MySurfaceImpactEnum.METAL; } else if (entity is MyTrees) { surfaceImpact = MySurfaceImpactEnum.DESTRUCTIBLE; materialType = MyMaterialType.WOOD; } else if (entity is IMyHandheldGunObject<MyGunBase>) { surfaceImpact = MySurfaceImpactEnum.METAL; materialType = MyMaterialType.METAL; var mat = (entity as IMyHandheldGunObject<MyGunBase>).GunBase; if (mat != null && mat.WeaponProperties != null && mat.WeaponProperties.WeaponDefinition != null) materialType = mat.WeaponProperties.WeaponDefinition.PhysicalMaterial; } else { surfaceImpact = MySurfaceImpactEnum.METAL; materialType = MyMaterialType.METAL; if (entity is MyCubeGrid) { Vector3I blockPos; var grid = (entity as MyCubeGrid); if (grid != null) { grid.FixTargetCube(out blockPos, Vector3D.Transform(hitPosition, grid.PositionComp.WorldMatrixNormalizedInv) / grid.GridSize); var block = grid.GetCubeBlock(blockPos); if (block != null) { if (block.BlockDefinition.PhysicalMaterial != null) { materialType = MyStringHash.GetOrCompute(block.BlockDefinition.PhysicalMaterial.Id.SubtypeName); } } } } } if (materialType.GetHashCode() == 0) materialType = MyMaterialType.METAL; }
public override int GetHashCode() { return((State.GetHashCode() * 397) ^ Id.GetHashCode()); }
public override int GetHashCode() { return((int)((((uint)TypeId.GetHashCode()) << 16) ^ ((uint)SubtypeId.GetHashCode()))); }
private static void GetSurfaceAndMaterial(IMyEntity entity, ref LineD line, ref Vector3D hitPosition, out MySurfaceImpactEnum surfaceImpact, out MyStringHash materialType) { var voxelBase = entity as MyVoxelBase; if (voxelBase != null) { materialType = MyMaterialType.ROCK; surfaceImpact = MySurfaceImpactEnum.DESTRUCTIBLE; var voxelDefinition = voxelBase.GetMaterialAt(ref hitPosition); if (voxelDefinition != null) { materialType = MyStringHash.GetOrCompute(voxelDefinition.MaterialTypeName); } } else if (entity is MyCharacter) { surfaceImpact = MySurfaceImpactEnum.CHARACTER; materialType = MyMaterialType.CHARACTER; if ((entity as MyCharacter).Definition.PhysicalMaterial != null) { materialType = MyStringHash.GetOrCompute((entity as MyCharacter).Definition.PhysicalMaterial); } } else if (entity is MyFloatingObject) { MyFloatingObject obj = entity as MyFloatingObject; materialType = (obj.VoxelMaterial != null) ? MyMaterialType.ROCK : (obj.ItemDefinition != null && obj.ItemDefinition.PhysicalMaterial != MyStringHash.NullOrEmpty ? obj.ItemDefinition.PhysicalMaterial : MyMaterialType.METAL); surfaceImpact = MySurfaceImpactEnum.METAL; } else if (entity is MyTrees) { surfaceImpact = MySurfaceImpactEnum.DESTRUCTIBLE; materialType = MyMaterialType.WOOD; } else if (entity is IMyHandheldGunObject <MyGunBase> ) { surfaceImpact = MySurfaceImpactEnum.METAL; materialType = MyMaterialType.METAL; var mat = (entity as IMyHandheldGunObject <MyGunBase>).GunBase; if (mat != null && mat.WeaponProperties != null && mat.WeaponProperties.WeaponDefinition != null) { materialType = mat.WeaponProperties.WeaponDefinition.PhysicalMaterial; } } else { surfaceImpact = MySurfaceImpactEnum.METAL; materialType = MyMaterialType.METAL; if (entity is MyCubeGrid) { var grid = (entity as MyCubeGrid); if (grid != null) { var block = grid.GetTargetedBlock(hitPosition); if (block != null) { if (block.BlockDefinition.PhysicalMaterial != null && !block.BlockDefinition.PhysicalMaterial.Id.TypeId.IsNull) { materialType = MyStringHash.GetOrCompute(block.BlockDefinition.PhysicalMaterial.Id.SubtypeName); } else { if (block.FatBlock != null) { MyIntersectionResultLineTriangleEx?res = null; block.FatBlock.GetIntersectionWithLine(ref line, out res); if (res.HasValue) { var technique = block.FatBlock.ModelCollision.GetDrawTechnique(res.Value.Triangle.TriangleIndex); if (technique == VRageRender.Import.MyMeshDrawTechnique.GLASS) { materialType = MyStringHash.GetOrCompute("Glass"); } } } } } } } } System.Diagnostics.Debug.Assert(materialType.GetHashCode() != 0, "Unknown material"); }
private static void GetSurfaceAndMaterial(IMyEntity entity, ref Vector3D hitPosition, out MySurfaceImpactEnum surfaceImpact, out MyStringHash materialType) { var voxelBase = entity as MyVoxelBase; if (voxelBase != null) { materialType = MyMaterialType.ROCK; surfaceImpact = MySurfaceImpactEnum.DESTRUCTIBLE; var voxelDefinition = voxelBase.GetMaterialAt(ref hitPosition); if (voxelDefinition != null) { materialType = MyStringHash.GetOrCompute(voxelDefinition.MaterialTypeName); } } else if (entity is MyCharacter) { surfaceImpact = MySurfaceImpactEnum.CHARACTER; materialType = MyMaterialType.CHARACTER; if ((entity as MyCharacter).Definition.PhysicalMaterial != null) { materialType = MyStringHash.GetOrCompute((entity as MyCharacter).Definition.PhysicalMaterial); } } else if (entity is MyFloatingObject) { MyFloatingObject obj = entity as MyFloatingObject; materialType = (obj.VoxelMaterial != null) ? MyMaterialType.ROCK : (obj.ItemDefinition != null && obj.ItemDefinition.PhysicalMaterial != MyStringHash.NullOrEmpty ? obj.ItemDefinition.PhysicalMaterial : MyMaterialType.METAL); surfaceImpact = MySurfaceImpactEnum.METAL; } else if (entity is MyTrees) { surfaceImpact = MySurfaceImpactEnum.DESTRUCTIBLE; materialType = MyMaterialType.WOOD; } else if (entity is IMyHandheldGunObject <MyGunBase> ) { surfaceImpact = MySurfaceImpactEnum.METAL; materialType = MyMaterialType.METAL; var mat = (entity as IMyHandheldGunObject <MyGunBase>).GunBase; if (mat != null && mat.WeaponProperties != null && mat.WeaponProperties.WeaponDefinition != null) { materialType = mat.WeaponProperties.WeaponDefinition.PhysicalMaterial; } } else { surfaceImpact = MySurfaceImpactEnum.METAL; materialType = MyMaterialType.METAL; if (entity is MyCubeGrid) { var grid = (entity as MyCubeGrid); if (grid != null) { var block = grid.GetTargetedBlock(hitPosition); if (block != null) { if (block.BlockDefinition.PhysicalMaterial != null) { materialType = MyStringHash.GetOrCompute(block.BlockDefinition.PhysicalMaterial.Id.SubtypeName); } } } } } if (materialType.GetHashCode() == 0) { materialType = MyMaterialType.METAL; } }
public override int GetHashCode() { return(Hash.GetHashCode()); }
private static void GetSurfaceAndMaterial(IMyEntity entity, ref Vector3D hitPosition, out MySurfaceImpactEnum surfaceImpact, out MyStringHash materialType) { var voxelBase = entity as MyVoxelBase; if (voxelBase != null) { materialType = MyMaterialType.ROCK; surfaceImpact = MySurfaceImpactEnum.DESTRUCTIBLE; var voxelDefinition = voxelBase.GetMaterialAt(ref hitPosition); if (voxelDefinition != null) { materialType = MyStringHash.GetOrCompute(voxelDefinition.MaterialTypeName); } } else if (entity is MyCharacter) { surfaceImpact = MySurfaceImpactEnum.CHARACTER; materialType = MyMaterialType.CHARACTER; if ((entity as MyCharacter).Definition.PhysicalMaterial != null) { materialType = MyStringHash.GetOrCompute((entity as MyCharacter).Definition.PhysicalMaterial); } } else if (entity is MyFloatingObject) { MyFloatingObject obj = entity as MyFloatingObject; materialType = (obj.VoxelMaterial != null) ? MyMaterialType.ROCK : MyMaterialType.METAL; surfaceImpact = MySurfaceImpactEnum.METAL; } else if (entity is MyTrees) { surfaceImpact = MySurfaceImpactEnum.DESTRUCTIBLE; materialType = MyMaterialType.WOOD; } else { surfaceImpact = MySurfaceImpactEnum.METAL; materialType = MyMaterialType.METAL; if (entity is MyCubeGrid) { Vector3I blockPos; var grid = (entity as MyCubeGrid); if (grid != null) { grid.FixTargetCube(out blockPos, Vector3D.Transform(hitPosition, grid.PositionComp.WorldMatrixNormalizedInv) / grid.GridSize); var block = grid.GetCubeBlock(blockPos); if (block != null) { if (block.BlockDefinition.PhysicalMaterial != null) { materialType = MyStringHash.GetOrCompute(block.BlockDefinition.PhysicalMaterial.Id.SubtypeName); } } } } if (materialType.GetHashCode() == 0) { materialType = MyMaterialType.METAL; } } }