本文整理汇总了C#中Sandbox.Game.Entities.Cube.MyGridPlacementSettings类的典型用法代码示例。如果您正苦于以下问题:C# MyGridPlacementSettings类的具体用法?C# MyGridPlacementSettings怎么用?C# MyGridPlacementSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyGridPlacementSettings类属于Sandbox.Game.Entities.Cube命名空间,在下文中一共展示了MyGridPlacementSettings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestPlacementAreaCube
/// <summary>
/// Test cube block placement area in grid.
/// </summary>
public static bool TestPlacementAreaCube(
MyCubeGrid targetGrid,
ref MyGridPlacementSettings settings,
Vector3I min,
Vector3I max,
MyBlockOrientation blockOrientation,
MyCubeBlockDefinition blockDefinition,
out MyCubeGrid touchingGrid,
MyEntity ignoredEntity = null,
bool ignoreFracturedPieces = false)
{
touchingGrid = null;
ProfilerShort.Begin("Math");
var worldMatrix = targetGrid != null ? targetGrid.WorldMatrix : MatrixD.Identity;
var gridSize = targetGrid != null ? targetGrid.GridSize : MyDefinitionManager.Static.GetCubeSize(MyCubeSize.Large);
Vector3 halfExtents = ((max - min) * gridSize + gridSize) / 2;
if (MyFakes.ENABLE_BLOCK_PLACING_IN_OCCUPIED_AREA)
halfExtents -= new Vector3D(GRID_PLACING_AREA_FIX_VALUE);
else
halfExtents -= new Vector3(0.03f, 0.03f, 0.03f); //allows touching blocks like wheels
var matrix = MatrixD.CreateTranslation((max + min) * 0.5f * gridSize) * worldMatrix;
var localAabb = BoundingBoxD.CreateInvalid();
localAabb.Include(min * gridSize - gridSize / 2);
localAabb.Include(max * gridSize + gridSize / 2);
Vector3D translation = matrix.Translation;
Quaternion rotation = Quaternion.CreateFromRotationMatrix(matrix);
ProfilerShort.BeginNextBlock("TestBlockPlacementArea");
bool result = TestBlockPlacementArea(targetGrid, ref settings, blockOrientation, blockDefinition, ref translation, ref rotation, ref halfExtents, ref localAabb, out touchingGrid, ignoredEntity: ignoredEntity,
ignoreFracturedPieces: ignoreFracturedPieces);
ProfilerShort.End();
return result;
}
示例2: TrySnapToSurface
protected bool TrySnapToSurface(MyGridPlacementSettings.SnapMode snapMode)
{
if (m_closestHitDistSq < float.MaxValue)
{
Vector3 newDragPointPosition = m_hitPos;
bool isAnyStatic = AnyCopiedGridIsStatic;
if (isAnyStatic)
{
m_pasteDirForward = Vector3.Forward;
m_pasteDirUp = Vector3.Up;
}
else if (m_hitNormal.Length() > 0.5)
{
if (snapMode == MyGridPlacementSettings.SnapMode.OneFreeAxis)
{
m_pasteDirUp = m_hitNormal;
float dotUp = m_pasteDirUp.Dot(m_hitEntity.WorldMatrix.Up);
float dotFwd = m_pasteDirUp.Dot(m_hitEntity.WorldMatrix.Forward);
float dotRt = m_pasteDirUp.Dot(m_hitEntity.WorldMatrix.Right);
if (Math.Abs(dotUp) > Math.Abs(dotFwd))
{
if (Math.Abs(dotUp) > Math.Abs(dotRt))
{
m_pasteDirForward = Vector3.Normalize(m_hitEntity.WorldMatrix.Right - (dotRt * m_pasteDirUp));
}
else
{
m_pasteDirForward = Vector3.Normalize(m_hitEntity.WorldMatrix.Forward - (dotFwd * m_pasteDirUp));
}
}
else
{
if (Math.Abs(dotFwd) > Math.Abs(dotRt))
{
m_pasteDirForward = Vector3.Normalize(m_hitEntity.WorldMatrix.Up - (dotUp * m_pasteDirUp));
}
else
{
m_pasteDirForward = Vector3.Normalize(m_hitEntity.WorldMatrix.Forward - (dotFwd * m_pasteDirUp));
}
}
}
else if (snapMode == MyGridPlacementSettings.SnapMode.Base6Directions)
{
var hitGrid = m_hitEntity as MyCubeGrid;
if (hitGrid != null)
{
Matrix hitGridRotation = hitGrid.WorldMatrix.GetOrientation();
Matrix firstRotation = GetFirstGridOrientationMatrix();
Matrix newFirstRotation = Matrix.AlignRotationToAxes(ref firstRotation, ref hitGridRotation);
Matrix rotationDelta = Matrix.Invert(firstRotation) * newFirstRotation;
m_pasteDirForward = newFirstRotation.Forward;
m_pasteDirUp = newFirstRotation.Up;
m_pasteOrientationAngle = 0.0f;
}
}
}
Matrix newOrientation = GetFirstGridOrientationMatrix();
Vector3 globalCenterDelta = Vector3.TransformNormal(m_dragPointToPositionLocal, newOrientation);
m_pastePosition = newDragPointPosition + globalCenterDelta;
if (MyDebugDrawSettings.DEBUG_DRAW_COPY_PASTE)
{
MyRenderProxy.DebugDrawSphere(newDragPointPosition, 0.08f, Color.Red.ToVector3(), 1.0f, false);
MyRenderProxy.DebugDrawSphere(m_pastePosition, 0.08f, Color.Red.ToVector3(), 1.0f, false);
}
IsSnapped = true;
return true;
}
IsSnapped = false;
return false;
}
示例3: TestPlacementAreaInternal
private static bool TestPlacementAreaInternal(MyCubeGrid targetGrid,
bool targetGridIsStatic,
ref MyGridPlacementSettings settings,
MyCubeBlockDefinition blockDefinition,
MyBlockOrientation? blockOrientation,
ref BoundingBoxD localAabb,
MyEntity ignoredEntity,
ref MatrixD worldMatrix,
out MyCubeGrid touchingGrid,
bool dynamicBuildMode = false,
bool ignoreFracturedPieces = false,
bool testVoxels = true)
{
ProfilerShort.Begin("TestPlacementAreaInternal");
touchingGrid = null;
float gridSize = targetGrid != null ? targetGrid.GridSize : (blockDefinition != null ? MyDefinitionManager.Static.GetCubeSize(blockDefinition.CubeSize) : MyDefinitionManager.Static.GetCubeSize(MyCubeSize.Large));
bool isStatic = targetGridIsStatic;
var worldAabb = localAabb.Transform(ref worldMatrix);
bool entityOverlap = false;
MyVoxelBase overlappedVoxelMap = null;
bool touchingStaticGrid = false;
foreach (var collison in m_physicsBoxQueryList)
{
var entity = collison.Body.GetEntity(0) as MyEntity;
if (entity == null)
continue;
if (ignoreFracturedPieces && (entity is MyFracturedPiece))
continue;
if (entity.GetPhysicsBody().WeldInfo.Children.Count == 0 && ignoredEntity != null && (entity == ignoredEntity || entity.GetTopMostParent() == ignoredEntity))
continue;
var body = entity.Physics;
if (body != null && body.IsPhantom)
continue;
var voxelMap = entity as MyVoxelBase;
if (voxelMap != null)
{
overlappedVoxelMap = voxelMap;
continue;
}
var grid = entity as MyCubeGrid;
if (grid == null)
{
var subPart = entity as MyEntitySubpart;
if (subPart != null)
{
grid = subPart.GetTopMostParent() as MyCubeGrid;
}
}
if(entity.GetPhysicsBody().WeldInfo.Children.Count > 0)
{
if(entity != ignoredEntity)
{
//Vector4 min,max;
//entity.Physics.GetShape().GetLocalAABB(0.05f, out min, out max);
//MyOrientedBoundingBoxD obb = new MyOrientedBoundingBoxD(new BoundingBoxD(new Vector3D(min.X, min.Y, min.Z), new Vector3D(max.X, max.Y, max.Z)), entity.WorldMatrix);
//MyRenderProxy.DebugDrawOBB(obb, Color.Green, 0.5f, false, false);
//obb = new MyOrientedBoundingBoxD(new BoundingBoxD(-m_lastQueryBox.HalfExtents, m_lastQueryBox.HalfExtents), m_lastQueryTransform);
//MyRenderProxy.DebugDrawOBB(obb, Color.Red, 0.5f, false, false);
if (TestQueryIntersection(entity.GetPhysicsBody().GetShape(), entity.WorldMatrix))
{
entityOverlap = true;
if(touchingGrid == null)
touchingGrid = entity as MyCubeGrid;
break;
}
}
foreach(var child in entity.GetPhysicsBody().WeldInfo.Children)
{
if(child.Entity == ignoredEntity)
continue;
if(TestQueryIntersection(child.WeldedRigidBody.GetShape(), child.Entity.WorldMatrix))
{
if (touchingGrid == null)
touchingGrid = child.Entity as MyCubeGrid;
entityOverlap = true;
break;
}
}
if (entityOverlap)
break;
continue;
}
if (grid != null && ((isStatic && grid.IsStatic)
|| (MyFakes.ENABLE_DYNAMIC_SMALL_GRID_MERGING && !isStatic && !grid.IsStatic && blockDefinition != null && blockDefinition.CubeSize == grid.GridSizeEnum)
|| (MyFakes.ENABLE_BLOCK_PLACEMENT_ON_VOXEL && isStatic && grid.IsStatic && blockDefinition != null && blockDefinition.CubeSize == grid.GridSizeEnum)))
{
// Small on large (or large on small) always possible
if (isStatic == grid.IsStatic && gridSize != grid.GridSize)
//.........这里部分代码省略.........
示例4: TestPlacementVoxelMapOverlap
public static bool TestPlacementVoxelMapOverlap(
MyVoxelBase voxelMap,
ref MyGridPlacementSettings settings,
ref BoundingBoxD localAabb,
ref MatrixD worldMatrix,
bool touchingStaticGrid = false)
{
ProfilerShort.Begin("TestPlacementVoxelMapOverlap");
var worldAabb = localAabb.Transform(ref worldMatrix);
const int IntersectsOrInside = 1;
const int Outside = 2;
int overlapState = Outside;
if (voxelMap == null)
voxelMap = MySession.Static.VoxelMaps.GetVoxelMapWhoseBoundingBoxIntersectsBox(ref worldAabb, null);
if (voxelMap != null && voxelMap.IsAnyAabbCornerInside(ref worldMatrix, localAabb))
{
overlapState = IntersectsOrInside;
}
bool testPassed = true;
switch (overlapState)
{
case IntersectsOrInside:
testPassed = settings.Penetration.MaxAllowed > 0;
break;
case Outside:
testPassed = settings.Penetration.MinAllowed <= 0 || (settings.CanAnchorToStaticGrid && touchingStaticGrid);
break;
default:
Debug.Fail("Invalid branch.");
break;
}
ProfilerShort.End();
return testPassed;
}
示例5: TestBlockPlacementArea
public static bool TestBlockPlacementArea(MyCubeBlockDefinition blockDefinition, MyBlockOrientation? blockOrientation, MatrixD worldMatrix, ref MyGridPlacementSettings settings, BoundingBoxD localAabb, bool dynamicBuildMode,
MyEntity ignoredEntity = null)
{
ProfilerShort.Begin("TestStart");
Vector3 halfExtents = localAabb.HalfExtents;
halfExtents += settings.SearchHalfExtentsDeltaAbsolute; //this works for SE
if (MyFakes.ENABLE_BLOCK_PLACING_IN_OCCUPIED_AREA)
halfExtents -= new Vector3D(GRID_PLACING_AREA_FIX_VALUE);
Vector3D translation = localAabb.Transform(ref worldMatrix).Center;
Quaternion quaternion = Quaternion.CreateFromRotationMatrix(worldMatrix);
quaternion.Normalize();
ProfilerShort.End();
ProfilerShort.Begin("Havok.GetPenetrationsBox");
Debug.Assert(m_physicsBoxQueryList.Count == 0, "List not cleared");
MyPhysics.GetPenetrationsBox(ref halfExtents, ref translation, ref quaternion, m_physicsBoxQueryList, MyPhysics.CollisionLayers.CharacterCollisionLayer);
m_lastQueryBox.HalfExtents = halfExtents;
m_lastQueryTransform = MatrixD.CreateFromQuaternion(quaternion);
m_lastQueryTransform.Translation = translation;
ProfilerShort.End();
MyCubeGrid touchingGrid;
return TestPlacementAreaInternal(null, ref settings, blockDefinition, blockOrientation, ref localAabb, ignoredEntity, ref worldMatrix, out touchingGrid, dynamicBuildMode: dynamicBuildMode);
}
示例6: TestPlacementAreaInternalWithEntities
private static bool TestPlacementAreaInternalWithEntities(MyCubeGrid targetGrid,
bool targetGridIsStatic,
ref MyGridPlacementSettings settings,
ref BoundingBoxD localAabb,
MyEntity ignoredEntity,
ref MatrixD worldMatrix,
bool dynamicBuildMode = false)
{
ProfilerShort.Begin("TestPlacementAreaInternalWithEntities");
MyCubeGrid touchingGrid = null;
float gridSize = targetGrid.GridSize;
bool isStatic = targetGridIsStatic;
var worldAabb = localAabb.Transform(ref worldMatrix);
bool entityOverlap = false;
MyVoxelBase overlappedVoxelMap = null;
bool touchingStaticGrid = false;
foreach (var entity in m_tmpResultList)
{
if (ignoredEntity != null && (entity == ignoredEntity || entity.GetTopMostParent() == ignoredEntity))
continue;
var body = entity.Physics;
if (body == null)
continue;
var voxelMap = entity as MyVoxelBase;
if (voxelMap != null)
{
overlappedVoxelMap = voxelMap;
continue;
}
var grid = entity as MyCubeGrid;
if (grid != null)
{
// Small on large (or large on small) always possible
if (isStatic == grid.IsStatic && gridSize != grid.GridSize)
continue;
TestGridPlacement(ref settings, ref worldMatrix, ref touchingGrid, gridSize, isStatic, ref localAabb, null, null, ref entityOverlap, ref touchingStaticGrid, grid);
if (entityOverlap)
{
break;
}
}
else
{
var character = entity as MyCharacter;
if (character != null && character.PositionComp.WorldAABB.Intersects(targetGrid.PositionComp.WorldAABB))
{
entityOverlap = true;
break;
}
}
}
m_tmpResultList.Clear();
ProfilerShort.End();
if (entityOverlap)
return false;
if (targetGrid.IsStatic)
{
return true;
}
ProfilerShort.Begin("TestVoxelOverlap");
bool result = TestVoxelOverlap(ref settings, ref localAabb, ref worldMatrix, ref worldAabb, ref overlappedVoxelMap, touchingStaticGrid);
ProfilerShort.End();
return result;
}
示例7: TestBlockPlacementOnGrid
protected static bool TestBlockPlacementOnGrid(MySlimBlock block, ref MatrixI transform, ref MyGridPlacementSettings settings, MyCubeGrid hitGrid)
{
Vector3I positionMin;
Vector3I.Transform(ref block.Min, ref transform, out positionMin);
Vector3I positionMax;
Vector3I.Transform(ref block.Max, ref transform, out positionMax);
Vector3I min = Vector3I.Min(positionMin, positionMax);
Vector3I max = Vector3I.Max(positionMin, positionMax);
Vector3I forward = Base6Directions.GetIntVector(transform.GetDirection(block.Orientation.Forward));
Vector3I up = Base6Directions.GetIntVector(transform.GetDirection(block.Orientation.Up));
MyBlockOrientation blockOrientation = new MyBlockOrientation(Base6Directions.GetDirection(forward), Base6Directions.GetDirection(up));
if (!hitGrid.CanAddCubes(min, max, blockOrientation, block.BlockDefinition))
return false;
return MyCubeGrid.TestPlacementAreaCube(hitGrid, ref settings, min, max, blockOrientation, block.BlockDefinition, ignoredEntity: hitGrid);
}
示例8: TestBlockPlacement
protected static bool TestBlockPlacement(MySlimBlock block, ref MyGridPlacementSettings settings)
{
return MyCubeGrid.TestPlacementAreaCube(block.CubeGrid, ref settings, block.Min, block.Max, block.Orientation, block.BlockDefinition, ignoredEntity: block.CubeGrid);
}
示例9: TestGridPlacementOnGrid
protected bool TestGridPlacementOnGrid(MyCubeGrid previewGrid, ref MyGridPlacementSettings settings, MyCubeGrid hitGrid)
{
bool retval = true;
Vector3I gridOffset = hitGrid.WorldToGridInteger(m_pastePosition);
MatrixI transform = hitGrid.CalculateMergeTransform(previewGrid, gridOffset);
if (MyDebugDrawSettings.DEBUG_DRAW_COPY_PASTE)
MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, 60.0f), "First grid offset: " + gridOffset.ToString(), Color.Red, 1.0f);
retval = retval && hitGrid.GridSizeEnum == previewGrid.GridSizeEnum && hitGrid.CanMergeCubes(previewGrid, gridOffset);
retval = retval && MyCubeGrid.CheckMergeConnectivity(hitGrid, previewGrid, gridOffset);
// Check if any block connects to hit grid
if (retval)
{
bool connected = false;
foreach (var block in previewGrid.CubeBlocks)
{
if (block.FatBlock is MyCompoundCubeBlock)
{
MyCompoundCubeBlock compoundBlock = block.FatBlock as MyCompoundCubeBlock;
foreach (var blockInCompound in compoundBlock.GetBlocks())
{
connected |= CheckConnectivityOnGrid(blockInCompound, ref transform, ref settings, hitGrid);
if (connected)
break;
}
}
else
{
connected |= CheckConnectivityOnGrid(block, ref transform, ref settings, hitGrid);
}
if (connected)
break;
}
retval &= connected;
}
if (retval)
{
foreach (var block in previewGrid.CubeBlocks)
{
if (block.FatBlock is MyCompoundCubeBlock)
{
MyCompoundCubeBlock compoundBlock = block.FatBlock as MyCompoundCubeBlock;
foreach (var blockInCompound in compoundBlock.GetBlocks())
{
retval = retval && TestBlockPlacementOnGrid(blockInCompound, ref transform, ref settings, hitGrid);
if (!retval)
break;
}
}
else
{
retval = retval && TestBlockPlacementOnGrid(block, ref transform, ref settings, hitGrid);
}
if (!retval)
break;
}
}
return retval;
}
示例10: CheckConnectivityOnGrid
protected static bool CheckConnectivityOnGrid(MySlimBlock block, ref MatrixI transform, ref MyGridPlacementSettings settings, MyCubeGrid hitGrid)
{
Vector3I position;
Vector3I.Transform(ref block.Position, ref transform, out position);
Vector3I forward = Base6Directions.GetIntVector(transform.GetDirection(block.Orientation.Forward));
Vector3I up = Base6Directions.GetIntVector(transform.GetDirection(block.Orientation.Up));
MyBlockOrientation blockOrientation = new MyBlockOrientation(Base6Directions.GetDirection(forward), Base6Directions.GetDirection(up));
Quaternion rotation;
blockOrientation.GetQuaternion(out rotation);
var blockDefinition = block.BlockDefinition;
return MyCubeGrid.CheckConnectivity(hitGrid, blockDefinition, blockDefinition.GetBuildProgressModelMountPoints(block.BuildLevelRatio), ref rotation, ref position);
}
示例11: TestBlockPlacementArea
public static bool TestBlockPlacementArea(
MyCubeGrid targetGrid,
ref MyGridPlacementSettings settings,
MyBlockOrientation blockOrientation,
MyCubeBlockDefinition blockDefinition,
ref Vector3D translation,
ref Quaternion rotation,
ref Vector3 halfExtents,
ref BoundingBoxD localAabb,
out MyCubeGrid touchingGrid,
MyEntity ignoredEntity = null)
{
touchingGrid = null;
if (blockDefinition != null && blockDefinition.UseModelIntersection)
{
var model = MyModels.GetModelOnlyData(blockDefinition.Model);
if(model != null)
model.CheckLoadingErrors(blockDefinition.Context);
if (model != null && model.HavokCollisionShapes != null)
{
int shapeCount = model.HavokCollisionShapes.Length;
HkShape[] shapes = new HkShape[shapeCount];
for (int q = 0; q < shapeCount; ++q)
{
shapes[q] = model.HavokCollisionShapes[q];
}
var shape = new HkListShape(shapes, shapeCount, HkReferencePolicy.None);
Quaternion q2 = Quaternion.CreateFromForwardUp(Base6Directions.GetVector(blockOrientation.Forward), Base6Directions.GetVector(blockOrientation.Up));
rotation = rotation * q2;
MyPhysics.GetPenetrationsShape(shape, ref translation, ref rotation, m_physicsBoxQueryList, MyPhysics.CharacterCollisionLayer);
shape.Base.RemoveReference();
}
else
{
Debug.Assert(m_physicsBoxQueryList.Count == 0, "List not cleared");
MyPhysics.GetPenetrationsBox(ref halfExtents, ref translation, ref rotation, m_physicsBoxQueryList, MyPhysics.CharacterCollisionLayer);
}
}
else
{
Debug.Assert(m_physicsBoxQueryList.Count == 0, "List not cleared");
MyPhysics.GetPenetrationsBox(ref halfExtents, ref translation, ref rotation, m_physicsBoxQueryList, MyPhysics.CharacterCollisionLayer);
}
m_lastQueryBox.HalfExtents = halfExtents;
m_lastQueryTransform = MatrixD.CreateFromQuaternion(rotation);
m_lastQueryTransform.Translation = translation;
var worldMatrix = targetGrid != null ? targetGrid.WorldMatrix : MatrixD.Identity;
return TestPlacementAreaInternal(targetGrid, ref settings, blockDefinition, blockOrientation, ref localAabb, ignoredEntity, ref worldMatrix, out touchingGrid);
}
示例12: TestBlockPlacementOnGrid
protected static bool TestBlockPlacementOnGrid(MySlimBlock block, ref MatrixI transform, ref MyGridPlacementSettings settings, MyCubeGrid hitGrid)
{
Vector3I positionMin;
Vector3I.Transform(ref block.Min, ref transform, out positionMin);
Vector3I positionMax;
Vector3I.Transform(ref block.Max, ref transform, out positionMax);
Vector3I min = Vector3I.Min(positionMin, positionMax);
Vector3I max = Vector3I.Max(positionMin, positionMax);
var forward = transform.GetDirection(block.Orientation.Forward);
var up = transform.GetDirection(block.Orientation.Up);
MyBlockOrientation blockOrientation = new MyBlockOrientation(forward, up);
return hitGrid.CanPlaceBlock(min, max, blockOrientation, block.BlockDefinition, ref settings);
}
示例13: TestPlacementAreaInternal
private static bool TestPlacementAreaInternal(MyCubeGrid targetGrid,
bool targetGridIsStatic,
ref MyGridPlacementSettings settings,
MyCubeBlockDefinition blockDefinition,
MyBlockOrientation? blockOrientation,
ref BoundingBoxD localAabb,
MyEntity ignoredEntity,
ref MatrixD worldMatrix,
out MyCubeGrid touchingGrid,
bool dynamicBuildMode = false)
{
ProfilerShort.Begin("TestPlacementAreaInternal");
touchingGrid = null;
float gridSize = targetGrid != null ? targetGrid.GridSize : (blockDefinition != null ? MyDefinitionManager.Static.GetCubeSize(blockDefinition.CubeSize) : MyDefinitionManager.Static.GetCubeSize(MyCubeSize.Large));
bool isStatic = targetGridIsStatic;
var worldAabb = localAabb.Transform(ref worldMatrix);
bool entityOverlap = false;
MyVoxelBase overlappedVoxelMap = null;
bool touchingStaticGrid = false;
foreach (var rigidBody in m_physicsBoxQueryList)
{
var entity = rigidBody.GetEntity();
if (entity == null)
continue;
if (ignoredEntity != null && (entity == ignoredEntity || entity.GetTopMostParent() == ignoredEntity))
continue;
var body = rigidBody.GetBody();
if (body != null && body.IsPhantom)
continue;
var voxelMap = entity as MyVoxelBase;
if (voxelMap != null)
{
overlappedVoxelMap = voxelMap;
continue;
}
var grid = entity as MyCubeGrid;
if (grid != null && ((isStatic && grid.IsStatic)
|| (MyFakes.ENABLE_DYNAMIC_SMALL_GRID_MERGING && !isStatic && !grid.IsStatic && blockDefinition != null && blockDefinition.CubeSize == grid.GridSizeEnum)
|| (MyFakes.ENABLE_BLOCK_PLACEMENT_ON_VOXEL && isStatic && grid.IsStatic && blockDefinition != null && blockDefinition.CubeSize == grid.GridSizeEnum)))
{
// Small on large (or large on small) always possible
if (isStatic == grid.IsStatic && gridSize != grid.GridSize)
continue;
TestGridPlacement(ref settings, ref worldMatrix, ref touchingGrid, gridSize, isStatic, ref worldAabb, blockDefinition, blockOrientation, ref entityOverlap, ref touchingStaticGrid, grid);
if (entityOverlap)
{
break;
}
continue;
}
entityOverlap = true;
break;
}
m_tmpResultList.Clear();
m_physicsBoxQueryList.Clear();
ProfilerShort.End();
if (entityOverlap)
return false;
return TestVoxelOverlap(ref settings, ref localAabb, ref worldMatrix, ref worldAabb, ref overlappedVoxelMap, touchingStaticGrid);
}
示例14: TestPlacementAreaCubeNoAABBInflate
public static bool TestPlacementAreaCubeNoAABBInflate(
MyCubeGrid targetGrid,
ref MyGridPlacementSettings settings,
Vector3I min,
Vector3I max,
MyBlockOrientation blockOrientation,
MyCubeBlockDefinition blockDefinition,
out MyCubeGrid touchingGrid,
MyEntity ignoredEntity = null)
{
touchingGrid = null;
var worldMatrix = targetGrid != null ? targetGrid.WorldMatrix : MatrixD.Identity;
var gridSize = targetGrid != null ? targetGrid.GridSize : MyDefinitionManager.Static.GetCubeSize(MyCubeSize.Large);
Vector3 halfExtents = ((max - min) * gridSize + gridSize) / 2;
var matrix = MatrixD.CreateTranslation((max + min) * 0.5f * gridSize) * worldMatrix;
var localAabb = BoundingBoxD.CreateInvalid();
localAabb.Include(min * gridSize - gridSize / 2);
localAabb.Include(max * gridSize + gridSize / 2);
Vector3D translation = matrix.Translation;
Quaternion rotation = Quaternion.CreateFromRotationMatrix(matrix);
return TestBlockPlacementArea(targetGrid, ref settings, blockOrientation, blockDefinition, ref translation, ref rotation, ref halfExtents, ref localAabb, out touchingGrid, ignoredEntity);
}
示例15: TestBlockPlacementNoAABBInflate
protected static bool TestBlockPlacementNoAABBInflate(MySlimBlock block, ref MyGridPlacementSettings settings, out MyCubeGrid touchingGrid)
{
return MyCubeGrid.TestPlacementAreaCubeNoAABBInflate(block.CubeGrid, ref settings, block.Min, block.Max, block.Orientation, block.BlockDefinition, out touchingGrid, ignoredEntity: block.CubeGrid);
}