private void CreateMountPoints() { ProfilerShort.Begin("FractureComponent.CreateMountPoints"); Debug.Assert(m_tmpChildren.Count == 0); if (MyFakes.FRACTURED_BLOCK_AABB_MOUNT_POINTS) { if (MountPoints == null) { MountPoints = new List <MyCubeBlockDefinition.MountPoint>(); } else { MountPoints.Clear(); } var blockDef = Block.BlockDefinition; var size = new Vector3(blockDef.Size); var bb = new BoundingBox(-size / 2, size / 2); var he = bb.HalfExtents; bb.Min += he; bb.Max += he; Shape.GetChildren(m_tmpChildren); if (m_tmpChildren.Count > 0) { foreach (var child in m_tmpChildren) { var shape = child.Shape; shape = AddMountForShape(shape, Matrix.Identity, ref bb, Block.CubeGrid.GridSize, MountPoints); } } else { AddMountForShape(Shape, Matrix.Identity, ref bb, Block.CubeGrid.GridSize, MountPoints); } m_tmpChildren.Clear(); } else { MountPoints = MyCubeBuilder.AutogenerateMountpoints(new HkShape[] { Shape.GetShape() }, Block.CubeGrid.GridSize); } ProfilerShort.End(); }
void onClick_Save(MyGuiControlButton sender) { foreach (var def in MyDefinitionManager.Static.GetAllDefinitions()) { MyCubeBlockDefinition cubeDef = def as MyCubeBlockDefinition; if (cubeDef != null) { if (!string.IsNullOrEmpty(cubeDef.Model)) { var model = VRage.Game.Models.MyModels.GetModel(cubeDef.Model); var newMountpoints = MyCubeBuilder.AutogenerateMountpoints(model, MyDefinitionManager.Static.GetCubeSize(cubeDef.CubeSize)); cubeDef.MountPoints = newMountpoints.ToArray(); } } } MyDefinitionManager.Static.Save("CubeBlocks_*.*"); }
private void CreateMountPoints() { ProfilerShort.Begin("FB.CreateMountPoints"); if (MyFakes.FRACTURED_BLOCK_AABB_MOUNT_POINTS) { MountPoints = new List <MyCubeBlockDefinition.MountPoint>(); var blockBB = BoundingBox.CreateInvalid(); for (int i = 0; i < OriginalBlocks.Count; i++) { var b = OriginalBlocks[i]; Matrix m; Orientations[i].GetMatrix(out m); var size = new Vector3(MyDefinitionManager.Static.GetCubeBlockDefinition(b).Size); var bb = new BoundingBox(-size / 2, size / 2); blockBB = blockBB.Include(bb.Transform(m)); } var he = blockBB.HalfExtents; blockBB.Min += he; blockBB.Max += he; Shape.GetChildren(m_children); foreach (var child in m_children) { var shape = child.Shape; shape = MyFractureComponentCubeBlock.AddMountForShape(shape, child.GetTransform(), ref blockBB, CubeGrid.GridSize, MountPoints); } if (m_children.Count == 0) { MyFractureComponentCubeBlock.AddMountForShape(Shape, Matrix.Identity, ref blockBB, CubeGrid.GridSize, MountPoints); } m_children.Clear(); } else { MountPoints = MyCubeBuilder.AutogenerateMountpoints(new HkShape[] { Shape.GetShape() }, CubeGrid.GridSize); } ProfilerShort.End(); }
private unsafe void CreateMountPoints() { if (!MyFakes.FRACTURED_BLOCK_AABB_MOUNT_POINTS) { HkShape[] shapes = new HkShape[] { this.Shape.GetShape() }; this.MountPoints = MyCubeBuilder.AutogenerateMountpoints(shapes, base.CubeGrid.GridSize); } else { this.MountPoints = new List <MyCubeBlockDefinition.MountPoint>(); BoundingBox blockBB = BoundingBox.CreateInvalid(); for (int i = 0; i < this.OriginalBlocks.Count; i++) { Matrix matrix; MyDefinitionId id = this.OriginalBlocks[i]; this.Orientations[i].GetMatrix(out matrix); Vector3 vector2 = new Vector3(MyDefinitionManager.Static.GetCubeBlockDefinition(id).Size); BoundingBox box2 = new BoundingBox(-vector2 / 2f, vector2 / 2f); blockBB = blockBB.Include(box2.Transform(matrix)); } Vector3 halfExtents = blockBB.HalfExtents; Vector3 *vectorPtr1 = (Vector3 *)ref blockBB.Min; vectorPtr1[0] += halfExtents; Vector3 *vectorPtr2 = (Vector3 *)ref blockBB.Max; vectorPtr2[0] += halfExtents; this.Shape.GetChildren(m_children); foreach (HkdShapeInstanceInfo info in m_children) { MyFractureComponentCubeBlock.AddMountForShape(info.Shape, info.GetTransform(), ref blockBB, base.CubeGrid.GridSize, this.MountPoints); } if (m_children.Count == 0) { MyFractureComponentCubeBlock.AddMountForShape(this.Shape, Matrix.Identity, ref blockBB, base.CubeGrid.GridSize, this.MountPoints); } m_children.Clear(); } }