public Vector3 LocalToGlobal(Position pos, Vector3 point) { var cellOffset = pos.Frame.LocalToGlobal(point); var blockOffset = LandDefs.GetBlockOffset(ObjCellID, pos.ObjCellID); return(blockOffset + cellOffset); }
public Vector3 GetOffset(Position pos) { var blockOffset = LandDefs.GetBlockOffset(ObjCellID, pos.ObjCellID); var globalOffset = blockOffset + pos.Frame.Origin - Frame.Origin; return(globalOffset); }
public override TransitionState FindEnvCollisions(Transition transition) { var transitState = check_entry_restrictions(transition); if (transitState != TransitionState.OK) { return(transitState); } var path = transition.SpherePath; var blockOffset = LandDefs.GetBlockOffset(path.CheckPos.ObjCellID, ID); var localPoint = transition.SpherePath.GlobalLowPoint - blockOffset; Polygon walkable = null; if (!find_terrain_poly(localPoint, ref walkable)) { return(transitState); } var objInfo = transition.ObjectInfo; if (get_block_water_type() == LandDefs.WaterType.EntirelyWater && !objInfo.State.HasFlag(ObjectInfoState.IsViewer) && !objInfo.Object.State.HasFlag(PhysicsState.Missile)) { return(TransitionState.Collided); } var waterDepth = get_water_depth(localPoint); var checkPos = new Sphere(path.GlobalSphere[0]); checkPos.Center -= LandDefs.GetBlockOffset(path.CheckPos.ObjCellID, ID); var result = objInfo.ValidateWalkable(checkPos, walkable.Plane, WaterType != LandDefs.WaterType.NotWater, waterDepth, transition, ID); if (result != TransitionState.OK && PhysicsObj.IsPicking) { Picker.PickResult.Type = PickType.LandCell; Picker.PickResult.ObjCell = this; Picker.PickResult.HitPoly = walkable; } return(result); }
public Vector3 GetOffset(Position pos, Vector3 rotation) { var blockOffset = LandDefs.GetBlockOffset(ObjCellID, pos.ObjCellID); return(blockOffset + pos.LocalToGlobal(rotation) - Frame.Origin); }
public static ObjCell find_cell_list(Position position, int numSphere, List <Sphere> sphere, CellArray cellArray, ObjCell currCell, SpherePath path) { cellArray.NumCells = 0; cellArray.AddedOutside = false; var cell = GetVisible(position.ObjCellID); if ((position.ObjCellID & 0xFFFF) >= 0x100) { if (path != null) { path.HitsInteriorCell = true; } cellArray.add_cell(position.ObjCellID, cell); } else { LandCell.add_all_outside_cells(position, numSphere, sphere, cellArray); } if (cell != null && numSphere != 0) { foreach (var otherCell in cellArray.Cells) { if (otherCell != null) { otherCell.find_transit_cells(position, numSphere, sphere, cellArray, path); } } if (currCell != null) { foreach (var otherCell in cellArray.Cells) { var blockOffset = LandDefs.GetBlockOffset(position.ObjCellID, otherCell.ID); var localPoint = sphere[0].Center - blockOffset; if (otherCell.point_in_cell(localPoint) && (otherCell.ID & 0xFFFF) >= 0x100) { if (path != null) { path.HitsInteriorCell = true; } return(otherCell); } } } } if (!cellArray.LoadCells && (position.ObjCellID & 0xFFFF) >= 0x100) { foreach (var otherCell in cellArray.Cells) { if (cell.ID != otherCell.ID) { continue; } var found = false; foreach (var stab in cell.StabList) { if (otherCell.ID == stab) { found = true; break; } } if (!found) { cellArray.remove_cell(otherCell); } } } return(null); }
public static void find_cell_list(Position position, int numSphere, List <Sphere> sphere, CellArray cellArray, ref ObjCell currCell, SpherePath path) { cellArray.NumCells = 0; cellArray.AddedOutside = false; var visibleCell = GetVisible(position.ObjCellID); if ((position.ObjCellID & 0xFFFF) >= 0x100) { if (path != null) { path.HitsInteriorCell = true; } cellArray.add_cell(position.ObjCellID, visibleCell); } else { LandCell.add_all_outside_cells(position, numSphere, sphere, cellArray); } if (visibleCell != null && numSphere != 0) { for (var i = 0; i < cellArray.Cells.Count; i++) { var cell = cellArray.Cells.Values.ElementAt(i); if (cell == null) { continue; } cell.find_transit_cells(position, numSphere, sphere, cellArray, path); } //var checkCells = cellArray.Cells.Values.ToList(); //foreach (var cell in checkCells) //cell.find_transit_cells(position, numSphere, sphere, cellArray, path); if (currCell != null) { currCell = null; foreach (var cell in cellArray.Cells.Values) { if (cell == null) { continue; } var blockOffset = LandDefs.GetBlockOffset(position.ObjCellID, cell.ID); var localPoint = sphere[0].Center - blockOffset; if (cell.point_in_cell(localPoint)) { currCell = cell; if ((cell.ID & 0xFFFF) >= 0x100) { if (path != null) { path.HitsInteriorCell = true; } return; // break? } } } } } if (!cellArray.LoadCells && (position.ObjCellID & 0xFFFF) >= 0x100) { var cells = cellArray.Cells.Values.ToList(); foreach (var cell in cells) { if (cell == null) { continue; } if (visibleCell.ID == cell.ID) { continue; } var found = false; foreach (var stab in ((EnvCell)visibleCell).VisibleCells.Values) { if (stab == null) { continue; } if (cell.ID == stab.ID) { found = true; break; } } if (!found) { cellArray.remove_cell(cell); } } } }