protected bool UpdateClipboards() { if (ShipCreationIsActivated) { m_shipCreationClipboard.Update(); ShipCreationClipboard.CalculateRotationHints(m_rotationHints, m_rotationHintRotating); UpdateBlockInfoHud(); } else if (CopyPasteIsActivated) { Clipboard.CalculateRotationHints(m_rotationHints, m_rotationHintRotating); } else if (CopyPasteFloatingObjectIsActivated) { FloatingObjectClipboard.CalculateRotationHints(m_rotationHints, m_rotationHintRotating); } else if (MultiBlockCreationIsActivated) { m_multiBlockCreationClipboard.Update(); m_multiBlockCreationClipboard.CalculateRotationHints(m_rotationHints, false); } if (!BuildInputValid || MultiBlockCreationIsActivated || ShipCreationIsActivated || CopyPasteIsActivated || CopyPasteFloatingObjectIsActivated) { m_renderData.ClearInstanceData(); m_renderData.UpdateRenderInstanceData(); m_renderData.UpdateRenderEntitiesData(CurrentGrid != null ? CurrentGrid.WorldMatrix : MatrixD.Identity, UseTransparency); if (!ShipCreationIsActivated && !CopyPasteIsActivated && !MultiBlockCreationIsActivated) { m_rotationHints.Clear(); VRageRender.MyRenderProxy.RemoveBillboardViewProjection(0); } if (MyFakes.ENABLE_DEBUG_DRAW_TEXTURE_NAMES) { DebugDrawModelTextures(); } if (MyDebugDrawSettings.DEBUG_DRAW_VOXEL_NAMES) { DebugDrawVertexNames(); } if (MyFakes.ENABLE_DEBUG_DRAW_GENERATING_BLOCK) { DebugDrawGeneratingBlock(); } if (MultiBlockCreationIsActivated) { UpdateBlockInfoHud(); } return(true); } return(false); }
public override void Draw() { base.Draw(); //VRageRender.MyRenderProxy.DebugDrawAABB(m_cubeBuilderAABB, Vector3.One, 1, 1, false); if (BlockCreationIsActivated) { MyHud.Crosshair.Position = MyHudCrosshair.ScreenCenter; } if (IsActivated) { if (DynamicMode) { CurrentGrid = null; CurrentVoxelMap = null; } else { ChoosePlacementObject(); } } if (ShipCreationIsActivated) { m_shipCreationClipboard.Update(); ShipCreationClipboard.CalculateRotationHints(m_rotationHints, m_rotationHintRotating); } else if (CopyPasteIsActivated) { Clipboard.CalculateRotationHints(m_rotationHints, m_rotationHintRotating); } else if (CopyPasteFloatingObjectIsActivated) { FloatingObjectClipboard.CalculateRotationHints(m_rotationHints, m_rotationHintRotating); } else if (MultiBlockCreationIsActivated) { m_multiBlockCreationClipboard.CalculateRotationHints(m_rotationHints, false); } if (!BuildInputValid || MultiBlockCreationIsActivated || ShipCreationIsActivated || CopyPasteIsActivated || CopyPasteFloatingObjectIsActivated) { m_renderData.ClearInstanceData(); m_renderData.UpdateRenderInstanceData(); m_renderData.UpdateRenderEntitiesData(CurrentGrid != null ? CurrentGrid.WorldMatrix : MatrixD.Identity, UseTransparency); if (!ShipCreationIsActivated && !CopyPasteIsActivated && !MultiBlockCreationIsActivated) { m_rotationHints.Clear(); VRageRender.MyRenderProxy.RemoveBillboardViewProjection(0); } if (MyFakes.ENABLE_DEBUG_DRAW_TEXTURE_NAMES) { DebugDrawModelTextures(); } if (MultiBlockCreationIsActivated) { UpdateBlockInfoHud(); } return; } var startPosition = m_gizmo.SpaceDefault.m_startBuild ?? m_gizmo.SpaceDefault.m_startRemove; if (startPosition != null && m_gizmo.SpaceDefault.m_continueBuild != null) { Vector3I rotatedSize; Vector3I.TransformNormal(ref CurrentBlockDefinition.Size, ref m_gizmo.SpaceDefault.m_localMatrixAdd, out rotatedSize); rotatedSize = Vector3I.Abs(rotatedSize); int stepCount; Vector3I stepDelta; Vector3I counter; ComputeSteps(startPosition.Value, m_gizmo.SpaceDefault.m_continueBuild.Value, m_gizmo.SpaceDefault.m_startBuild.HasValue ? rotatedSize : Vector3I.One, out stepDelta, out counter, out stepCount); m_cubeCountStringBuilder.Clear(); m_cubeCountStringBuilder.Append(" "); m_cubeCountStringBuilder.AppendInt32(stepCount); MyGuiManager.DrawString(MyFontEnum.White, m_cubeCountStringBuilder, new Vector2(0.5f, 0.5f), 1.5f); } bool addPos = m_gizmo.SpaceDefault.m_startBuild.HasValue; bool removePos = false; if (DynamicMode) { Vector3D freePlacementIntersectionPoint = GetFreeSpacePlacementPosition(out m_gizmo.SpaceDefault.m_dynamicBuildAllowed); m_gizmo.SpaceDefault.m_worldMatrixAdd.Translation = freePlacementIntersectionPoint; addPos = true; } else { if (m_gizmo.SpaceDefault.m_startBuild == null && m_gizmo.SpaceDefault.m_startRemove == null) { if (!FreezeGizmo) { float gridSize = MyDefinitionManager.Static.GetCubeSize(CurrentBlockDefinition.CubeSize); addPos = GetAddAndRemovePositions(gridSize, PlacingSmallGridOnLargeStatic, out m_gizmo.SpaceDefault.m_addPos, out m_gizmo.SpaceDefault.m_addPosSmallOnLarge, out m_gizmo.SpaceDefault.m_addDir, out m_gizmo.SpaceDefault.m_removePos, out m_gizmo.SpaceDefault.m_removeBlock, out m_gizmo.SpaceDefault.m_blockIdInCompound); } if (addPos) { if (PlacingSmallGridOnLargeStatic) { m_gizmo.SpaceDefault.m_localMatrixAdd.Translation = m_gizmo.SpaceDefault.m_addPosSmallOnLarge.Value; } else { m_gizmo.SpaceDefault.m_localMatrixAdd.Translation = m_gizmo.SpaceDefault.m_addPos; } if (CurrentGrid != null) { m_gizmo.SpaceDefault.m_worldMatrixAdd = m_gizmo.SpaceDefault.m_localMatrixAdd * CurrentGrid.WorldMatrix; } else { m_gizmo.SpaceDefault.m_worldMatrixAdd = m_gizmo.SpaceDefault.m_localMatrixAdd; } Debug.Assert(!m_gizmo.SpaceDefault.m_worldMatrixAdd.IsNan(), "Invalid gizmo matrix"); if (m_gizmo.SpaceDefault.m_removeBlock != null) { removePos = true; } } } } bool buildingDisabledByCockpit = MySession.ControlledEntity != null && MySession.ControlledEntity is MyCockpit && !DeveloperSpectatorIsBuilding; //bool buildingDisabledByCockpit = true; if (!buildingDisabledByCockpit) { if (IsInSymmetrySettingMode) { m_gizmo.SpaceDefault.m_continueBuild = null; addPos = false; removePos = false; if (m_gizmo.SpaceDefault.m_removeBlock != null) { var min = (m_gizmo.SpaceDefault.m_removeBlock.Min * CurrentGrid.GridSize); var max = (m_gizmo.SpaceDefault.m_removeBlock.Max * CurrentGrid.GridSize); Vector3 center = (min + max) * 0.5f; Color color = DrawSymmetryPlane(m_symmetrySettingMode, CurrentGrid, center); DrawSemiTransparentBox(CurrentGrid, m_gizmo.SpaceDefault.m_removeBlock, color.ToVector4()); } } if (CurrentGrid != null && (UseSymmetry || IsInSymmetrySettingMode)) { if (CurrentGrid.XSymmetryPlane != null) { Vector3 center = CurrentGrid.XSymmetryPlane.Value * CurrentGrid.GridSize; DrawSymmetryPlane(CurrentGrid.XSymmetryOdd ? MySymmetrySettingModeEnum.XPlaneOdd : MySymmetrySettingModeEnum.XPlane, CurrentGrid, center); } if (CurrentGrid.YSymmetryPlane != null) { Vector3 center = CurrentGrid.YSymmetryPlane.Value * CurrentGrid.GridSize; DrawSymmetryPlane(CurrentGrid.YSymmetryOdd ? MySymmetrySettingModeEnum.YPlaneOdd : MySymmetrySettingModeEnum.YPlane, CurrentGrid, center); } if (CurrentGrid.ZSymmetryPlane != null) { Vector3 center = CurrentGrid.ZSymmetryPlane.Value * CurrentGrid.GridSize; DrawSymmetryPlane(CurrentGrid.ZSymmetryOdd ? MySymmetrySettingModeEnum.ZPlaneOdd : MySymmetrySettingModeEnum.ZPlane, CurrentGrid, center); } } } UpdateGizmos(addPos, removePos, true); m_renderData.UpdateRenderInstanceData(); if (DynamicMode || CurrentVoxelMap != null) { MatrixD drawMatrix = m_gizmo.SpaceDefault.m_worldMatrixAdd; Vector3D rotatedModelOffset; Vector3D.TransformNormal(ref CurrentBlockDefinition.ModelOffset, ref drawMatrix, out rotatedModelOffset); drawMatrix.Translation = drawMatrix.Translation + rotatedModelOffset; m_renderData.UpdateRenderEntitiesData(drawMatrix, UseTransparency); } else { m_renderData.UpdateRenderEntitiesData(CurrentGrid != null ? CurrentGrid.WorldMatrix : MatrixD.Identity, UseTransparency); } UpdateBlockInfoHud(); DebugDraw(); }
protected bool UpdateClipboards() { if (ShipCreationIsActivated) { m_shipCreationClipboard.Update(); ShipCreationClipboard.CalculateRotationHints(m_rotationHints, m_rotationHintRotating); UpdateBlockInfoHud(); } else if (CopyPasteIsActivated) { Clipboard.CalculateRotationHints(m_rotationHints, m_rotationHintRotating); } else if (CopyPasteFloatingObjectIsActivated) { FloatingObjectClipboard.CalculateRotationHints(m_rotationHints, m_rotationHintRotating); } else if (MultiBlockCreationIsActivated) { m_multiBlockCreationClipboard.Update(); m_multiBlockCreationClipboard.CalculateRotationHints(m_rotationHints, false); } //By Gregory: Ignore update in case we are on cockpit and build is disabled var shipController = MySession.Static.ControlledEntity as MyShipController; bool isInCockpitAndBuildFromCockpitDisabled = shipController != null ? !shipController.BuildingMode : false; if (!BuildInputValid || MultiBlockCreationIsActivated || ShipCreationIsActivated || CopyPasteIsActivated || CopyPasteFloatingObjectIsActivated || isInCockpitAndBuildFromCockpitDisabled) { m_renderData.ClearInstanceData(); m_renderData.UpdateRenderInstanceData(); m_renderData.UpdateRenderEntitiesData(CurrentGrid != null ? CurrentGrid.WorldMatrix : MatrixD.Identity, UseTransparency); if (!ShipCreationIsActivated && !CopyPasteIsActivated && !MultiBlockCreationIsActivated) { m_rotationHints.Clear(); VRageRender.MyRenderProxy.RemoveBillboardViewProjection(0); } if (MyFakes.ENABLE_DEBUG_DRAW_TEXTURE_NAMES) { DebugDrawModelTextures(); } if (MyDebugDrawSettings.DEBUG_DRAW_VOXEL_NAMES) { DebugDrawVertexNames(); } if (MyFakes.ENABLE_DEBUG_DRAW_GENERATING_BLOCK) { DebugDrawGeneratingBlock(); } if (MultiBlockCreationIsActivated) { UpdateBlockInfoHud(); } return(true); } return(false); }