MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / loadModel

Method loadModel

Source/Graphics/models.cpp:109–133  ·  view source on GitHub ↗

Load a model and return its ID

Source from the content-addressed store, hash-verified

107
108// Load a model and return its ID
109int Models::loadModel(const std::string& rel_path, char flags, const std::string& store_name) {
110 int which_model = -1;
111 const std::string& check_name = store_name.empty() ? rel_path : store_name;
112 // Check if the model is already loaded
113 std::map<std::string, int>::iterator iter = name_map.find(check_name);
114 if (iter != name_map.end()) {
115 which_model = iter->second;
116 }
117 // If model is not loaded; load it
118 unsigned int i = 0;
119 if (which_model == -1) {
120 which_model = AddModel();
121 ModelData& md = GetModelData(which_model);
122 // Check extension
123 while (i < rel_path.size() && rel_path[i] != '.') {
124 i++;
125 }
126 if (rel_path[i + 1] == 'o') {
127 md.model.LoadObj(rel_path, flags, check_name);
128 }
129 md.name = rel_path;
130 name_map[check_name] = which_model;
131 }
132 return which_model;
133}
134
135// Select which model to draw
136void Models::drawModel(int which_model) {

Callers 8

LoadDetailModelMethod · 0.45
InitMethod · 0.45
AlternateHullMethod · 0.45
LoadMethod · 0.45
LoadMethod · 0.45
LoadMethod · 0.45
GetCollisionModelIDMethod · 0.45
LoadModelMethod · 0.45

Calls 5

LoadObjMethod · 0.80
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected