// This method returns all physics entities touching the given spherical // area. The method creates a sphere shape and calls its collide // method, so it's quite fast. Note that entities will be appended to the // array, so usually you should make sure to pass an empty array. This method // will also overwrite the internal Contacts array which can be // queried after the method has returned, but note that there will only // be one contact per physics shape. int CPhysicsServer::GetEntitiesInSphere(const vector3& Pos, float Radius, const CFilterSet& ExcludeSet, nArray<PEntity>& Result) { n_assert(Radius >= 0.0f); //???in shape constructor? matrix44 Tfm; Tfm.translate(Pos); return GetEntitiesInShape(CreateSphereShape(Tfm, InvalidMaterial, Radius), ExcludeSet, Result); }
// Object Creation Function Definitions std::vector<std::shared_ptr<Shape>> MakeShapes(const std::string &name, const Transform *object2world, const Transform *world2object, bool reverseOrientation, const ParamSet ¶mSet) { std::vector<std::shared_ptr<Shape>> shapes; std::shared_ptr<Shape> s; if (name == "sphere") s = CreateSphereShape(object2world, world2object, reverseOrientation, paramSet); // Create remaining single _Shape_ types else if (name == "cylinder") s = CreateCylinderShape(object2world, world2object, reverseOrientation, paramSet); else if (name == "disk") s = CreateDiskShape(object2world, world2object, reverseOrientation, paramSet); else if (name == "cone") s = CreateConeShape(object2world, world2object, reverseOrientation, paramSet); else if (name == "paraboloid") s = CreateParaboloidShape(object2world, world2object, reverseOrientation, paramSet); else if (name == "hyperboloid") s = CreateHyperboloidShape(object2world, world2object, reverseOrientation, paramSet); if (s != nullptr) shapes.push_back(s); // Create multiple-_Shape_ types else if (name == "curve") shapes = CreateCurveShape(object2world, world2object, reverseOrientation, paramSet); else if (name == "trianglemesh") shapes = CreateTriangleMeshShape(object2world, world2object, reverseOrientation, paramSet, &graphicsState.floatTextures); else if (name == "plymesh") shapes = CreatePLYMesh(object2world, world2object, reverseOrientation, paramSet, &graphicsState.floatTextures); else if (name == "heightfield") shapes = CreateHeightfield(object2world, world2object, reverseOrientation, paramSet); else if (name == "loopsubdiv") shapes = CreateLoopSubdiv(object2world, world2object, reverseOrientation, paramSet); else if (name == "nurbs") shapes = CreateNURBS(object2world, world2object, reverseOrientation, paramSet); else Warning("Shape \"%s\" unknown.", name.c_str()); paramSet.ReportUnused(); return shapes; }