本文整理汇总了C#中VRage.Voxels.MyCellCoord类的典型用法代码示例。如果您正苦于以下问题:C# MyCellCoord类的具体用法?C# MyCellCoord怎么用?C# MyCellCoord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyCellCoord类属于VRage.Voxels命名空间,在下文中一共展示了MyCellCoord类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateCell
public IMyClipmapCell CreateCell(MyClipmapScaleEnum scaleGroup, MyCellCoord cellCoord, ref MatrixD worldMatrix)
{
var cell = new MyClipmapCellProxy(cellCoord, ref worldMatrix, m_massiveCenter, m_massiveRadius, m_renderFlags);
cell.SetVisibility(false);
cell.ScaleGroup = scaleGroup;
return cell;
}
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:7,代码来源:MyClipmapHandler.cs
示例2: MarkBlockChanged
// Actually, this function marks even cubes around the block to make sure that any changes caused in their triangles
// will be reflected in the navigation mesh.
public void MarkBlockChanged(MySlimBlock block)
{
Vector3I min = block.Min - Vector3I.One;
Vector3I max = block.Max + Vector3I.One;
Vector3I pos = min;
for (var it = new Vector3I.RangeIterator(ref block.Min, ref block.Max); it.IsValid(); it.GetNext(out pos))
{
m_changedCubes.Add(pos);
}
Vector3I minCell = CubeToCell(ref min);
Vector3I maxCell = CubeToCell(ref max);
pos = minCell;
for (var it = new Vector3I.RangeIterator(ref minCell, ref maxCell); it.IsValid(); it.GetNext(out pos))
{
m_changedCells.Add(pos);
MyCellCoord cellCoord = new MyCellCoord(0, pos);
ulong packedCell = cellCoord.PackId64();
TryClearCell(packedCell);
}
}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:27,代码来源:MyGridHighLevelHelper.cs
示例3: MyRenderVoxelCell
public MyRenderVoxelCell(MyClipmapScaleEnum scaleGroup, MyCellCoord coord, ref MatrixD worldMatrix)
: base(0, "MyRenderVoxelCell", RenderFlags.Visible | RenderFlags.CastShadows, CullingOptions.VoxelMap)
{
m_scaleGroup = scaleGroup;
m_coord = coord;
m_worldMatrix = worldMatrix;
m_fakeVoxelMaterial.DrawTechnique = MyMeshDrawTechnique.VOXEL_MAP;
}
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:8,代码来源:MyRenderVoxelCell.cs
示例4: MyRenderVoxelCellBackground
public MyRenderVoxelCellBackground(MyCellCoord coord, ref MatrixD worldMatrix, Vector3D position, float atmoshpereRadius, float planetRadius, bool hasAtmosphere) :
base(MyClipmapScaleEnum.Massive, coord, ref worldMatrix)
{
m_atmosphereRadius = atmoshpereRadius;
m_planetRadius = planetRadius;
m_hasAtmosphere = hasAtmosphere;
m_position = position;
m_leftCornerPositionOffset = worldMatrix.Translation -position;
}
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:9,代码来源:MyRenderVoxelCellFar.cs
示例5: MyRenderVoxelCell
IMyClipmapCell IMyClipmapCellHandler.CreateCell(MyClipmapScaleEnum scaleGroup, MyCellCoord cellCoord, ref MatrixD worldMatrix)
{
switch (scaleGroup)
{
case MyClipmapScaleEnum.Normal:
return new MyRenderVoxelCell(scaleGroup, cellCoord, ref worldMatrix);
default:
throw new InvalidBranchException();
}
}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:11,代码来源:MyRenderClipmap.cs
示例6: MyClipmapCellProxy
internal MyClipmapCellProxy(MyCellCoord cellCoord, ref VRageMath.MatrixD worldMatrix, RenderFlags additionalFlags = 0)
{
m_worldMatrix = worldMatrix;
m_actor = MyActorFactory.CreateSceneObject();
m_actor.SetMatrix(ref worldMatrix);
m_actor.AddComponent(MyComponentFactory<MyFoliageComponent>.Create());
m_lod = cellCoord.Lod;
Mesh = MyMeshes.CreateVoxelCell(cellCoord.CoordInLod, cellCoord.Lod);
m_actor.GetRenderable().SetModel(Mesh);
m_actor.GetRenderable().m_additionalFlags = MyProxiesFactory.GetRenderableProxyFlags(additionalFlags);
}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:14,代码来源:MyClipmapCellProxy.cs
示例7: MyRenderVoxelCell
IMyClipmapCell IMyClipmapCellHandler.CreateCell(MyClipmapScaleEnum scaleGroup, MyCellCoord cellCoord, ref MatrixD worldMatrix)
{
switch (scaleGroup)
{
case MyClipmapScaleEnum.Normal:
return new MyRenderVoxelCell(scaleGroup, cellCoord, ref worldMatrix);
case MyClipmapScaleEnum.Massive:
return new MyRenderVoxelCellBackground(cellCoord, ref worldMatrix, m_position, m_atmosphereRadius, m_planetRadius, m_hasAtmosphere);
default:
throw new InvalidBranchException();
}
}
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:14,代码来源:MyRenderClipmap.cs
示例8: MyClipmapCellProxy
internal MyClipmapCellProxy(MyCellCoord cellCoord, ref VRageMath.Matrix worldMatrix)
{
m_worldMatrix = worldMatrix;
m_actor = MyActorFactory.CreateSceneObject();
//m_mesh = new MyVoxelMesh(cellCoord.CoordInLod, cellCoord.Lod, "");
//m_actor.GetRenderable().SetModel(m_mesh);
m_actor.SetMatrix(ref worldMatrix);
m_actor.AddComponent(MyComponentFactory<MyFoliageComponent>.Create());
m_lod = cellCoord.Lod;
Mesh = MyMeshes.CreateVoxelCell(cellCoord.CoordInLod, cellCoord.Lod);
m_actor.GetRenderable().SetModel(Mesh);
m_discardingOn = false;
}
开发者ID:notten,项目名称:SpaceEngineers,代码行数:17,代码来源:MyClipmapHandler.cs
示例9: InvalidateRange
internal void InvalidateRange(Vector3I lodMin, Vector3I lodMax)
{
var cell = new MyCellCoord(m_lodIndex, lodMin);
for (var it = new Vector3I.RangeIterator(ref lodMin, ref lodMax);
it.IsValid(); it.GetNext(out cell.CoordInLod))
{
CellData data;
var id = cell.PackId64();
using (m_storedCellDataLock.AcquireSharedUsing())
{
if (m_storedCellData.TryGetValue(id, out data))
{
data.State = CellState.Invalid;
}
}
}
}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:17,代码来源:MyClipmap.LodLevel.cs
示例10: OnTaskComplete
internal void OnTaskComplete(MyCellCoord coord, HkBvCompressedMeshShape childShape)
{
Debug.Assert(RigidBody != null, "RigidBody in voxel physics is null! This must not happen.");
if (RigidBody != null)
{
HkUniformGridShape shape = GetShape(coord.Lod);
Debug.Assert(shape.Base.IsValid);
shape.SetChild(coord.CoordInLod.X, coord.CoordInLod.Y, coord.CoordInLod.Z, childShape, HkReferencePolicy.None);
//BoundingBoxD worldAabb;
//MyVoxelCoordSystems.GeometryCellCoordToWorldAABB(m_voxelMap.PositionLeftBottomCorner, ref coord, out worldAabb);
//VRageRender.MyRenderProxy.DebugDrawAABB(worldAabb, Color.Green, 1f, 1f, true);
m_needsShapeUpdate = true;
}
}
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:14,代码来源:MyVoxelPhysicsBody.cs
示例11: RenderCellCoordToLocalPosition
public static void RenderCellCoordToLocalPosition(ref MyCellCoord renderCell, out Vector3D localPosition)
{
localPosition = renderCell.CoordInLod * RenderCellSizeInMeters(renderCell.Lod);
}
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:4,代码来源:MyVoxelCoordSystems.cs
示例12: RenderCellCoordToWorldAABB
public static void RenderCellCoordToWorldAABB(Vector3D referenceVoxelMapPosition, ref MyCellCoord renderCell, out BoundingBoxD worldAABB)
{
RenderCellCoordToLocalAABB(ref renderCell, out worldAABB);
worldAABB = worldAABB.Translate(referenceVoxelMapPosition);
}
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:5,代码来源:MyVoxelCoordSystems.cs
示例13: RenderCellCoordToLocalAABB
public static void RenderCellCoordToLocalAABB(ref MyCellCoord renderCell, out BoundingBoxD localAABB)
{
Vector3D localMinCorner;
RenderCellCoordToLocalPosition(ref renderCell, out localMinCorner);
localAABB = new BoundingBoxD(localMinCorner, localMinCorner + RenderCellSizeInMeters(renderCell.Lod));
}
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:6,代码来源:MyVoxelCoordSystems.cs
示例14: GetCell
internal CellData GetCell(ref MyCellCoord cell)
{
MyPrecalcComponent.AssertUpdateThread();
bool isEmpty;
CellData data;
if (TryGetCell(cell, out isEmpty, out data))
{
return data;
}
MyIsoMesh mesh;
if (!TryGetMesh(cell, out isEmpty, out mesh))
{
ProfilerShort.Begin("Cell precalc");
if (true)
{
var min = cell.CoordInLod << MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_VOXELS_BITS;
var max = min + MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_VOXELS;
// overlap to neighbor; introduces extra data but it makes logic for raycasts simpler (no need to check neighbor cells)
min -= 1;
max += 2;
mesh = MyPrecalcComponent.IsoMesher.Precalc(m_storage, 0, min, max, false, MyFakes.ENABLE_VOXEL_COMPUTED_OCCLUSION, true);
}
else
{
mesh = MyPrecalcComponent.IsoMesher.Precalc(new MyIsoMesherArgs()
{
Storage = m_storage,
GeometryCell = cell,
});
}
ProfilerShort.End();
}
if (mesh != null)
{
data = new CellData();
data.Init(
mesh.PositionOffset, mesh.PositionScale,
mesh.Positions.GetInternalArray(), mesh.VerticesCount,
mesh.Triangles.GetInternalArray(), mesh.TrianglesCount);
}
if (cell.Lod == 0)
{
using (m_lock.AcquireExclusiveUsing())
{
if (data != null)
{
var key = cell.PackId64();
m_cellsByCoordinate[key] = data;
}
else
{
SetEmpty(ref cell, true);
}
}
}
return data;
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:62,代码来源:MyVoxelGeometry.cs
示例15: storage_RangeChanged
/// <param name="minVoxelChanged">Inclusive min.</param>
/// <param name="maxVoxelChanged">Inclusive max.</param>
private void storage_RangeChanged(Vector3I minChanged, Vector3I maxChanged, MyStorageDataTypeFlags changedData)
{
MyPrecalcComponent.AssertUpdateThread();
ProfilerShort.Begin("MyVoxelGeometry.storage_RangeChanged");
minChanged -= MyPrecalcComponent.InvalidatedRangeInflate;
maxChanged += MyPrecalcComponent.InvalidatedRangeInflate;
m_storage.ClampVoxelCoord(ref minChanged);
m_storage.ClampVoxelCoord(ref maxChanged);
var minCellChanged = minChanged >> MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_VOXELS_BITS;
var maxCellChanged = maxChanged >> MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_VOXELS_BITS;
using (m_lock.AcquireExclusiveUsing())
{
if (minCellChanged == Vector3I.Zero && maxCellChanged == m_cellsCount - 1)
{
m_cellsByCoordinate.Clear();
m_coordinateToMesh.Clear();
m_isEmptyCache.Reset();
}
else
{
MyCellCoord cell = new MyCellCoord();
cell.CoordInLod = minCellChanged;
for (var it = new Vector3I_RangeIterator(ref minCellChanged, ref maxCellChanged); it.IsValid(); it.GetNext(out cell.CoordInLod))
{
var key = cell.PackId64();
m_cellsByCoordinate.Remove(key);
m_coordinateToMesh.Remove(key);
SetEmpty(ref cell, false);
}
}
}
ProfilerShort.End();
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:38,代码来源:MyVoxelGeometry.cs
示例16: GetClosestNavigationTriangle
private MyNavigationTriangle GetClosestNavigationTriangle(ref Vector3 point, ref float closestDistanceSq)
{
// TODO: When point is completely away (according to BB), return null
MyNavigationTriangle closestTriangle = null;
// Convert from world matrix local coords to LeftBottomCorner-based coords
Vector3 lbcPoint = point + (m_voxelMap.PositionComp.GetPosition() - m_voxelMap.PositionLeftBottomCorner);
Vector3I closestCellCorner = Vector3I.Round(lbcPoint / m_cellSize);
for (int i = 0; i < 8; ++i)
{
Vector3I cell = closestCellCorner + m_cornerOffsets[i];
if (!m_processedCells.Contains(cell)) continue;
MyCellCoord coord = new MyCellCoord(NAVMESH_LOD, cell);
ulong packedCoord = coord.PackId64();
MyIntervalList triList = m_higherLevelHelper.TryGetTriangleList(packedCoord);
if (triList == null) continue;
foreach (var triIndex in triList)
{
MyNavigationTriangle tri = GetTriangle(triIndex);
// TODO: Use triangle centers so far
float distSq = Vector3.DistanceSquared(tri.Center, point);
if (distSq < closestDistanceSq)
{
closestDistanceSq = distSq;
closestTriangle = tri;
}
}
}
return closestTriangle;
}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:36,代码来源:MyVoxelNavigationMesh.cs
示例17: GetClosestHighLevelPrimitive
private MyHighLevelPrimitive GetClosestHighLevelPrimitive(ref Vector3 point, ref float closestDistanceSq)
{
MyHighLevelPrimitive retval = null;
// Convert from world matrix local coords to LeftBottomCorner-based coords
Vector3 lbcPoint = point + (m_voxelMap.PositionComp.GetPosition() - m_voxelMap.PositionLeftBottomCorner);
m_tmpIntList.Clear();
// Collect components from the eight closest cells
Vector3I closestCellCorner = Vector3I.Round(lbcPoint / m_cellSize);
for (int i = 0; i < 8; ++i)
{
Vector3I cell = closestCellCorner + m_cornerOffsets[i];
MyCellCoord coord = new MyCellCoord(NAVMESH_LOD, cell);
ulong packedCoord = coord.PackId64();
m_higherLevelHelper.CollectComponents(packedCoord, m_tmpIntList);
}
foreach (int componentIndex in m_tmpIntList)
{
var hlPrimitive = m_higherLevel.GetPrimitive(componentIndex);
Debug.Assert(hlPrimitive != null, "Couldnt' find a high-level primitive for the index given by higher level helper!");
if (hlPrimitive == null) continue;
float distSq = Vector3.DistanceSquared(hlPrimitive.Position, point);
if (distSq < closestDistanceSq)
{
closestDistanceSq = distSq;
retval = hlPrimitive;
}
}
m_tmpIntList.Clear();
return retval;
}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:39,代码来源:MyVoxelNavigationMesh.cs
示例18: ComputeIsEmptyLookup
private void ComputeIsEmptyLookup(MyCellCoord cell, out ulong outCacheKey, out int outBit)
{
var offset = cell.CoordInLod % 4;
cell.CoordInLod >>= 2;
Debug.Assert(offset.IsInsideInclusive(Vector3I.Zero, new Vector3I(3)));
outCacheKey = cell.PackId64();
outBit = offset.X + 4 * (offset.Y + 4 * offset.Z);
Debug.Assert((uint)outBit < 64u);
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:9,代码来源:MyVoxelGeometry.cs
示例19: AddVoxelMesh
private void AddVoxelMesh(MyVoxelBase voxelBase, IMyStorage storage, Dictionary<Vector3I, MyIsoMesh> cache, float border, Vector3D originPosition, MyOrientedBoundingBoxD obb, List<BoundingBoxD> bbList)
{
bool useCache = cache != null;
if (useCache)
CheckCacheValidity();
obb.HalfExtent += new Vector3D(border, 0, border);
BoundingBoxD bb = obb.GetAABB();
int aabbSideSide = (int)Math.Round(bb.HalfExtents.Max() * 2);
bb = new BoundingBoxD(bb.Min, bb.Min + aabbSideSide);
bb.Translate(obb.Center - bb.Center);
// For debug
bbList.Add(new BoundingBoxD(bb.Min, bb.Max));
bb = (BoundingBoxD)bb.TransformFast(voxelBase.PositionComp.WorldMatrixInvScaled);
bb.Translate(voxelBase.SizeInMetresHalf);
Vector3I min = Vector3I.Round(bb.Min);
Vector3I max = min + aabbSideSide;
Vector3I geomMin, geomMax;
MyVoxelCoordSystems.VoxelCoordToGeometryCellCoord(ref min, out geomMin);
MyVoxelCoordSystems.VoxelCoordToGeometryCellCoord(ref max, out geomMax);
var cullBox = obb;
cullBox.Transform(voxelBase.PositionComp.WorldMatrixInvScaled);
cullBox.Center += voxelBase.SizeInMetresHalf;
ProfilerShort.Begin("WOOOORK");
Vector3I_RangeIterator it = new Vector3I_RangeIterator(ref geomMin, ref geomMax);
MyCellCoord coord = new MyCellCoord();
BoundingBox localAabb;
coord.Lod = NAVMESH_LOD;
int hits = 0;
MyIsoMesh gMesh;
Vector3 offset = originPosition - voxelBase.PositionLeftBottomCorner;
// Calculate rotation
Vector3 gravityVector = -Vector3.Normalize(GameSystems.MyGravityProviderSystem.CalculateTotalGravityInPoint(originPosition));
Vector3 forwardVector = Vector3.CalculatePerpendicularVector(gravityVector);
Quaternion quaternion = Quaternion.CreateFromForwardUp(forwardVector, gravityVector);
Matrix rotation = Matrix.CreateFromQuaternion(Quaternion.Inverse(quaternion));
Matrix ownRotation = voxelBase.PositionComp.WorldMatrix.GetOrientation();
while (it.IsValid())
{
ProfilerShort.Begin("ITERATOR");
if (useCache && cache.TryGetValue(it.Current, out gMesh))
{
if (gMesh != null)
{
AddMeshTriangles(gMesh, offset, rotation, ownRotation);
}
it.MoveNext();
ProfilerShort.End();
continue;
}
coord.CoordInLod = it.Current;
MyVoxelCoordSystems.GeometryCellCoordToLocalAABB(ref coord.CoordInLod, out localAabb);
if (!cullBox.Intersects(ref localAabb))
{
hits++;
it.MoveNext();
ProfilerShort.End();
continue;
}
ProfilerShort.End();
var debugBB = new BoundingBoxD(localAabb.Min, localAabb.Max).Translate(-voxelBase.SizeInMetresHalf);
bbList.Add(debugBB);
ProfilerShort.Begin("Mesh Calc");
var voxelStart = coord.CoordInLod * MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_VOXELS - 1;
var voxelEnd = voxelStart + MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_VOXELS //- 1
+ 1 // overlap to neighbor so geometry is stitched together within same LOD
+ 1; // for eg. 9 vertices in row we need 9 + 1 samples (voxels)
var generatedMesh = MyPrecalcComponent.IsoMesher.Precalc(storage, NAVMESH_LOD, voxelStart, voxelEnd, false, false, true);
ProfilerShort.End();
if (useCache)
cache[it.Current] = generatedMesh;
if (generatedMesh != null)
{
ProfilerShort.Begin("Mesh NOT NULL");
AddMeshTriangles(generatedMesh, offset, rotation, ownRotation);
ProfilerShort.End();
}
it.MoveNext();
}
ProfilerShort.End();
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:97,代码来源:MyNavigationInputMesh.cs
示例20: IsEmpty
private bool IsEmpty(ref MyCellCoord cell)
{
ulong cacheKey;
int bitIdx;
ComputeIsEmptyLookup(cell, out cacheKey, out bitIdx);
var cacheLine = m_isEmptyCache.Read(cacheKey);
return (cacheLine & ((ulong)1 << bitIdx)) != 0;
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:8,代码来源:MyVoxelGeometry.cs
注:本文中的VRage.Voxels.MyCellCoord类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论