Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/entity.h2
-rw-r--r--src/core/model.cc24
-rw-r--r--src/core/model.h15
3 files changed, 29 insertions, 12 deletions
diff --git a/src/core/entity.h b/src/core/entity.h
index 1f47640..323eec7 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -28,7 +28,7 @@ class Entity
{
public:
/// Entity flags
- enum Flags {Static=1, Solid=2};
+ enum Flags {Static=1, Solid=2, Bright=4};
/// Entity type constants
enum Type {Default=0, Dynamic=1, Controlable=2};
diff --git a/src/core/model.cc b/src/core/model.cc
index da179e5..88a1040 100644
--- a/src/core/model.cc
+++ b/src/core/model.cc
@@ -247,6 +247,11 @@ Model::Model(std::string const & name) :
ifs.close();
if (model_face.size()) {
+ if (model_maxbbox.lengthsquared() > model_minbbox.lengthsquared()) {
+ model_radius = model_maxbbox.length();
+ } else {
+ model_radius = model_minbbox.length();
+ }
model_valid = true;
}
con_debug << " maps/" << name << ".map " << model_face.size() << " polygons\n";
@@ -502,18 +507,17 @@ void Model::make_face(math::Plane3f *face, std::vector<math::Plane3f *> & planes
Face *mf = new Face(face->normal()*-1, color);
for (std::vector<Vector3f *>::iterator it = vl.begin(); it != vl.end(); it++) {
mf->add_vertex(*(*it) * model_scale);
- }
- add_face(mf);
- /*
- mf->add_vertex(*(*vn) * model_scale);
- mf->add_vertex(*(*v0) * model_scale);
- mf->add_vertex(*(*vn1) * model_scale);
- add_face(mf);
+
+ // bounding box
+ for (int i=0; i < 3; i++) {
+ if (model_maxbbox[i] < (*(*it))[i] * model_scale)
+ model_maxbbox[i] = (*(*it))[i] * model_scale;
- vl.pop_back();
+ if (model_minbbox[i] > (*(*it))[i] * model_scale)
+ model_minbbox[i] = (*(*it))[i] * model_scale;
+ }
}
- */
-
+ add_face(mf);
if (color) delete color;
} else {
con_debug << "Unresolved face!\n";
diff --git a/src/core/model.h b/src/core/model.h
index 013edcc..00c8a48 100644
--- a/src/core/model.h
+++ b/src/core/model.h
@@ -88,7 +88,16 @@ public:
{
return model_name;
}
+
+ /// maximum values of the bounding box
+ inline math::Vector3f const & maxbbox() const { return model_maxbbox; }
+ /// minimum values of the bounding box
+ inline math::Vector3f const & minbbox() const { return model_minbbox; }
+
+ /// radius
+ inline float radius() const { return model_radius; }
+
/// the Model registry
static std::map<std::string, Model*> registry;
@@ -114,7 +123,7 @@ public:
/// list of Lights
std::list<Light *> model_light;
-
+
private:
void make_face(math::Plane3f *face, std::vector<math::Plane3f *> & planes);
void add_engine(Engine *engine);
@@ -123,8 +132,12 @@ private:
std::string model_name;
+ float model_radius;
float model_scale;
bool model_valid;
+
+ math::Vector3f model_maxbbox;
+ math::Vector3f model_minbbox;
};
}