Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/entity.h52
-rw-r--r--src/core/parser.cc35
-rw-r--r--src/game/base/game.cc22
-rw-r--r--src/game/base/planet.cc2
-rw-r--r--src/game/base/shipdealer.cc6
-rw-r--r--src/game/base/station.cc2
-rw-r--r--src/game/example/example.cc18
-rw-r--r--src/game/intro/convoy.cc14
-rw-r--r--src/game/intro/intro.cc4
-rw-r--r--src/model/mapfile.cc52
-rw-r--r--src/model/parts.cc42
-rw-r--r--src/model/parts.h64
-rw-r--r--src/render/draw.cc14
-rw-r--r--src/render/render.h2
14 files changed, 237 insertions, 92 deletions
diff --git a/src/core/entity.h b/src/core/entity.h
index da58d86..41c56b4 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -101,37 +101,37 @@ public:
inline bool dirty() const { return entity_dirty; }
/// entity location
- inline math::Vector3f & location() { return entity_location; }
+ inline const math::Vector3f& location() const { return entity_location; }
/// local coordinate system of the entity
- inline math::Axis & axis() { return entity_axis; }
+ inline const math::Axis& axis() const { return entity_axis; }
/// primary color of the entity
- inline math::Color const & color() const { return entity_color; }
+ inline const math::Color& color() const { return entity_color; }
/// secondary
- inline math::Color const & color_second() const { return entity_color_second; }
+ inline const math::Color& color_second() const { return entity_color_second; }
/// base shape of the entity
- inline Shape shape() const { return entity_shape; }
+ inline const Shape shape() const { return entity_shape; }
/// base radius of the entity
- inline float radius() const { return entity_radius; }
+ inline const float radius() const { return entity_radius; }
/// current speed of the entity in game units per second
inline const float speed() const { return entity_speed; }
/// indicates a server-side entity
- inline bool serverside() const { return entity_serverside; }
+ inline const bool serverside() const { return entity_serverside; }
/// general visibility
- inline bool visible() const { return entity_visible; }
+ inline const bool visible() const { return entity_visible; }
/// entity menus
inline Menus &menus() { return entity_menus; }
/// extensions
- inline Extension *extension(size_t type) { return entity_extension[type]; }
+ inline Extension *extension(size_t type) const { return entity_extension[type]; }
/// find a menu
MenuDescription *find_menu(std::string const &label);
@@ -228,6 +228,29 @@ public:
/// clear all update flags
virtual void clear_updates();
+/*----- actors ---------------------------------------------------- */
+
+ /**
+ * @brief mutable reference to the location
+ */
+ inline math::Vector3f& get_location() { return entity_location; }
+
+ /**
+ * @brief mutable reference to the axis
+ */
+ inline math::Axis& get_axis() { return entity_axis; }
+
+ /**
+ * @brief mutable reference to the primary color
+ */
+ inline math::Color& get_color() { return entity_color; }
+
+ /**
+ * @brief mutable reference to the secondary color
+ */
+
+ inline math::Color& get_color_second() { return entity_color_second; }
+
/*----- static ---------------------------------------------------- */
/// type definition for the entity registry
@@ -249,17 +272,11 @@ public:
static inline Registry & registry() { return entity_registry; }
/* entity_ variables can be set by the module */
- math::Vector3f entity_location;
- math::Axis entity_axis;
/// speed of the entity
float entity_speed;
-
-
float entity_radius;
Shape entity_shape;
- math::Color entity_color;
- math::Color entity_color_second;
unsigned int entity_moduletypeid;
bool entity_dirty;
@@ -278,6 +295,11 @@ protected:
bool entity_visible;
bool entity_serverside;
+ math::Vector3f entity_location;
+ math::Axis entity_axis;
+ math::Color entity_color;
+ math::Color entity_color_second;
+
private:
unsigned int entity_id;
unsigned int entity_flags;
diff --git a/src/core/parser.cc b/src/core/parser.cc
index 0cee506..fcca2e1 100644
--- a/src/core/parser.cc
+++ b/src/core/parser.cc
@@ -13,11 +13,18 @@ namespace core {
bool Parser::got_entity_key(filesystem::IniFile &inifile, core::Entity *entity)
{
+ math::Vector3f v;
+ math::Color color;
+
std::string shapename;
std::string strval;
+
float direction;
float pitch;
float roll;
+
+ float f;
+
bool blnval;
if (inifile.got_key_string("shape", shapename)) {
@@ -42,34 +49,48 @@ bool Parser::got_entity_key(filesystem::IniFile &inifile, core::Entity *entity)
} else if (inifile.got_key_string("label", strval)) {
entity->set_label(strval);
return true;
+
} else if (inifile.got_key_string("name", strval)) {
entity->set_name(strval);
return true;
+
} else if (inifile.got_key_string("model", strval)) {
entity->set_modelname(strval);
return true;
+
} else if (inifile.got_key_bool("showonmap", blnval)) {
if (blnval)
entity->set_flag(Entity::ShowOnMap);
else
entity->unset_flag(Entity::ShowOnMap);
return true;
+
} else if (inifile.got_key_angle("direction", direction)) {
- entity->axis().change_direction(direction);
+ entity->get_axis().change_direction(direction);
return true;
+
} else if (inifile.got_key_angle("pitch", pitch)) {
- entity->axis().change_pitch(pitch);
+ entity->get_axis().change_pitch(pitch);
return true;
+
} else if (inifile.got_key_angle("roll", roll)) {
- entity->axis().change_roll(roll);
+ entity->get_axis().change_roll(roll);
return true;
- } else if (inifile.got_key_angle("radius", entity->entity_radius)) {
+
+ } else if (inifile.got_key_angle("radius", f)) {
+ entity->entity_radius = f;
return true;
- } else if (inifile.got_key_vector3f("location", entity->entity_location)) {
+
+ } else if (inifile.got_key_vector3f("location", v)) {
+ entity->get_location().assign(v);
return true;
- } else if (inifile.got_key_color("colorsecond", entity->entity_color_second)) {
+
+ } else if (inifile.got_key_color("colorsecond", color)) {
+ entity->get_color_second().assign(color);
return true;
- } else if (inifile.got_key_color("color", entity->entity_color)) {
+
+ } else if (inifile.got_key_color("color", color)) {
+ entity->get_color().assign(color);
return true;
}
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index ed1b80e..35dfc5f 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -82,8 +82,8 @@ void Game::func_join(core::Player *player, std::string const &args)
core::Entity *dock = ship->zone()->default_view();
if (dock) {
- ship->entity_location.assign(dock->location() + (dock->axis().forward() * ((ship->radius()+ dock->radius())*2.0f)));
- ship->entity_axis.assign(dock->axis());
+ ship->get_location().assign(dock->location() + (dock->axis().forward() * ((ship->radius()+ dock->radius())*2.0f)));
+ ship->get_axis().assign(dock->axis());
ship->set_state(core::Entity::Docked);
player->set_view(dock);
}
@@ -237,8 +237,8 @@ void Game::func_launch(core::Player *player, std::string const &args)
Ship *ship = static_cast<Ship *>(player->control());
ship->shutdown_physics();
core::Entity *dock = player->view();
- ship->entity_location.assign(dock->location() + (dock->axis().forward() * (ship->radius()+ dock->radius())));
- ship->entity_axis.assign(dock->axis());
+ ship->get_location().assign(dock->location() + (dock->axis().forward() * (ship->radius()+ dock->radius())));
+ ship->get_axis().assign(dock->axis());
ship->set_state(core::Entity::Normal);
ship->init_physics(ship->radius());
ship->set_state(core::Entity::Jump);
@@ -265,14 +265,14 @@ void Game::func_respawn(core::Player *player, std::string const &args)
ship->shutdown_physics();
if (dock) {
- ship->entity_location.assign(dock->location() + (dock->axis().forward() * ((ship->radius()+ dock->radius()))));
- ship->entity_axis.assign(dock->axis());
+ ship->get_location().assign(dock->location() + (dock->axis().forward() * ((ship->radius()+ dock->radius()))));
+ ship->get_axis().assign(dock->axis());
ship->set_state(core::Entity::Docked);
player->set_view(dock);
player->send("^BRespawning at " + dock->name());
} else {
- ship->location().clear();
- ship->axis().clear();
+ ship->get_location().clear();
+ ship->get_axis().clear();
ship->set_state(core::Entity::Jump);
player->set_view(0);
player->send("^BRespawning");
@@ -303,9 +303,9 @@ void Game::func_goto(core::Player *player, const std::string &args)
if (dock) {
ship->shutdown_physics();
- ship->entity_location.assign(dock->location() + (dock->axis().forward() * (ship->radius()+dock->radius())));
- ship->entity_axis.assign(dock->axis());
- ship->entity_axis.change_direction(180.0f);
+ ship->get_location().assign(dock->location() + (dock->axis().forward() * (ship->radius()+dock->radius())));
+ ship->get_axis().assign(dock->axis());
+ ship->get_axis().change_direction(180.0f);
ship->set_state(core::Entity::Normal);
ship->init_physics(ship->radius());
diff --git a/src/game/base/planet.cc b/src/game/base/planet.cc
index 3242f15..60885b1 100644
--- a/src/game/base/planet.cc
+++ b/src/game/base/planet.cc
@@ -52,7 +52,7 @@ void Planet::dock(core::Entity *entity)
return;
}
- ship->location().assign(entity->location());
+ ship->get_location().assign(entity->location());
ship->set_state(core::Entity::Docked);
if (ship->owner() && ship->owner()->control() == ship) {
diff --git a/src/game/base/shipdealer.cc b/src/game/base/shipdealer.cc
index feef432..408ae43 100644
--- a/src/game/base/shipdealer.cc
+++ b/src/game/base/shipdealer.cc
@@ -132,10 +132,10 @@ void ShipDealer::func_buy(core::Player *player, const std::string &args)
Ship * ship = new Ship(player, shipmodel);
if (dock) {
ship->set_zone(dock->zone());
- ship->location().assign(dock->location());
+ ship->get_location().assign(dock->location());
ship->set_state(core::Entity::Docked);
- ship->entity_axis.assign(dock->axis());
- ship->entity_axis.change_direction(180.0f);
+ ship->get_axis().assign(dock->axis());
+ ship->get_axis().change_direction(180.0f);
player->set_control(ship);
player->set_view(dock);
} else {
diff --git a/src/game/base/station.cc b/src/game/base/station.cc
index 67c1595..0552269 100644
--- a/src/game/base/station.cc
+++ b/src/game/base/station.cc
@@ -48,7 +48,7 @@ void Station::dock(core::Entity *entity)
return;
}
- ship->location().assign(entity->location());
+ ship->get_location().assign(entity->location());
ship->set_state(core::Entity::Docked);
if (ship->owner() && ship->owner()->control() == ship) {
diff --git a/src/game/example/example.cc b/src/game/example/example.cc
index 25daef7..9d4c1ed 100644
--- a/src/game/example/example.cc
+++ b/src/game/example/example.cc
@@ -43,8 +43,8 @@ Example::Example() : core::Module("The Osirion Project Example", true)
cube->set_label("cube");
cube->set_name("The Red Cube");
cube->entity_shape = core::Entity::Cube; // set the shape to cube
- cube->entity_location.assign(16, -8, 0); // set location
- cube->entity_color.assign(1, 0, 0); // set RGB color red
+ cube->get_location().assign(16, -8, 0); // set location
+ cube->get_color().assign(1, 0, 0); // set RGB color red
cube->entity_radius = 0.25f; // set radius, in game units
cube->set_zone(zone); // add the entity to the zone
@@ -52,8 +52,8 @@ Example::Example() : core::Module("The Osirion Project Example", true)
sphere->set_label("sphere");
sphere->set_name("The Green Sphere");
sphere->entity_shape = core::Entity::Sphere; // set the shape to sphere
- sphere->entity_location.assign(16, 0, 0); // set location
- sphere->entity_color.assign(0, 1, 0); // set RGB color green
+ sphere->get_location().assign(16, 0, 0); // set location
+ sphere->get_color().assign(0, 1, 0); // set RGB color green
sphere->entity_radius = 0.25f; // set radius, in game units
sphere->set_zone(zone); // add the entity to the zone
@@ -61,8 +61,8 @@ Example::Example() : core::Module("The Osirion Project Example", true)
diamond->set_label("diamond");
diamond->set_name("The Blue Diamond");
diamond->entity_shape = core::Entity::Diamond; // set the shape to cube
- diamond->entity_location.assign(16, 8, 0); // set location
- diamond->entity_color.assign(0, 0, 1); // set RGB color blue
+ diamond->get_location().assign(16, 8, 0); // set location
+ diamond->get_color().assign(0, 0, 1); // set RGB color blue
diamond->entity_radius = 0.25f; // set radius, in game units
diamond->set_zone(zone); // add the entity to the zone
@@ -70,9 +70,9 @@ Example::Example() : core::Module("The Osirion Project Example", true)
axis->set_label("origin");
axis->set_name("The Origin");
axis->entity_shape = core::Entity::Axis; // set the shape to axis
- axis->entity_location.assign(0, 0, 0); // set location
- axis->entity_color.assign(1); // set greyscale color white
- axis->entity_color_second.assign(0.5f, 0.0f, 0.5f); // set RGB secondary color
+ axis->get_location().assign(0, 0, 0); // set location
+ axis->get_color().assign(1); // set greyscale color white
+ axis->get_color_second().assign(0.5f, 0.0f, 0.5f); // set RGB secondary color
axis->entity_radius = 0.25f; // set radius, in game units
axis->set_zone(zone); // add the entity to the zone
diff --git a/src/game/intro/convoy.cc b/src/game/intro/convoy.cc
index 6671369..9e13ae5 100644
--- a/src/game/intro/convoy.cc
+++ b/src/game/intro/convoy.cc
@@ -59,20 +59,20 @@ void Convoy::add(const std::string &model)
Member *member = new Member(model);
convoy_members.push_back(member);
member->set_zone(zone());
- member->entity_color.assign(color());
- member->entity_color_second.assign(color_second());
+ member->get_color().assign(color());
+ member->get_color_second().assign(color_second());
member->entity_thrust = 1.0f;
member->entity_speed = speed();
- member->entity_location.assign(location());
+ member->get_location().assign(location());
d = ((float) convoy_members.size()) * 0.5f;
- member->entity_location.x += math::randomf((float) convoy_members.size()) -d;
- member->entity_location.y += math::randomf((float) convoy_members.size()) -d;
- member->entity_location.z += (math::randomf((float) convoy_members.size()) -d) * 0.5f;
+ member->get_location().x += math::randomf((float) convoy_members.size()) -d;
+ member->get_location().y += math::randomf((float) convoy_members.size()) -d;
+ member->get_location().z += (math::randomf((float) convoy_members.size()) -d) * 0.5f;
- member->entity_axis.assign(axis());
+ member->get_axis().assign(axis());
}
void Convoy::frame(float seconds)
diff --git a/src/game/intro/intro.cc b/src/game/intro/intro.cc
index 3fafa0f..05dcec7 100644
--- a/src/game/intro/intro.cc
+++ b/src/game/intro/intro.cc
@@ -104,10 +104,10 @@ bool Intro::load_world()
convoy->set_color_second(color);
} else if (ini.got_key_vector3f("location", v)) {
- convoy->entity_location.assign(v);
+ convoy->get_location().assign(v);
} else if (ini.got_key_float("direction", f)) {
- convoy->axis().change_direction(f);
+ convoy->get_axis().change_direction(f);
} else if (ini.got_key_float("speed", f)) {
convoy->entity_speed = f;
diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc
index a86e06e..9c9048b 100644
--- a/src/model/mapfile.cc
+++ b/src/model/mapfile.cc
@@ -1211,7 +1211,7 @@ Model * MapFile::load(std::string const &name)
// submodel attributes
if (mapfile.got_key_vector3f("origin", location)) {
- submodel->set_location(location * SCALE);
+ submodel->get_location().assign(location * SCALE);
continue;
} else if (mapfile.got_key_string("model", modelname)) {
@@ -1226,11 +1226,11 @@ Model * MapFile::load(std::string const &name)
} else if (mapfile.got_key_float("angle", angle)) {
if (angle == ANGLEUP) {
- submodel->axis().change_pitch(90.0f);
+ submodel->get_axis().change_pitch(90.0f);
} else if (angle == ANGLEDOWN) {
- submodel->axis().change_pitch(-90.0f);
+ submodel->get_axis().change_pitch(-90.0f);
} else {
- submodel->axis().change_direction(angle);
+ submodel->get_axis().change_direction(angle);
}
} else if (mapfile.got_key_float("modelscale", s)) {
@@ -1316,7 +1316,6 @@ Model * MapFile::load(std::string const &name)
(*dit)->get_location() -= mapfile.map_center;
}
- // FIXME this will go wrong if a Rotate group is imported as submodel
for (SubModelList::iterator smit = submodel_list.begin(); smit != submodel_list.end(); smit++) {
submodel = (*smit);
Model *submodel_model = 0;
@@ -1326,6 +1325,8 @@ Model * MapFile::load(std::string const &name)
}
if (submodel_model) {
+ submodel->get_location() -= mapfile.map_center;
+
// copy fragmentgroups
for (Model::Groups::iterator git = submodel_model->groups().begin(); git != submodel_model->groups().end(); git++) {
FragmentGroup *groupsrc = (*git);
@@ -1335,7 +1336,7 @@ Model * MapFile::load(std::string const &name)
groupdst->set_type(groupsrc->type());
groupdst->set_scale(groupsrc->scale() * submodel->scale());
groupdst->set_speed(groupsrc->speed());
- groupdst->set_location((submodel->location() - mapfile.map_center) + (submodel_model->origin() + groupsrc->location()) * submodel->scale() );
+ groupdst->set_location(submodel->location() + (submodel_model->origin() + groupsrc->location()) * submodel->scale() );
groupdst->set_axis(groupsrc->axis() * submodel->axis());
// copy fragments
@@ -1351,6 +1352,45 @@ Model * MapFile::load(std::string const &name)
}
}
+ // recalculate bbox
+ for (size_t i =0; i < 3; i ++) {
+ float c;
+ c = submodel->location()[i] + (submodel_model->origin()[i] + submodel_model->model_maxbbox[i]) * submodel->scale();
+ if (c > model->model_maxbbox[i]) {
+ model->model_maxbbox[i] = c;
+ }
+
+ c = submodel->location()[i] + (submodel_model->origin()[i] + submodel_model->model_minbbox[i]) * submodel->scale();
+ if (c < model->model_minbbox[i]) {
+ model->model_minbbox[i] = c;
+ }
+
+ }
+ model->set_radius(sqrtf(math::max(model->model_maxbbox.lengthsquared(), model->model_minbbox.lengthsquared())));
+
+ // copy lights, flares and particle systems
+ for (Model::Lights::const_iterator lit = submodel_model->lights().begin(); lit != submodel_model->lights().end(); lit++) {
+ light = new Light(*(*lit));
+ light->get_location().assign(submodel->location() + (submodel_model->origin() + light->location()) * submodel->scale());
+ light->set_radius(light->radius() * submodel->scale());
+ model->add_light(light);
+ }
+
+ for (Model::Flares::const_iterator flit = submodel_model->flares().begin(); flit != submodel_model->flares().end(); flit++) {
+ flare = new Flare(*(*flit));
+ flare->get_location().assign(submodel->location() + (submodel_model->origin() + flare->location()) * submodel->scale());
+ flare->set_radius(flare->radius() * submodel->scale());
+ model->add_flare(flare);
+ }
+
+ for (Model::ParticleSystems::const_iterator pit = submodel_model->particles().begin(); pit != submodel_model->particles().end(); pit++) {
+ particles = new Particles(*(*pit));
+ particles->get_location().assign(submodel->location() + (submodel_model->origin() + particles->location()) * submodel->scale());
+ particles->set_radius(particles->radius() * submodel->scale());
+ model->add_particles(particles);
+ }
+
+
con_debug << " imported submodel '" << submodel->name() << "'" << std::endl;
}
diff --git a/src/model/parts.cc b/src/model/parts.cc
index eabc108..ac54410 100644
--- a/src/model/parts.cc
+++ b/src/model/parts.cc
@@ -28,6 +28,22 @@ Light::Light() :
light_texture = 0;
}
+Light::Light(const Light& other) : Part(other),
+ light_color(other.color())
+{
+ light_entity = other.entity();
+ light_engine = other.engine();
+ light_strobe = other.strobe();
+
+ light_radius = other.radius();
+ light_frequency = other.frequency();
+ light_offset = other.offset();
+ light_time = other.time();
+
+ light_flare = other.flare();
+
+ light_texture = other.texture();
+}
Light::~Light()
{}
@@ -38,13 +54,17 @@ Flare::Flare() : Light()
flare_cull = CullBack;
}
+Flare::Flare(const Flare& other) : Light(other)
+{
+ flare_cull = other.cull();
+}
+
Flare::~Flare()
{}
/* ---- class Particles -------------------------------------------- */
-Particles::Particles() :
- Part()
+Particles::Particles() : Part()
{
particles_entity = false;
particles_engine = false;
@@ -52,7 +72,7 @@ Particles::Particles() :
particles_cull = CullNone;
}
-Particles::Particles(math::Vector3f const & location) :
+Particles::Particles(const math::Vector3f& location) :
Part(location)
{
}
@@ -63,22 +83,34 @@ Particles::~Particles()
/* ---- class Dock ------------------------------------------------- */
-Dock::Dock()
+Dock::Dock() : Part()
{
dock_radius = 0.01f;
}
+Dock::Dock(const Dock& other) : Part(other)
+{
+ dock_radius = other.radius();
+}
+
Dock::~Dock()
{
}
/* ---- class SubModel---------------------------------------------- */
-SubModel::SubModel()
+SubModel::SubModel() : Part()
{
submodel_scale = 1.0f;
}
+SubModel::SubModel(const SubModel& other) : Part(other),
+ submodel_name(other.name()),
+ submodel_axis(other.axis())
+{
+ submodel_scale = other.scale();
+}
+
SubModel::~SubModel()
{
}
diff --git a/src/model/parts.h b/src/model/parts.h
index c3a0401..5c90efb 100644
--- a/src/model/parts.h
+++ b/src/model/parts.h
@@ -42,9 +42,17 @@ public:
}
/**
+ * @brief copy constructor
+ */
+ inline Part(const Part& other) : part_location(other.location())
+ {
+ }
+
+ /**
* @brief constructor with location
+ * @param location location of this part within the parent model
*/
- inline Part(const math::Vector3f &location) : part_location(location)
+ inline Part(const math::Vector3f& location) : part_location(location)
{
}
@@ -53,7 +61,7 @@ public:
/**
* @brief location of this part within the parent model
*/
- inline const math::Vector3f &location() const
+ inline const math::Vector3f& location() const
{
return part_location;
}
@@ -62,7 +70,7 @@ public:
/**
* @brief set the location within the parent model
*/
- inline void set_location(const math::Vector3f location) { part_location.assign(location); }
+ inline void set_location(const math::Vector3f& location) { part_location.assign(location); }
/**
* @brief set the location within the parent model
@@ -74,7 +82,7 @@ public:
/**
* @brief mutable reference to the location of this part within the parent model
*/
- inline math::Vector3f &get_location()
+ inline math::Vector3f& get_location()
{
return part_location;
}
@@ -95,6 +103,11 @@ public:
Light();
/**
+ * @brief copy constructor
+ */
+ Light(const Light& other);
+
+ /**
* @brief destructor
*/
~Light();
@@ -102,7 +115,7 @@ public:
/* ---- inspectors ----------------------------------------- */
/// light color
- inline const math::Color & color() const
+ inline const math::Color& color() const
{
return light_color;
};
@@ -237,6 +250,11 @@ class Flare : public Light
public:
Flare();
+ /**
+ * @brief copy constructor
+ */
+ Flare(const Flare& other);
+
~Flare();
/* ---- inspectors ----------------------------------------- */
@@ -282,7 +300,7 @@ public:
return particles_axis;
}
- inline const std::string & script() const
+ inline const std::string& script() const
{
return particles_script;
}
@@ -323,14 +341,14 @@ public:
inline void set_cull(const Cull cull) { particles_cull = cull; }
- inline void set_script(const std::string &script) { particles_script.assign(script); }
+ inline void set_script(const std::string& script) { particles_script.assign(script); }
/* ---- actors --------------------------------------------- */
/**
* @brief mutable reference to the axis
*/
- inline math::Axis &get_axis() { return particles_axis; }
+ inline math::Axis& get_axis() { return particles_axis; }
private:
bool particles_entity;
@@ -351,6 +369,12 @@ class Dock : public Part
{
public:
Dock();
+
+ /**
+ * @brief copy constructor
+ */
+ Dock(const Dock& other);
+
~Dock();
/// dock radius, default is 0.01f
@@ -369,32 +393,38 @@ private:
/* ---- class SubModel --------------------------------------------- */
/// a submodel
-class SubModel
+class SubModel : public Part
{
public:
SubModel();
+
+ SubModel(const SubModel& other);
+
~SubModel();
- inline const std::string &name() const { return submodel_name; }
+ inline const std::string& name() const { return submodel_name; }
inline const float scale() const { return submodel_scale; }
- inline const math::Vector3f &location() const { return submodel_location; }
+ inline const math::Axis& axis() const { return submodel_axis; }
- inline math::Axis &axis() { return submodel_axis; }
inline void set_scale(const float scale) { submodel_scale = scale; }
- inline void set_name(const std::string &name) { submodel_name.assign(name); }
+ inline void set_name(const std::string& name) { submodel_name.assign(name); }
+
+ inline void set_axis(const math::Axis& axis) { submodel_axis.assign(axis); }
- inline void set_location(const math::Vector3f &location) { submodel_location.assign(location); }
+ /* ---- actors --------------------------------------------- */
- inline void set_axis(const math::Axis &axis) { submodel_axis.assign(axis); }
+ /**
+ * @brief mutable reference to the axis
+ */
+ inline math::Axis& get_axis() { return submodel_axis; }
private:
- std::string submodel_name;
float submodel_scale;
- math::Vector3f submodel_location;
+ std::string submodel_name;
math::Axis submodel_axis;
};
diff --git a/src/render/draw.cc b/src/render/draw.cc
index e9e655c..1884125 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -201,7 +201,7 @@ void draw_sphere(math::Color const & color, float radius)
}
}
-void draw_globe(core::EntityGlobe *globe)
+void draw_globe(const core::EntityGlobe* globe)
{
/*
Globes have to be rendered distance sorted, closest last.
@@ -226,8 +226,8 @@ void draw_globe(core::EntityGlobe *globe)
if (ext_render(globe)->distance() > (FARPLANE - globe->radius())) {
// globe is behind the far plane, make a fake size calculation
- location = Camera::eye() + (location - Camera::eye()) * (FARPLANE / ext_render(globe)->distance());
- radius *= FARPLANE / ext_render(globe)->distance();
+ location = Camera::eye() + (location - Camera::eye()) * ((FARPLANE - globe->radius()) / ext_render(globe)->distance());
+ radius *= (FARPLANE - globe->radius()) / (ext_render(globe)->distance());
gl::depthmask(GL_FALSE);
@@ -336,12 +336,12 @@ void draw_pass_globes()
/* ---- Default entities ------------------------------------------ */
-void draw_entity_sphere(core::Entity *entity)
+void draw_entity_sphere(const core::Entity* entity)
{
draw_sphere(entity->color(), entity->radius());
}
-void draw_entity_cube(core::Entity *entity)
+void draw_entity_cube(const core::Entity* entity)
{
float radius = entity->radius();
@@ -392,7 +392,7 @@ void draw_entity_cube(core::Entity *entity)
gl::end();
}
-void draw_entity_diamond(core::Entity *entity)
+void draw_entity_diamond(const core::Entity* entity)
{
float radius = entity->radius()/2;
@@ -472,7 +472,7 @@ void draw_entity_diamond(core::Entity *entity)
}
}
-void draw_entity_axis(core::Entity *entity)
+void draw_entity_axis(const core::Entity* entity)
{
float r = entity->radius();
diff --git a/src/render/render.h b/src/render/render.h
index 0073f57..c397c78 100644
--- a/src/render/render.h
+++ b/src/render/render.h
@@ -57,7 +57,7 @@ namespace render {
/// use GL_NORMALIZE instead of GL_RESCALE_NORMAL
extern core::Cvar *r_normalize;
- inline RenderExt *ext_render(core::Entity *entity) { return static_cast<RenderExt *>(entity->extension((size_t)core::Extension::Render)); }
+ inline RenderExt *ext_render(const core::Entity *entity) { return static_cast<RenderExt *>(entity->extension((size_t)core::Extension::Render)); }
}