public void SetPosition(Vector3 newpos, bool editPivot) { if (MultipleSelection) { //don't do anything here for multiselection } else if (EntityDef != null) { if (editPivot) { EntityDef.SetPivotPositionFromWidget(newpos); } else { EntityDef.SetPositionFromWidget(newpos); } } else if (CarGenerator != null) { CarGenerator.SetPosition(newpos); } else if (PathNode != null) { PathNode.SetPosition(newpos); } else if (CollisionPoly != null) { CollisionPoly.Position = newpos; } else if (CollisionBounds != null) { CollisionBounds.Position = newpos; } else if (NavPoly != null) { NavPoly.SetPosition(newpos); } else if (NavPoint != null) { NavPoint.SetPosition(newpos); } else if (NavPortal != null) { NavPortal.SetPosition(newpos); } else if (TrainTrackNode != null) { TrainTrackNode.SetPosition(newpos); } else if (ScenarioNode != null) { ScenarioNode.SetPosition(newpos); } else if (Audio != null) { Audio.SetPosition(newpos); } }
public void SetPosition(Vector3 newpos, bool editPivot) { if (MultipleSelection) { //don't do anything here for multiselection } else if (EntityDef != null) { if (editPivot) { EntityDef.SetPivotPositionFromWidget(newpos); } else { EntityDef.SetPositionFromWidget(newpos); } } else if (CarGenerator != null) { CarGenerator.SetPosition(newpos); } else if (PathNode != null) { PathNode.SetPosition(newpos); } else if (NavPoly != null) { NavPoly.SetPosition(newpos); //if (projectForm != null) //{ // projectForm.OnWorldNavPolyModified(NavPoly); //} } else if (NavPoint != null) { NavPoint.SetPosition(newpos); } else if (NavPortal != null) { NavPortal.SetPosition(newpos); } else if (TrainTrackNode != null) { TrainTrackNode.SetPosition(newpos); } else if (ScenarioNode != null) { ScenarioNode.SetPosition(newpos); } else if (Audio != null) { Audio.SetPosition(newpos); } }
/// <summary> /// Retrieve the endpoints of the offmesh connection at the specified polygon /// </summary> /// <param name="prevRef">The previous polygon reference</param> /// <param name="polyRef">The current polygon reference</param> /// <param name="startPos">The starting position</param> /// <param name="endPos">The ending position</param> /// <returns>True if endpoints found, false if not</returns> public bool GetOffMeshConnectionPolyEndPoints(NavPolyId prevRef, NavPolyId polyRef, ref Vector3 startPos, ref Vector3 endPos) { int salt = 0, indexTile = 0, indexPoly = 0; if (polyRef == NavPolyId.Null) { return(false); } //get current polygon idManager.Decode(ref polyRef, out indexPoly, out indexTile, out salt); if (indexTile >= maxTiles) { return(false); } if (tileList[indexTile].Salt != salt) { return(false); } NavTile tile = tileList[indexTile]; if (indexPoly >= tile.PolyCount) { return(false); } NavPoly poly = tile.Polys[indexPoly]; if (poly.PolyType != NavPolyType.OffMeshConnection) { return(false); } int idx0 = 0, idx1 = 1; //find the link that points to the first vertex foreach (Link link in poly.Links) { if (link.Edge == 0) { if (link.Reference != prevRef) { idx0 = 1; idx1 = 0; } break; } } startPos = tile.Verts[poly.Verts[idx0]]; endPos = tile.Verts[poly.Verts[idx1]]; return(true); }
/// <summary> /// Retrieve the tile and poly based off of a polygon reference /// </summary> /// <param name="reference">Polygon reference</param> /// <param name="tile">Resulting tile</param> /// <param name="poly">Resulting poly</param> /// <returns>True if tile and poly successfully retrieved</returns> public bool TryGetTileAndPolyByRef(NavPolyId reference, out NavTile tile, out NavPoly poly) { tile = null; poly = null; if (reference == NavPolyId.Null) { return(false); } //Get tile and poly indices int salt, polyIndex, tileIndex; idManager.Decode(ref reference, out polyIndex, out tileIndex, out salt); //Make sure indices are valid if (tileIndex >= maxTiles) { return(false); } NavTile foundTile; if (!tileIndices.TryGetValue(tileIndex, out foundTile)) { return(false); } if (foundTile.Salt != salt) { return(false); } if (polyIndex >= foundTile.PolyCount) { return(false); } //Retrieve tile and poly tile = tileIndices[tileIndex]; poly = tileIndices[tileIndex].Polys[polyIndex]; return(true); }
private NavTile DeserializeMeshTile(ref Stream stream, NavPolyIdManager manager, out NavPolyId baseRef) { NavTile tile; using (var binaryReader = new BinaryReader(stream)) { var id = binaryReader.ReadInt32(); baseRef = new NavPolyId(id); var x = binaryReader.ReadInt32(); var y = binaryReader.ReadInt32(); var location = new Vector2i(x, y); var layer = binaryReader.ReadInt32(); tile = new NavTile(location, layer, manager, baseRef); tile.Salt = binaryReader.ReadInt32(); var minX = binaryReader.ReadSingle(); var minY = binaryReader.ReadSingle(); var minZ = binaryReader.ReadSingle(); var maxX = binaryReader.ReadSingle(); var maxY = binaryReader.ReadSingle(); var maxZ = binaryReader.ReadSingle(); tile.Bounds = new BBox3(minX, minY, minZ, maxX, maxY, maxZ); var polysCount = binaryReader.ReadInt32(); var polys = new NavPoly[polysCount]; for (var i = 0; i < polysCount; i++) { var poly = new NavPoly(); poly.PolyType = (NavPolyType)binaryReader.ReadByte(); var polyLinksCount = binaryReader.ReadInt32(); for (var j = 0; j < polyLinksCount; j++) { var navPolyId = binaryReader.ReadInt32(); var link = new Link(); link.Reference = new NavPolyId(navPolyId); link.Edge = binaryReader.ReadInt32(); link.Side = (BoundarySide)binaryReader.ReadByte(); link.BMin = binaryReader.ReadInt32(); link.BMax = binaryReader.ReadInt32(); poly.Links.Add(link); } var polyVertsCount = binaryReader.ReadInt32(); poly.Verts = new int[polyVertsCount]; for (var j = 0; j < polyVertsCount; j++) { poly.Verts[j] = binaryReader.ReadInt32(); } var polyNeisCount = binaryReader.ReadInt32(); poly.Neis = new int[polyNeisCount]; for (var j = 0; j < polyNeisCount; j++) { poly.Neis[j] = binaryReader.ReadInt32(); } var polyTag = binaryReader.ReadByte(); if (polyTag == 0xFE) { poly.Tag = null; } else { poly.Tag = (OffMeshConnectionFlags)polyTag; } poly.VertCount = binaryReader.ReadInt32(); var areaId = binaryReader.ReadByte(); poly.Area = new Area(areaId); polys[i] = poly; } tile.Polys = polys; tile.PolyCount = polysCount; var vertsCount = binaryReader.ReadInt32(); var verts = new Vector3[vertsCount]; for (var i = 0; i < vertsCount; i++) { var vx = binaryReader.ReadSingle(); var vy = binaryReader.ReadSingle(); var vz = binaryReader.ReadSingle(); var vert = new Vector3(vx, vy, vz); verts[i] = vert; } tile.Verts = verts; var detailMeshesCount = binaryReader.ReadInt32(); var detailMeshes = new PolyMeshDetail.MeshData[detailMeshesCount]; for (var i = 0; i < detailMeshesCount; i++) { var detailMesh = new PolyMeshDetail.MeshData(); detailMesh.VertexIndex = binaryReader.ReadInt32(); detailMesh.VertexCount = binaryReader.ReadInt32(); detailMesh.TriangleIndex = binaryReader.ReadInt32(); detailMesh.TriangleCount = binaryReader.ReadInt32(); detailMeshes[i] = detailMesh; } tile.DetailMeshes = detailMeshes; var detailVertsCount = binaryReader.ReadInt32(); var detailVerts = new Vector3[detailVertsCount]; for (var i = 0; i < detailVertsCount; i++) { var vx = binaryReader.ReadSingle(); var vy = binaryReader.ReadSingle(); var vz = binaryReader.ReadSingle(); var detailVert = new Vector3(vx, vy, vz); detailVerts[i] = detailVert; } tile.DetailVerts = detailVerts; var detailTrisCount = binaryReader.ReadInt32(); var detailTris = new PolyMeshDetail.TriangleData[detailTrisCount]; for (var i = 0; i < detailTrisCount; i++) { var hash0 = binaryReader.ReadInt32(); var hash1 = binaryReader.ReadInt32(); var hash2 = binaryReader.ReadInt32(); var flags = binaryReader.ReadInt32(); var detailTri = new PolyMeshDetail.TriangleData(hash0, hash1, hash2, flags); detailTris[i] = detailTri; } tile.DetailTris = detailTris; var offMeshConnectionsCount = binaryReader.ReadInt32(); for (var i = 0; i < offMeshConnectionsCount; i++) { } var nodesCount = binaryReader.ReadInt32(); var nodes = new BVTree.Node[nodesCount]; for (var i = 0; i < nodesCount; i++) { var node = new BVTree.Node(); node.Bounds.Min.X = binaryReader.ReadInt32(); node.Bounds.Min.Y = binaryReader.ReadInt32(); node.Bounds.Min.Z = binaryReader.ReadInt32(); node.Bounds.Max.X = binaryReader.ReadInt32(); node.Bounds.Max.Y = binaryReader.ReadInt32(); node.Bounds.Max.Z = binaryReader.ReadInt32(); node.Index = binaryReader.ReadInt32(); nodes[i] = node; } tile.BVTree = new BVTree(nodes); tile.BvQuantFactor = binaryReader.ReadSingle(); tile.BvNodeCount = binaryReader.ReadInt32(); tile.WalkableClimb = binaryReader.ReadSingle(); } return(tile); }
/// <summary> /// Initializes a new instance of the <see cref="NavMeshBuilder" /> class. /// Add all the PolyMesh and PolyMeshDetail attributes to the Navigation Mesh. /// Then, add Off-Mesh connection support. /// </summary> /// <param name="polyMesh">The PolyMesh</param> /// <param name="polyMeshDetail">The PolyMeshDetail</param> /// <param name="offMeshCons">Offmesh connection data</param> /// <param name="settings">The settings used to build.</param> public NavMeshBuilder(PolyMesh polyMesh, PolyMeshDetail polyMeshDetail, OffMeshConnection[] offMeshCons, NavMeshGenerationSettings settings) { if (settings.VertsPerPoly > PathfindingCommon.VERTS_PER_POLYGON) { throw new InvalidOperationException("The number of vertices per polygon is above SharpNav's limit"); } if (polyMesh.VertCount == 0) { throw new InvalidOperationException("The provided PolyMesh has no vertices."); } if (polyMesh.PolyCount == 0) { throw new InvalidOperationException("The provided PolyMesh has not polys."); } int nvp = settings.VertsPerPoly; //classify off-mesh connection points BoundarySide[] offMeshSides = new BoundarySide[offMeshCons.Length * 2]; int storedOffMeshConCount = 0; int offMeshConLinkCount = 0; if (offMeshCons.Length > 0) { //find height bounds float hmin = float.MaxValue; float hmax = -float.MaxValue; if (polyMeshDetail != null) { for (int i = 0; i < polyMeshDetail.VertCount; i++) { float h = polyMeshDetail.Verts[i].Y; hmin = Math.Min(hmin, h); hmax = Math.Max(hmax, h); } } else { for (int i = 0; i < polyMesh.VertCount; i++) { PolyVertex iv = polyMesh.Verts[i]; float h = polyMesh.Bounds.Min.Y + iv.Y * settings.CellHeight; hmin = Math.Min(hmin, h); hmax = Math.Max(hmax, h); } } hmin -= settings.MaxClimb; hmax += settings.MaxClimb; BBox3 bounds = polyMesh.Bounds; bounds.Min.Y = hmin; bounds.Max.Y = hmax; for (int i = 0; i < offMeshCons.Length; i++) { Vector3 p0 = offMeshCons[i].Pos0; Vector3 p1 = offMeshCons[i].Pos1; offMeshSides[i * 2 + 0] = BoundarySideExtensions.FromPoint(p0, bounds); offMeshSides[i * 2 + 1] = BoundarySideExtensions.FromPoint(p1, bounds); //off-mesh start position isn't touching mesh if (offMeshSides[i * 2 + 0] == BoundarySide.Internal) { if (p0.Y < bounds.Min.Y || p0.Y > bounds.Max.Y) { offMeshSides[i * 2 + 0] = 0; } } //count number of links to allocate if (offMeshSides[i * 2 + 0] == BoundarySide.Internal) { offMeshConLinkCount++; } if (offMeshSides[i * 2 + 1] == BoundarySide.Internal) { offMeshConLinkCount++; } if (offMeshSides[i * 2 + 0] == BoundarySide.Internal) { storedOffMeshConCount++; } } } //off-mesh connections stored as polygons, adjust values int totPolyCount = polyMesh.PolyCount + storedOffMeshConCount; int totVertCount = polyMesh.VertCount + storedOffMeshConCount * 2; //find portal edges int edgeCount = 0; int portalCount = 0; for (int i = 0; i < polyMesh.PolyCount; i++) { PolyMesh.Polygon p = polyMesh.Polys[i]; for (int j = 0; j < nvp; j++) { if (p.Vertices[j] == PolyMesh.NullId) { break; } edgeCount++; if (PolyMesh.IsBoundaryEdge(p.NeighborEdges[j])) { int dir = p.NeighborEdges[j] % 16; if (dir != 15) { portalCount++; } } } } int maxLinkCount = edgeCount + portalCount * 2 + offMeshConLinkCount * 2; //find unique detail vertices int uniqueDetailVertCount = 0; int detailTriCount = 0; if (polyMeshDetail != null) { detailTriCount = polyMeshDetail.TrisCount; for (int i = 0; i < polyMesh.PolyCount; i++) { int numDetailVerts = polyMeshDetail.Meshes[i].VertexCount; int numPolyVerts = polyMesh.Polys[i].VertexCount; uniqueDetailVertCount += numDetailVerts - numPolyVerts; } } else { uniqueDetailVertCount = 0; detailTriCount = 0; for (int i = 0; i < polyMesh.PolyCount; i++) { int numPolyVerts = polyMesh.Polys[i].VertexCount; uniqueDetailVertCount += numPolyVerts - 2; } } //allocate data header = new PathfindingCommon.NavMeshInfo(); navVerts = new Vector3[totVertCount]; navPolys = new NavPoly[totPolyCount]; navDMeshes = new PolyMeshDetail.MeshData[polyMesh.PolyCount]; navDVerts = new Vector3[uniqueDetailVertCount]; navDTris = new PolyMeshDetail.TriangleData[detailTriCount]; offMeshConnections = new OffMeshConnection[storedOffMeshConCount]; //store header //HACK TiledNavMesh should figure out the X/Y/layer instead of the user maybe? header.X = 0; header.Y = 0; header.Layer = 0; header.PolyCount = totPolyCount; header.VertCount = totVertCount; header.MaxLinkCount = maxLinkCount; header.Bounds = polyMesh.Bounds; header.DetailMeshCount = polyMesh.PolyCount; header.DetailVertCount = uniqueDetailVertCount; header.DetailTriCount = detailTriCount; header.OffMeshBase = polyMesh.PolyCount; header.WalkableHeight = settings.AgentHeight; header.WalkableRadius = settings.AgentRadius; header.WalkableClimb = settings.MaxClimb; header.OffMeshConCount = storedOffMeshConCount; header.BvNodeCount = settings.BuildBoundingVolumeTree ? polyMesh.PolyCount * 2 : 0; header.BvQuantFactor = 1f / settings.CellSize; int offMeshVertsBase = polyMesh.VertCount; int offMeshPolyBase = polyMesh.PolyCount; //store vertices for (int i = 0; i < polyMesh.VertCount; i++) { PolyVertex iv = polyMesh.Verts[i]; navVerts[i].X = polyMesh.Bounds.Min.X + iv.X * settings.CellSize; navVerts[i].Y = polyMesh.Bounds.Min.Y + iv.Y * settings.CellHeight; navVerts[i].Z = polyMesh.Bounds.Min.Z + iv.Z * settings.CellSize; } //off-mesh link vertices int n = 0; for (int i = 0; i < offMeshCons.Length; i++) { //only store connections which start from this tile if (offMeshSides[i * 2 + 0] == BoundarySide.Internal) { navVerts[offMeshVertsBase + (n * 2 + 0)] = offMeshCons[i].Pos0; navVerts[offMeshVertsBase + (n * 2 + 1)] = offMeshCons[i].Pos1; n++; } } //store polygons for (int i = 0; i < polyMesh.PolyCount; i++) { navPolys[i] = new NavPoly(); navPolys[i].VertCount = 0; navPolys[i].Tag = polyMesh.Polys[i].Tag; navPolys[i].Area = polyMesh.Polys[i].Area; navPolys[i].PolyType = NavPolyType.Ground; navPolys[i].Verts = new int[nvp]; navPolys[i].Neis = new int[nvp]; for (int j = 0; j < nvp; j++) { if (polyMesh.Polys[i].Vertices[j] == PolyMesh.NullId) { break; } navPolys[i].Verts[j] = polyMesh.Polys[i].Vertices[j]; if (PolyMesh.IsBoundaryEdge(polyMesh.Polys[i].NeighborEdges[j])) { //border or portal edge int dir = polyMesh.Polys[i].NeighborEdges[j] % 16; if (dir == 0xf) //border { navPolys[i].Neis[j] = 0; } else if (dir == 0) //portal x- { navPolys[i].Neis[j] = Link.External | 4; } else if (dir == 1) //portal z+ { navPolys[i].Neis[j] = Link.External | 2; } else if (dir == 2) //portal x+ { navPolys[i].Neis[j] = Link.External | 0; } else if (dir == 3) //portal z- { navPolys[i].Neis[j] = Link.External | 6; } } else { //normal connection navPolys[i].Neis[j] = polyMesh.Polys[i].NeighborEdges[j] + 1; } navPolys[i].VertCount++; } } //off-mesh connection vertices n = 0; for (int i = 0; i < offMeshCons.Length; i++) { //only store connections which start from this tile if (offMeshSides[i * 2 + 0] == BoundarySide.Internal) { navPolys[offMeshPolyBase + n] = new NavPoly(); navPolys[offMeshPolyBase + n].VertCount = 2; navPolys[offMeshPolyBase + n].Verts = new int[nvp]; navPolys[offMeshPolyBase + n].Verts[0] = offMeshVertsBase + (n * 2 + 0); navPolys[offMeshPolyBase + n].Verts[1] = offMeshVertsBase + (n * 2 + 1); navPolys[offMeshPolyBase + n].Tag = offMeshCons[i].Flags; navPolys[offMeshPolyBase + n].Area = polyMesh.Polys[offMeshCons[i].Poly].Area; //HACK is this correct? navPolys[offMeshPolyBase + n].PolyType = NavPolyType.OffMeshConnection; n++; } } //store detail meshes and vertices if (polyMeshDetail != null) { int vbase = 0; List <Vector3> storedDetailVerts = new List <Vector3>(); for (int i = 0; i < polyMesh.PolyCount; i++) { int vb = polyMeshDetail.Meshes[i].VertexIndex; int numDetailVerts = polyMeshDetail.Meshes[i].VertexCount; int numPolyVerts = navPolys[i].VertCount; navDMeshes[i].VertexIndex = vbase; navDMeshes[i].VertexCount = numDetailVerts - numPolyVerts; navDMeshes[i].TriangleIndex = polyMeshDetail.Meshes[i].TriangleIndex; navDMeshes[i].TriangleCount = polyMeshDetail.Meshes[i].TriangleCount; //Copy detail vertices //first 'nv' verts are equal to nav poly verts //the rest are detail verts for (int j = 0; j < navDMeshes[i].VertexCount; j++) { storedDetailVerts.Add(polyMeshDetail.Verts[vb + numPolyVerts + j]); } vbase += numDetailVerts - numPolyVerts; } navDVerts = storedDetailVerts.ToArray(); //store triangles for (int j = 0; j < polyMeshDetail.TrisCount; j++) { navDTris[j] = polyMeshDetail.Tris[j]; } } else { //create dummy detail mesh by triangulating polys int tbase = 0; for (int i = 0; i < polyMesh.PolyCount; i++) { int numPolyVerts = navPolys[i].VertCount; navDMeshes[i].VertexIndex = 0; navDMeshes[i].VertexCount = 0; navDMeshes[i].TriangleIndex = tbase; navDMeshes[i].TriangleCount = numPolyVerts - 2; //triangulate polygon for (int j = 2; j < numPolyVerts; j++) { navDTris[tbase].VertexHash0 = 0; navDTris[tbase].VertexHash1 = j - 1; navDTris[tbase].VertexHash2 = j; //bit for each edge that belongs to the poly boundary navDTris[tbase].Flags = 1 << 2; if (j == 2) { navDTris[tbase].Flags |= 1 << 0; } if (j == numPolyVerts - 1) { navDTris[tbase].Flags |= 1 << 4; } tbase++; } } } //store and create BV tree if (settings.BuildBoundingVolumeTree) { //build tree navBvTree = new BVTree(polyMesh.Verts, polyMesh.Polys, nvp, settings.CellSize, settings.CellHeight); } //store off-mesh connections n = 0; for (int i = 0; i < offMeshConnections.Length; i++) { //only store connections which start from this tile if (offMeshSides[i * 2 + 0] == BoundarySide.Internal) { offMeshConnections [n] = new OffMeshConnection(); offMeshConnections[n].Poly = offMeshPolyBase + n; //copy connection end points offMeshConnections[n].Pos0 = offMeshCons[i].Pos0; offMeshConnections[n].Pos1 = offMeshCons[i].Pos1; offMeshConnections[n].Radius = offMeshCons[i].Radius; offMeshConnections[n].Flags = offMeshCons[i].Flags; offMeshConnections[n].Side = offMeshSides[i * 2 + 1]; offMeshConnections[n].Tag = offMeshCons[i].Tag; n++; } } }
public string GetFullNameString(string defval) { string name = defval; if (MultipleSelection) { name = "Multiple items"; } else if (EntityDef != null) { name = EntityDef._CEntityDef.archetypeName.ToString(); } else if (Archetype != null) { name = Archetype.Hash.ToString(); } else if (CollisionBounds != null) { name = CollisionBounds.GetName(); } if (Geometry != null) { name += " (" + GeometryIndex.ToString() + ")"; } if (TimeCycleModifier != null) { name = TimeCycleModifier.CTimeCycleModifier.name.ToString(); } if (BoxOccluder != null) { name = "BoxOccluder " + (BoxOccluder.Ymap?.Name ?? "") + ": " + BoxOccluder.Index.ToString(); } if (OccludeModel != null) { name = "OccludeModel " + (OccludeModel.Ymap?.Name ?? "") + ": " + OccludeModel.Index.ToString(); } if (CarGenerator != null) { name = CarGenerator.NameString(); } if (EntityExtension != null) { name += ": " + EntityExtension.Name; } if (ArchetypeExtension != null) { name += ": " + ArchetypeExtension.Name; } if (WaterQuad != null) { name = "WaterQuad " + WaterQuad.ToString(); } if (NavPoly != null) { name = "NavPoly " + NavPoly.ToString(); } if (NavPoint != null) { name = "NavPoint " + NavPoint.ToString(); } if (NavPortal != null) { name = "NavPortal " + NavPortal.ToString(); } if (PathNode != null) { name = "PathNode " + PathNode.AreaID.ToString() + "." + PathNode.NodeID.ToString();// + FloatUtil.GetVector3String(PathNode.Position); } if (TrainTrackNode != null) { name = "TrainTrackNode " + FloatUtil.GetVector3String(TrainTrackNode.Position); } if (ScenarioNode != null) { name = ScenarioNode.ToString(); } if (Audio != null) { name = Audio.ShortTypeName + " " + Audio.GetNameString();// + FloatUtil.GetVector3String(Audio.InnerPos); } if (MloRoomDef != null) { name = "MloRoomDef " + MloRoomDef.RoomName; } return(name); }
public void SetPosition(Vector3 newpos, bool editPivot) { if (MultipleSelectionItems != null) { if (editPivot) { } else { var dpos = newpos - MultipleSelectionCenter;// oldpos; if (dpos == Vector3.Zero) { return; //nothing moved.. (probably due to snap) } for (int i = 0; i < MultipleSelectionItems.Length; i++) { if (MultipleSelectionItems[i].CollisionPoly == null)//skip polys, they use gathered verts { var refpos = MultipleSelectionItems[i].WidgetPosition; MultipleSelectionItems[i].SetPosition(refpos + dpos, false); } } if (GatheredCollisionVerts != null) { for (int i = 0; i < GatheredCollisionVerts.Length; i++) { var refpos = GatheredCollisionVerts[i].Position; GatheredCollisionVerts[i].Position = refpos + dpos; } } MultipleSelectionCenter = newpos; } } else if (EntityDef != null) { if (editPivot) { EntityDef.SetPivotPositionFromWidget(newpos); } else { EntityDef.SetPositionFromWidget(newpos); } } else if (CarGenerator != null) { CarGenerator.SetPosition(newpos); } else if (PathNode != null) { PathNode.SetPosition(newpos); } else if (CollisionVertex != null) { CollisionVertex.Position = newpos; } else if (CollisionPoly != null) { CollisionPoly.Position = newpos; } else if (CollisionBounds != null) { CollisionBounds.Position = newpos; } else if (NavPoly != null) { NavPoly.SetPosition(newpos); } else if (NavPoint != null) { NavPoint.SetPosition(newpos); } else if (NavPortal != null) { NavPortal.SetPosition(newpos); } else if (TrainTrackNode != null) { TrainTrackNode.SetPosition(newpos); } else if (ScenarioNode != null) { ScenarioNode.SetPosition(newpos); } else if (Audio != null) { Audio.SetPosition(newpos); } }
public string GetNameString(string defval) { string name = defval; if (MultipleSelection) { name = "Multiple items"; } else if (EntityDef != null) { name = EntityDef.CEntityDef.archetypeName.ToString(); } else if (Archetype != null) { name = Archetype.Hash.ToString(); } else if (TimeCycleModifier != null) { name = TimeCycleModifier.CTimeCycleModifier.name.ToString(); } else if (CarGenerator != null) { name = CarGenerator.CCarGen.carModel.ToString(); } else if (DistantLodLights != null) { name = DistantLodLights.Ymap?.Name ?? ""; } else if (CollisionBounds != null) { name = CollisionBounds.GetName(); } if (EntityExtension != null) { name = EntityExtension.Name; } if (ArchetypeExtension != null) { name = ArchetypeExtension.Name; } if (WaterQuad != null) { name = "WaterQuad " + WaterQuad.ToString(); } if (NavPoly != null) { name = "NavPoly " + NavPoly.ToString(); } if (NavPoint != null) { name = "NavPoint " + NavPoint.ToString(); } if (NavPortal != null) { name = "NavPortal " + NavPortal.ToString(); } if (PathNode != null) { name = "PathNode " + PathNode.AreaID.ToString() + "." + PathNode.NodeID.ToString(); //+ FloatUtil.GetVector3String(PathNode.Position); } if (TrainTrackNode != null) { name = "TrainTrackNode " + FloatUtil.GetVector3String(TrainTrackNode.Position); } if (ScenarioNode != null) { name = ScenarioNode.ToString(); } if (Audio != null) { name = Audio.ShortTypeName + " " + Audio.GetNameString();// FloatUtil.GetVector3String(Audio.InnerPos); } if (MloRoomDef != null) { name = "MloRoomDef " + MloRoomDef.RoomName; } return(name); }
/// <summary> /// Only use this function if it is known that the provided polygon reference is valid. /// </summary> /// <param name="reference">Polygon reference</param> /// <param name="tile">Resulting tile</param> /// <param name="poly">Resulting poly</param> public void TryGetTileAndPolyByRefUnsafe(NavPolyId reference, out NavTile tile, out NavPoly poly) { int salt, polyIndex, tileIndex; idManager.Decode(ref reference, out polyIndex, out tileIndex, out salt); tile = tileIndices[tileIndex]; poly = tileIndices[tileIndex].Polys[polyIndex]; }