AIBase.cxx AIManager.cxx AIManager.hxx: Remove dead code.
No ground intersection on AI models. Note that the carrier still
reenables that nodemask.
#include <simgear/misc/sg_path.hxx>
#include <simgear/scene/model/location.hxx>
#include <simgear/scene/model/model.hxx>
+#include <simgear/scene/util/SGNodeMasks.hxx>
#include <simgear/debug/logstream.hxx>
#include <simgear/props/props.hxx>
SGPropertyNode *prop_root,
double sim_time_sec)
{
- // some more code here to check whether a model with this name has already been loaded
- // if not load it, otherwise, get the memory pointer and do something like
- // SetModel as in ATC/AIEntity.cxx
- osg::Group* personality_branch = new osg::Group;
-
- //model = manager->getModel(path);
- //if (!(model)) {
- model = sgLoad3DModel(fg_root,
- path,
- prop_root,
- sim_time_sec);
- // manager->setModel(path, model.get());
- //}
- personality_branch->addChild( model.get() );
-
- return personality_branch;
- //return model;
+ model = sgLoad3DModel(fg_root, path, prop_root, sim_time_sec);
+ model->setNodeMask(model->getNodeMask() & ~SG_NODEMASK_TERRAIN_BIT);
+ return model.get();
}
bool FGAIBase::isa( object_type otype ) {
}
}
-// This code keeps track of models that have already been loaded
-// Eventually we'd prbably need to find a way to keep track of models
-// that are unloaded again
-osg::Node* FGAIManager::getModel(const string& path)
-{
- ModelVecIterator i = loadedModels.begin();
- //cerr << "Reference count summary " << endl;
- int count = 0;
- while (i != loadedModels.end())
- {
- count += i->getNumRefs() -1;
- //cerr << "Model " << i->getPath() << " has reference count of " << i->getNumRefs() << " ";
- if (i->getNumRefs() == 1)
- {
- i = loadedModels.erase(i);
- //cerr << "[ Deleted ]" << endl;
- }
- else
- {
- i++;
- //cerr << endl;
- }
- }
- //cerr << "Reference summary end : " << count << "models allocated" << endl;
- i = loadedModels.begin();
-
- while (i != loadedModels.end())
- {
- if (i->getPath() == path)
- return i->getModelId();
- i++;
- }
- return 0;
-}
-
-void FGAIManager::setModel(const string& path, osg::Node *model)
-{
- loadedModels.push_back(FGModelID(path,model));
-}
-
bool FGAIManager::getStartPosition(const string& id, const string& pid,
SGGeod& geodPos, double& hdng, SGVec3d& uvw)
{
#include <Traffic/Schedule.hxx>
SG_USING_STD(list);
-SG_USING_STD(vector);
-
-class FGModelID
-{
-private:
- osg::ref_ptr<osg::Node> model;
- string path;
-public:
- FGModelID(const string& pth, osg::Node* mdl) { path =pth; model=mdl;};
- osg::Node* const getModelId() const { return model.get();};
- const string & getPath() const { return path;};
- int getNumRefs() const { return model->referenceCount(); };
-};
-
-typedef vector<FGModelID> ModelVec;
-typedef vector<FGModelID>::iterator ModelVecIterator;
class FGAIThermal;
-
class FGAIManager : public SGSubsystem
{
typedef ai_list_type::const_iterator ai_list_const_iterator;
ai_list_type ai_list;
- ModelVec loadedModels;
public:
void processScenario( const string &filename );
- osg::Node* getModel(const string& path);
- void setModel(const string& path, osg::Node *model);
-
static SGPropertyNode_ptr loadScenarioFile(const std::string& filename);
static bool getStartPosition(const string& id, const string& pid,