// // RequestPath // // Request a new path be found. Returns FALSE if request is invalid. // Finder::RequestResult Finder::RequestPath ( U32 sx, U32 sz, U32 dx, U32 dz, U8 traction, UnitObj *unit, SearchType type, U32 flags, PointList *blockList ) { // Forget any current path ForgetPath(); // Is destination on the map if (!WorldCtrl::CellOnMap(sx, sz) || !WorldCtrl::CellOnMap(dx, dz)) { LOG_DIAG(("Request position is not on the map (%u, %u)->(%u,%u)", sx, sz, dx, dz)); return (RR_OFFMAP); } // Filter out requests to move to the same cell if (sx == dx && sz == dz) { return (RR_SAMECELL); } // Can this traction type move to this cell if (!CanMoveToCell(traction, dx, dz)) { U32 xNew, zNew; // Find the closest location we can move to if (FindClosestCell(traction, dx, dz, xNew, zNew, 15)) { // Use the new location dx = xNew; dz = zNew; } else // AStar will fail, so jump straight to trace if (type == ST_ASTAR) { type = ST_TRACE; } } // Create a new path path = new Path(sx, sz, dx, dz, traction, unit, type, flags, blockList); // Add to the system AddPath(path); // Success return (RR_SUBMITTED); }
void avtLocateCellQuery::Execute(vtkDataSet *ds, const int dom) { if (ds == NULL) { return; } if (!RayIntersectsDataSet(ds)) { return; } avtDataObjectInformation &info = GetInput()->GetInfo(); avtDataAttributes &dataAtts = info.GetAttributes(); int dim = dataAtts.GetSpatialDimension(); int topodim = dataAtts.GetTopologicalDimension(); double dist = minDist, isect[3] = { 0., 0., 0.}; int foundCell = -1; // Find the cell, intersection point, and distance along the ray. // if (ds->GetDataObjectType() != VTK_RECTILINEAR_GRID) { if (topodim == 1 && dim == 2) // Lines foundCell = FindClosestCell(ds, dist, isect); else foundCell = LocatorFindCell(ds, dist, isect); } else { foundCell = RGridFindCell(ds, dist, isect); } if ((foundCell != -1) && (dist < minDist)) { minDist = dist; pickAtts.SetPickPoint(isect); vtkDataArray *origCells = ds->GetCellData()->GetArray("avtOriginalCellNumbers"); bool canUseCells = dataAtts.CanUseOrigZones(); if (canUseCells && origCells) { int comp = origCells->GetNumberOfComponents() -1; foundElement = (int) origCells->GetComponent(foundCell, comp); } else if (canUseCells && dataAtts.GetContainsOriginalCells()) { debug5 << "PICK PROBLEM! Info says we should have original " << " cells but the array was not found in the dataset." << endl; } else if (info.GetValidity().GetZonesPreserved()) { if (dataAtts.GetContainsGhostZones() != AVT_CREATED_GHOSTS) { if (canUseCells) foundElement = foundCell; } else { pickAtts.SetHasMixedGhostTypes( vtkVisItUtility::ContainsMixedGhostZoneTypes(ds)); } } // // There is no need to 'fudge' the intersection point unless // avtLocateCellQuery will be using it to find the Zone number and // we are in 3D. // if (foundElement == -1 && dim == 3 && canUseCells) { vtkVisItUtility::GetCellCenter(ds->GetCell(foundCell), isect); } pickAtts.SetCellPoint(isect); foundDomain = dom; } // if cell was found }