Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2009-08-16 17:34:00 +0000
committerStijn Buys <ingar@osirion.org>2009-08-16 17:34:00 +0000
commitd763e294f44eb38b94bf7e2055b77a982b72b7c0 (patch)
tree37f91c6b7fee58fcecfbfc54dda3f71eb8617b9f /src
parent95cc140404c6524ea16e193e1421e826b239114f (diff)
more constness
Diffstat (limited to 'src')
-rw-r--r--src/client/chat.cc8
-rw-r--r--src/client/hud.cc18
-rw-r--r--src/client/infowidget.cc6
-rw-r--r--src/client/map.cc42
-rw-r--r--src/client/notifications.cc6
-rw-r--r--src/client/soundext.cc2
-rw-r--r--src/game/intro/convoy.cc6
-rw-r--r--src/math/vector2f.cc6
-rw-r--r--src/math/vector2f.h36
-rw-r--r--src/math/vector3f.cc9
-rw-r--r--src/math/vector3f.h32
-rw-r--r--src/model/asefile.cc6
-rw-r--r--src/model/face.cc4
-rw-r--r--src/model/fragment.cc2
-rw-r--r--src/model/mapfile.cc66
-rw-r--r--src/render/camera.cc6
-rw-r--r--src/render/draw.cc68
-rw-r--r--src/render/dust.cc6
-rw-r--r--src/ui/console.cc12
-rw-r--r--src/ui/font.cc4
-rw-r--r--src/ui/font.h4
-rw-r--r--src/ui/inputbox.cc4
-rwxr-xr-xsrc/ui/modelview.cc6
-rw-r--r--src/ui/paint.cc49
-rw-r--r--src/ui/scrollpane.cc4
-rw-r--r--src/ui/ui.cc6
-rw-r--r--src/ui/widget.cc4
-rw-r--r--src/ui/widget.h12
28 files changed, 226 insertions, 208 deletions
diff --git a/src/client/chat.cc b/src/client/chat.cc
index 93ba4b0..137e6b1 100644
--- a/src/client/chat.cc
+++ b/src/client/chat.cc
@@ -183,14 +183,14 @@ void Chat::resize()
const float margin = 8.0f;
math::Vector2f s(size());
- s.x -= margin*2;
- s.y -= margin*2;
+ s[0] -= margin*2;
+ s[1] -= margin*2;
chat_scrollpane->set_location(margin, margin);
- chat_scrollpane->set_size(s.x, s.y - font()->height() *1.5f);
+ chat_scrollpane->set_size(s.width(), s.height() - font()->height() *1.5f);
chat_input->set_location(margin, height() - font()->height() - margin);
- chat_input->set_size(s.x, font()->height());
+ chat_input->set_size(s.width(), font()->height());
}
diff --git a/src/client/hud.cc b/src/client/hud.cc
index 102c445..662bbe8 100644
--- a/src/client/hud.cc
+++ b/src/client/hud.cc
@@ -50,19 +50,19 @@ void HUD::draw_offscreen_target(core::Entity *entity, bool is_active_target)
float cx = 0;
float cy = 0;
- if ( target.y*target.y + target.z*target.z < 0.0001 ) {
+ if ( target.y() * target.y() + target.z() * target.z() < 0.0001 ) {
// X - bound, behind (front is visible)
cx = 0.0f;
cy = -0.5f;
- } else if (fabs(target.y) > fabs(target.z)) {
+ } else if (fabs(target.y()) > fabs(target.z())) {
// Y-bound
- cx = math::sgnf(target.y) * 0.5f;
- cy = 0.5f * target.z / fabs(target.y);
+ cx = math::sgnf(target.y()) * 0.5f;
+ cy = 0.5f * target.z() / fabs(target.y());
} else {
// Z-bound
- cx = 0.5f * target.y / fabs(target.z);
- cy = math::sgnf(target.z) * 0.5f;
+ cx = 0.5f * target.y() / fabs(target.z());
+ cy = math::sgnf(target.z()) * 0.5f;
}
const float r = 16;
@@ -117,11 +117,11 @@ void HUD::draw_target(core::Entity *entity, bool is_active_target)
target = render::Camera::axis().transpose() * target;
// calculate the intersection between the line (0,0,0)-target and the frustum front
- float t = (render::FRUSTUMFRONT + 0.001f) / target.x;
+ float t = (render::FRUSTUMFRONT + 0.001f) / target.x();
Vector3f center(target *t);
- float cx = render::State::width() * (0.5 - center.y);
- float cy = render::State::height() * (0.5 - center.z * render::State::aspect());
+ float cx = render::State::width() * (0.5 - center.y());
+ float cy = render::State::height() * (0.5 - center.z() * render::State::aspect());
if ((cx < 0 ) || (cy < 0) || (cx > render::State::width()) || (cy > render::State::height())) {
draw_offscreen_target(entity, is_active_target);
diff --git a/src/client/infowidget.cc b/src/client/infowidget.cc
index fd3de11..b30dfd7 100644
--- a/src/client/infowidget.cc
+++ b/src/client/infowidget.cc
@@ -58,9 +58,9 @@ void DevInfoWidget::draw()
if (core::localcontrol()) {
textstream << std::fixed << std::setprecision(2)
- << "^Nx ^B" << core::localcontrol()->location().x << " "
- << "^Ny ^B" << core::localcontrol()->location().y << " "
- << "^Nz ^B" << core::localcontrol()->location().z << '\n';
+ << "^Nx ^B" << core::localcontrol()->location().x() << " "
+ << "^Ny ^B" << core::localcontrol()->location().y() << " "
+ << "^Nz ^B" << core::localcontrol()->location().z() << '\n';
textstream << "^Nthurst ^B" << core::localcontrol()->thrust() << " "
<< "^Nspeed ^B" << core::localcontrol()->speed() << '\n';
diff --git a/src/client/map.cc b/src/client/map.cc
index a2a353a..46ac583 100644
--- a/src/client/map.cc
+++ b/src/client/map.cc
@@ -83,19 +83,19 @@ void Map::draw()
math::Vector2f v(global_location());
math::Vector2f l;
- v.x += margin;
- v.y += (height() - s - 2.0f * margin) * 0.5f;
+ v[0] += margin;
+ v[1] += (height() - s - 2.0f * margin) * 0.5f;
map_hover = 0;
gl::color(0,0,blue);
gl::begin(gl::Lines);
for (int i=0; i <= gridsize; i++) {
- gl::vertex(v.x, v.y + s / gridsize * i);
- gl::vertex(v.x + s, v.y + s / gridsize * i);
+ gl::vertex(v.x(), v.y() + s / gridsize * i);
+ gl::vertex(v.x() + s, v.y() + s / gridsize * i);
- gl::vertex(v.x + s / gridsize * i, v.y);
- gl::vertex(v.x + s / gridsize * i, v.y+s);
+ gl::vertex(v.x() + s / gridsize * i, v.y());
+ gl::vertex(v.x() + s / gridsize * i, v.y() + s);
}
gl::end();
@@ -105,8 +105,8 @@ void Map::draw()
size_t texture_current = render::Textures::bind(texture_entity);
- v.x += s * 0.5f;
- v.y += s * 0.5f;
+ v[0] += s * 0.5f;
+ v[0] += s * 0.5f;
core::Zone *zone = core::localplayer()->zone();
@@ -128,8 +128,8 @@ void Map::draw()
if (targets::is_valid_map_target(entity)) {
draw_icon = true;
- l.x -= s / scale * entity->location().y;
- l.y -= s / scale * entity->location().x;
+ l[0] -= s / scale * entity->location().y();
+ l[1] -= s / scale * entity->location().x();
if (math::distancesquared(cursor, l) < (r*r)) {
map_hover = entity->id();
@@ -175,16 +175,16 @@ void Map::draw()
gl::color(color);
glTexCoord2f(0.0f, 0.0f);
- gl::vertex(l.x-r, l.y-r);
+ gl::vertex(l.x() - r, l.y() - r);
glTexCoord2f(1.0f, 0.0f);
- gl::vertex(l.x+r, l.y-r);
+ gl::vertex(l.x() + r, l.y() - r);
glTexCoord2f(1.0f, 1.0f);
- gl::vertex(l.x+r, l.y+r);
+ gl::vertex(l.x() + r, l.y() + r);
glTexCoord2f(0.0f, 1.0f);
- gl::vertex(l.x-r, l.y+r);
+ gl::vertex(l.x() - r, l.y() + r);
}
}
@@ -194,8 +194,8 @@ void Map::draw()
//if (core::localcontrol()->state() != core::Entity::Docked) {
l.assign(v);
- l.x -= s / scale * entity->location().y;
- l.y -= s / scale * entity->location().x;
+ l[0] -= s / scale * entity->location().y();
+ l[1] -= s / scale * entity->location().x();
if (core::application()->time() - floorf(core::application()->time()) < 0.5f) {
if (texture_current != texture_entity) {
gl::end();
@@ -207,16 +207,16 @@ void Map::draw()
color.a = 1.0f;
gl::color(color);
glTexCoord2f(0.0f, 0.0f);
- gl::vertex(l.x-r, l.y-r);
-
+ gl::vertex(l.x() - r, l.y() - r);
+
glTexCoord2f(1.0f, 0.0f);
- gl::vertex(l.x+r, l.y-r);
+ gl::vertex(l.x() + r, l.y() - r);
glTexCoord2f(1.0f, 1.0f);
- gl::vertex(l.x+r, l.y+r);
+ gl::vertex(l.x() + r, l.y() + r);
glTexCoord2f(0.0f, 1.0f);
- gl::vertex(l.x-r, l.y+r);
+ gl::vertex(l.x() - r, l.y() + r);
}
//}
diff --git a/src/client/notifications.cc b/src/client/notifications.cc
index 25cbe0b..062aacb 100644
--- a/src/client/notifications.cc
+++ b/src/client/notifications.cc
@@ -58,11 +58,11 @@ void Notifications::draw()
const float margin = ui::UI::elementmargin;
math::Vector2f s(size());
- s.x -= margin*2;
- s.y -= margin*2;
+ s[0] -= margin*2;
+ s[1] -= margin*2;
notify_scrollpane->set_location(margin, margin);
- notify_scrollpane->set_size(s.x, s.y );
+ notify_scrollpane->set_size(s.x(), s.y() );
}
diff --git a/src/client/soundext.cc b/src/client/soundext.cc
index dda3a98..40b9417 100644
--- a/src/client/soundext.cc
+++ b/src/client/soundext.cc
@@ -98,7 +98,7 @@ void SoundExt::frame(float elapsed)
float speed = entity->speed();
float pitch = 1.0f;
float gain = 0.0;
- float r = ( entity->model() ? entity->model()->maxbbox().x : entity->radius());
+ float r = ( entity->model() ? entity->model()->maxbbox().x() : entity->radius());
if (entity->state() == core::Entity::Impulse) {
pitch = 1.0f;
diff --git a/src/game/intro/convoy.cc b/src/game/intro/convoy.cc
index a0cc27c..ac52c38 100644
--- a/src/game/intro/convoy.cc
+++ b/src/game/intro/convoy.cc
@@ -68,9 +68,9 @@ void Convoy::add(const std::string &model)
member->get_location().assign(location());
d = ((float) convoy_members.size()) * 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->get_location().get_x() += math::randomf((float) convoy_members.size()) -d;
+ member->get_location().get_y() += math::randomf((float) convoy_members.size()) -d;
+ member->get_location().get_z() += (math::randomf((float) convoy_members.size()) -d) * 0.5f;
member->get_axis().assign(axis());
}
diff --git a/src/math/vector2f.cc b/src/math/vector2f.cc
index 2b5ff9e..65f1f93 100644
--- a/src/math/vector2f.cc
+++ b/src/math/vector2f.cc
@@ -12,17 +12,17 @@
namespace math
{
-Vector2f::Vector2f() : x(coord[0]), y(coord[1])
+Vector2f::Vector2f()
{
clear();
}
-Vector2f::Vector2f(const Vector2f &other) : x(coord[0]), y(coord[1])
+Vector2f::Vector2f(const Vector2f &other)
{
assign(other);
}
-Vector2f::Vector2f(const float x, const float y) : x(coord[0]), y(coord[1])
+Vector2f::Vector2f(const float x, const float y)
{
assign(x, y);
}
diff --git a/src/math/vector2f.h b/src/math/vector2f.h
index 6258d85..ba60aa1 100644
--- a/src/math/vector2f.h
+++ b/src/math/vector2f.h
@@ -78,6 +78,28 @@ public:
return coord[index];
}
+ /// x coordinate
+ inline float width() const {
+ return coord[0];
+ }
+
+ /// y coordinate
+ inline float height() const {
+ return coord[1];
+ }
+
+ /// x coordinate
+ inline float x() const { return coord[0]; }
+
+ /// y coordinate
+ inline float y() const { return coord[1]; }
+
+ /// mutable reference to the x coordinate
+ inline float & get_x() { return coord[0]; }
+
+ /// mutable reference to the y coordinate
+ inline float & get_y() { return coord[1]; }
+
/// a pointer to the internal data
inline float *ptr() const {
return (float *) coord;
@@ -91,20 +113,6 @@ public:
return ((x >= 0) && (y >= 0) && (x <= coord[0]) && (y <= coord[1]));
}
- inline float width() const {
- return coord[0];
- }
-
- inline float height() const {
- return coord[1];
- }
-
- /// x coordinate
- float &x;
-
- /// y coordinate
- float &y;
-
private:
float coord[2];
};
diff --git a/src/math/vector3f.cc b/src/math/vector3f.cc
index 8a6dd5e..1e9fd2b 100644
--- a/src/math/vector3f.cc
+++ b/src/math/vector3f.cc
@@ -12,20 +12,17 @@
namespace math
{
-Vector3f::Vector3f() :
- x(coord[0]), y(coord[1]), z(coord[2])
+Vector3f::Vector3f()
{
clear();
}
-Vector3f::Vector3f(const Vector3f &other) :
- x(coord[0]), y(coord[1]), z(coord[2])
+Vector3f::Vector3f(const Vector3f &other)
{
assign(other);
}
-Vector3f::Vector3f(const float x, const float y, const float z) :
- x(coord[0]), y(coord[1]), z(coord[2])
+Vector3f::Vector3f(const float x, const float y, const float z)
{
assign(x, y, z);
}
diff --git a/src/math/vector3f.h b/src/math/vector3f.h
index 82b818e..99a665f 100644
--- a/src/math/vector3f.h
+++ b/src/math/vector3f.h
@@ -114,6 +114,27 @@ public:
return coord[index];
}
+ /// x coordinate
+ inline float x() const { return coord[0]; }
+
+ /// y coordinate
+ inline float y() const { return coord[1]; }
+
+ /// z coordinate
+ inline float z() const { return coord[2]; }
+
+ /// mutable reference to the x coordinate
+ inline float & get_x() { return coord[0]; }
+
+ /// mutable reference to the y coordinate
+ inline float & get_y() { return coord[1]; }
+
+ /// mutable reference to the z coordinate
+ inline float & get_z() { return coord[2]; }
+
+ /// a pointer to the internal data
+ inline float *ptr() const { return (float *) coord; }
+
/// cartesian length
float length() const;
@@ -125,11 +146,6 @@ public:
/// vector must not be (0, 0, 0)
void normalize();
- /// a pointer to the internal data
- inline float *ptr() const {
- return (float *) coord;
- }
-
/* static functions */
/// Returns the unity vector on the X-axis
@@ -158,11 +174,7 @@ public:
static inline Vector3f normalized(const Vector3f & vector) {
return (vector / vector.length());
}
-
- float &x;
- float &y;
- float &z;
-
+
private:
float coord[3];
};
diff --git a/src/model/asefile.cc b/src/model/asefile.cc
index 664a3f7..17169f4 100644
--- a/src/model/asefile.cc
+++ b/src/model/asefile.cc
@@ -270,11 +270,11 @@ size_t count = 0;
math::Vector3f *t2 = ase_tvertexlist[c];
if (triangle) {
if (t0)
- triangle->t0().assign(t0->x, 1.0f - t0->y);
+ triangle->t0().assign(t0->x(), 1.0f - t0->y());
if (t1)
- triangle->t1().assign(t1->x, 1.0f - t1->y);
+ triangle->t1().assign(t1->x(), 1.0f - t1->y());
if (t2)
- triangle->t2().assign(t2->x, 1.0f - t2->y);
+ triangle->t2().assign(t2->x(), 1.0f - t2->y());
}
count++;
}
diff --git a/src/model/face.cc b/src/model/face.cc
index c6c3269..7626fac 100644
--- a/src/model/face.cc
+++ b/src/model/face.cc
@@ -28,7 +28,7 @@ Face::Face(Vector3f const & point0, Vector3f const &point1, Vector3f const &poin
face_point[2] = point2;
face_normal = crossproduct((face_point[1] - face_point[0]) , (face_point[2] - face_point[0]));
- pd = -1 * (face_normal.x * face_point[0].x + face_normal.y * face_point[0].y + face_normal.z * face_point[0].z);
+ pd = -1 * (face_normal.x() * face_point[0].x() + face_normal.y() * face_point[0].y() + face_normal.z() * face_point[0].z());
}
Face::Face(Face const & other)
@@ -37,7 +37,7 @@ Face::Face(Face const & other)
this->face_point[i] = other.face_point[i];
face_normal = crossproduct((face_point[1] - face_point[0]) , (face_point[2] - face_point[0]));
- pd = -1 * (face_normal.x * face_point[0].x + face_normal.y * face_point[0].y + face_normal.z * face_point[0].z);
+ pd = -1 * (face_normal.x() * face_point[0].x() + face_normal.y() * face_point[0].y() + face_normal.z() * face_point[0].z());
}
}
diff --git a/src/model/fragment.cc b/src/model/fragment.cc
index 8c3481c..ab0f9fa 100644
--- a/src/model/fragment.cc
+++ b/src/model/fragment.cc
@@ -48,7 +48,7 @@ size_t Fragment::add_vertex(math::Vector3f const & vertex, math::Vector3f const
size_t Fragment::add_vertex(math::Vector3f const & vertex, math::Vector3f const &normal, math::Vector2f const &texcoord, bool detail)
{
- size_t n = VertexArray::instance()->add_vertex(vertex, normal, texcoord.x, texcoord.y);
+ size_t n = VertexArray::instance()->add_vertex(vertex, normal, texcoord.x(), texcoord.y());
if (n) {
if (detail)
fragment_detail_size += n;
diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc
index 54f6d78..cc96051 100644
--- a/src/model/mapfile.cc
+++ b/src/model/mapfile.cc
@@ -131,8 +131,8 @@ void face_texture_verts(Face &face, const math::Vector2f &tex_shift, const float
const math::Vector2f map_texture_coords(Face *face, const math::Vector3f &v)
{
return math::Vector2f (
- (face->tex_shift().x + math::dotproduct(face->tex_vec(0), v)) / face->material()->size().width(),
- (face->tex_shift().y + math::dotproduct(face->tex_vec(1), v)) / face->material()->size().height()
+ (face->tex_shift().x() + math::dotproduct(face->tex_vec(0), v)) / face->material()->size().width(),
+ (face->tex_shift().y() + math::dotproduct(face->tex_vec(1), v)) / face->material()->size().height()
);
}
@@ -446,9 +446,9 @@ void MapFile::make_brushface(Face *face)
// calculate initial vertices on the bounding box
// check if the face is x-axis oriented
- if ((fabsf(face->normal().x) >= fabsf(face->normal().y)) && (fabsf(face->normal().x) >= fabsf(face->normal().z))) {
+ if ((fabsf(face->normal().x()) >= fabsf(face->normal().y())) && (fabsf(face->normal().x()) >= fabsf(face->normal().z()))) {
- if (face->normal().x > MIN_DELTA) {
+ if (face->normal().x() > MIN_DELTA) {
vl.push_back(new math::Vector3f(0, -MAX_BOUNDS, -MAX_BOUNDS));
vl.push_back(new math::Vector3f(0, -MAX_BOUNDS, MAX_BOUNDS));
vl.push_back(new math::Vector3f(0, MAX_BOUNDS, MAX_BOUNDS));
@@ -461,17 +461,17 @@ void MapFile::make_brushface(Face *face)
}
// calculate the x coordinate of each face vertex
for (std::vector<Vector3f *>::iterator it = vl.begin(); it != vl.end(); it++) {
- (*it)->x = (-face->d() -
- face->normal().z * (*it)->z -
- face->normal().y * (*it)->y) /
- face->normal().x;
+ (*it)->get_x() = (-face->d() -
+ face->normal().z() * (*it)->z() -
+ face->normal().y() * (*it)->y()) /
+ face->normal().x();
}
}
// check if the face is y-axis oriented
- else if ((fabsf(face->normal().y) >= fabsf(face->normal().x)) && (fabsf(face->normal().y) >= fabsf(face->normal().z))) {
+ else if ((fabsf(face->normal().y()) >= fabsf(face->normal().x())) && (fabsf(face->normal().y()) >= fabsf(face->normal().z()))) {
- if (face->normal().y > MIN_DELTA) {
+ if (face->normal().y() > MIN_DELTA) {
vl.push_back(new Vector3f(MAX_BOUNDS, 0, -MAX_BOUNDS));
vl.push_back(new Vector3f(MAX_BOUNDS, 0, MAX_BOUNDS));
vl.push_back(new Vector3f(-MAX_BOUNDS, 0, MAX_BOUNDS));
@@ -485,17 +485,17 @@ void MapFile::make_brushface(Face *face)
// calculate the x coordinate of each face vertex
for (std::vector<Vector3f *>::iterator it = vl.begin(); it != vl.end(); it++) {
- (*it)->y = (-face->d() -
- face->normal().z * (*it)->z -
- face->normal().x * (*it)->x) /
- face->normal().y;
+ (*it)->get_y() = (-face->d() -
+ face->normal().z() * (*it)->z() -
+ face->normal().x() * (*it)->x()) /
+ face->normal().y();
}
}
// face must be z-axis oriented
else {
- if (face->normal().z > MIN_DELTA) {
+ if (face->normal().z() > MIN_DELTA) {
vl.push_back(new Vector3f(-MAX_BOUNDS, -MAX_BOUNDS, 0));
vl.push_back(new Vector3f(-MAX_BOUNDS, MAX_BOUNDS, 0));
vl.push_back(new Vector3f(MAX_BOUNDS, MAX_BOUNDS, 0));
@@ -509,10 +509,10 @@ void MapFile::make_brushface(Face *face)
// calculate the x coordinate of each face vertex
for (std::vector<Vector3f *>::iterator it = vl.begin(); it != vl.end(); it++) {
- (*it)->z = (-face->d() -
- face->normal().x * (*it)->x -
- face->normal().y * (*it)->y) /
- face->normal().z;
+ (*it)->get_z() = (-face->d() -
+ face->normal().x() * (*it)->x() -
+ face->normal().y() * (*it)->y()) /
+ face->normal().z();
}
}
@@ -529,7 +529,7 @@ void MapFile::make_brushface(Face *face)
Vector3f pn = crossproduct(plane->point(1)-plane->point(0), plane->point(2)-plane->point(0));
Vector3f t = crossproduct(fn, pn);
- if ((t.x == 0) && (t.y == 0) && (t.z == 0)) {
+ if ((t.x() == 0) && (t.y() == 0) && (t.z() == 0)) {
continue;
}
@@ -552,7 +552,7 @@ void MapFile::make_brushface(Face *face)
prev = *vl.back();
}
- if ((v.x*plane->normal().x + v.y*plane->normal().y + v.z*plane->normal().z +plane->d()) < MIN_DELTA) {
+ if ((v.x() * plane->normal().x() + v.y() * plane->normal().y() + v.z() * plane->normal().z() + plane->d()) < MIN_DELTA) {
// find current
std::vector<Vector3f *>::iterator vit = vl.begin();
@@ -561,14 +561,14 @@ void MapFile::make_brushface(Face *face)
}
// check if prev - v intersects with plane
- if ((prev.x*plane->normal().x + prev.y*plane->normal().y + prev.z*plane->normal().z + plane->d()) > MIN_DELTA) {
+ if ((prev.x() * plane->normal().x() + prev.y() * plane->normal().y() + prev.z() * plane->normal().z() + plane->d()) > MIN_DELTA) {
// calculate intersection
- float t1 = -plane->normal().x * prev.x - plane->normal().y * prev.y - plane->normal().z * prev.z -plane->d();
- float t2 = (plane->normal().x * v.x - plane->normal().x * prev.x +
- plane->normal().y * v.y - plane->normal().y * prev.y +
- plane->normal().z * v.z - plane->normal().z * prev.z);
-
+ float t1 = -plane->normal().x() * prev.x() - plane->normal().y() * prev.y() - plane->normal().z() * prev.z() -plane->d();
+ float t2 = (plane->normal().x() * v.x() - plane->normal().x() * prev.x() +
+ plane->normal().y() * v.y() - plane->normal().y() * prev.y() +
+ plane->normal().z() * v.z() - plane->normal().z() * prev.z());
+
Vector3f *s = new Vector3f;
if (t2 == 0) {
@@ -584,14 +584,14 @@ void MapFile::make_brushface(Face *face)
}
// check if next - v intersects with plane
- if ((next.x*plane->normal().x + next.y*plane->normal().y + next.z*plane->normal().z + plane->d()) > MIN_DELTA) {
+ if ((next.x() * plane->normal().x() + next.y() * plane->normal().y() + next.z() * plane->normal().z() + plane->d()) > MIN_DELTA) {
// calculate intersection
- float t1 = -plane->normal().x * v.x - plane->normal().y * v.y - plane->normal().z * v.z -plane->d();
- float t2 = (plane->normal().x * next.x - plane->normal().x * v.x +
- plane->normal().y * next.y - plane->normal().y * v.y +
- plane->normal().z * next.z - plane->normal().z * v.z);
- //cout << "next t2 " << t2 << std::endl;
+ float t1 = -plane->normal().x() * v.x() - plane->normal().y() * v.y() - plane->normal().z() * v.z() -plane->d();
+ float t2 = (plane->normal().x() * next.x() - plane->normal().x() * v.x() +
+ plane->normal().y() * next.y() - plane->normal().y() * v.y() +
+ plane->normal().z() * next.z() - plane->normal().z() * v.z());
+
Vector3f *s = new Vector3f;
if (t2 == 0) {
diff --git a/src/render/camera.cc b/src/render/camera.cc
index 54c4547..913adfb 100644
--- a/src/render/camera.cc
+++ b/src/render/camera.cc
@@ -289,8 +289,8 @@ void Camera::frame(float seconds)
}
if (core::localcontrol()->model()) {
- camera_target -= camera_axis.forward() * math::max(FRUSTUMFRONT / WORLDSCALE, core::localcontrol()->model()->maxbbox().x);
- camera_target += camera_axis.up() * math::max(FRUSTUMFRONT / WORLDSCALE, core::localcontrol()->model()->maxbbox().z * 2.0f);
+ camera_target -= camera_axis.forward() * math::max(FRUSTUMFRONT / WORLDSCALE, core::localcontrol()->model()->maxbbox().x());
+ camera_target += camera_axis.up() * math::max(FRUSTUMFRONT / WORLDSCALE, core::localcontrol()->model()->maxbbox().z() * 2.0f);
} else {
camera_target -= camera_axis.forward() * math::max (FRUSTUMFRONT / WORLDSCALE, FRUSTUMFRONT / WORLDSCALE + core::localcontrol()->radius());
camera_target += camera_axis.up() * math::max (FRUSTUMFRONT / WORLDSCALE, FRUSTUMFRONT / WORLDSCALE + core::localcontrol()->radius());
@@ -322,7 +322,7 @@ void Camera::frame(float seconds)
camera_axis.assign(target_axis);
if (core::localcontrol()->model()) {
- camera_target += (core::localcontrol()->model()->maxbbox().x) *
+ camera_target += (core::localcontrol()->model()->maxbbox().x()) *
core::localcontrol()->axis().forward();
} else {
camera_target += (core::localcontrol()->radius()) *
diff --git a/src/render/draw.cc b/src/render/draw.cc
index e9123cd..4dc6e53 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -823,30 +823,30 @@ void draw_model_bbox(model::Model *model)
{
// top
gl::begin(gl::LineLoop);
- gl::vertex(model->model_maxbbox.x, model->model_maxbbox.y, model->model_maxbbox.z);
- gl::vertex(model->model_minbbox.x, model->model_maxbbox.y, model->model_maxbbox.z);
- gl::vertex(model->model_minbbox.x, model->model_minbbox.y, model->model_maxbbox.z);
- gl::vertex(model->model_maxbbox.x, model->model_minbbox.y, model->model_maxbbox.z);
+ gl::vertex(model->model_maxbbox.x(), model->model_maxbbox.y(), model->model_maxbbox.z());
+ gl::vertex(model->model_minbbox.x(), model->model_maxbbox.y(), model->model_maxbbox.z());
+ gl::vertex(model->model_minbbox.x(), model->model_minbbox.y(), model->model_maxbbox.z());
+ gl::vertex(model->model_maxbbox.x(), model->model_minbbox.y(), model->model_maxbbox.z());
gl::end();
// bottom
gl::begin(gl::LineLoop);
- gl::vertex(model->model_maxbbox.x, model->model_maxbbox.y, model->model_minbbox.z);
- gl::vertex(model->model_minbbox.x, model->model_maxbbox.y, model->model_minbbox.z);
- gl::vertex(model->model_minbbox.x, model->model_minbbox.y, model->model_minbbox.z);
- gl::vertex(model->model_maxbbox.x, model->model_minbbox.y, model->model_minbbox.z);
+ gl::vertex(model->model_maxbbox.x(), model->model_maxbbox.y(), model->model_minbbox.z());
+ gl::vertex(model->model_minbbox.x(), model->model_maxbbox.y(), model->model_minbbox.z());
+ gl::vertex(model->model_minbbox.x(), model->model_minbbox.y(), model->model_minbbox.z());
+ gl::vertex(model->model_maxbbox.x(), model->model_minbbox.y(), model->model_minbbox.z());
gl::end();
// body
gl::begin(gl::Lines);
- gl::vertex(model->model_maxbbox.x, model->model_maxbbox.y, model->model_maxbbox.z);
- gl::vertex(model->model_maxbbox.x, model->model_maxbbox.y, model->model_minbbox.z);
- gl::vertex(model->model_minbbox.x, model->model_maxbbox.y, model->model_maxbbox.z);
- gl::vertex(model->model_minbbox.x, model->model_maxbbox.y, model->model_minbbox.z);
- gl::vertex(model->model_minbbox.x, model->model_minbbox.y, model->model_maxbbox.z);
- gl::vertex(model->model_minbbox.x, model->model_minbbox.y, model->model_minbbox.z);
- gl::vertex(model->model_maxbbox.x, model->model_minbbox.y, model->model_maxbbox.z);
- gl::vertex(model->model_maxbbox.x, model->model_minbbox.y, model->model_minbbox.z);
+ gl::vertex(model->model_maxbbox.x(), model->model_maxbbox.y(), model->model_maxbbox.z());
+ gl::vertex(model->model_maxbbox.x(), model->model_maxbbox.y(), model->model_minbbox.z());
+ gl::vertex(model->model_minbbox.x(), model->model_maxbbox.y(), model->model_maxbbox.z());
+ gl::vertex(model->model_minbbox.x(), model->model_maxbbox.y(), model->model_minbbox.z());
+ gl::vertex(model->model_minbbox.x(), model->model_minbbox.y(), model->model_maxbbox.z());
+ gl::vertex(model->model_minbbox.x(), model->model_minbbox.y(), model->model_minbbox.z());
+ gl::vertex(model->model_maxbbox.x(), model->model_minbbox.y(), model->model_maxbbox.z());
+ gl::vertex(model->model_maxbbox.x(), model->model_minbbox.y(), model->model_minbbox.z());
gl::end();
}
@@ -1180,8 +1180,8 @@ void draw_pass_spacegrid()
float s = 1.0f / gridsize;
float z = -4.0f;
- float dx = Camera::target().x - floorf(Camera::target().x);
- float dy = Camera::target().y - floorf(Camera::target().y);
+ float dx = Camera::target().x() - floorf(Camera::target().x());
+ float dy = Camera::target().y() - floorf(Camera::target().y());
gl::push();
gl::translate(Camera::target());
@@ -1360,29 +1360,29 @@ void draw_target(core::Entity *entity)
// top
gl::begin(gl::LineLoop);
- gl::vertex(maxbox.x, maxbox.y, maxbox.z);
- gl::vertex(minbox.x, maxbox.y, maxbox.z);
- gl::vertex(minbox.x, minbox.y, maxbox.z);
- gl::vertex(maxbox.x, minbox.y, maxbox.z);
+ gl::vertex(maxbox.x(), maxbox.y(), maxbox.z());
+ gl::vertex(minbox.x(), maxbox.y(), maxbox.z());
+ gl::vertex(minbox.x(), minbox.y(), maxbox.z());
+ gl::vertex(maxbox.x(), minbox.y(), maxbox.z());
gl::end();
// bottom
gl::begin(gl::LineLoop);
- gl::vertex(maxbox.x, maxbox.y, minbox.z);
- gl::vertex(minbox.x, maxbox.y, minbox.z);
- gl::vertex(minbox.x, minbox.y, minbox.z);
- gl::vertex(maxbox.x, minbox.y, minbox.z);
+ gl::vertex(maxbox.x(), maxbox.y(), minbox.z());
+ gl::vertex(minbox.x(), maxbox.y(), minbox.z());
+ gl::vertex(minbox.x(), minbox.y(), minbox.z());
+ gl::vertex(maxbox.x(), minbox.y(), minbox.z());
gl::end();
gl::begin(gl::Lines);
- gl::vertex(maxbox.x, maxbox.y, maxbox.z);
- gl::vertex(maxbox.x, maxbox.y, minbox.z);
- gl::vertex(minbox.x, maxbox.y, maxbox.z);
- gl::vertex(minbox.x, maxbox.y, minbox.z);
- gl::vertex(minbox.x, minbox.y, maxbox.z);
- gl::vertex(minbox.x, minbox.y, minbox.z);
- gl::vertex(maxbox.x, minbox.y, maxbox.z);
- gl::vertex(maxbox.x, minbox.y, minbox.z);
+ gl::vertex(maxbox.x(), maxbox.y(), maxbox.z());
+ gl::vertex(maxbox.x(), maxbox.y(), minbox.z());
+ gl::vertex(minbox.x(), maxbox.y(), maxbox.z());
+ gl::vertex(minbox.x(), maxbox.y(), minbox.z());
+ gl::vertex(minbox.x(), minbox.y(), maxbox.z());
+ gl::vertex(minbox.x(), minbox.y(), minbox.z());
+ gl::vertex(maxbox.x(), minbox.y(), maxbox.z());
+ gl::vertex(maxbox.x(), minbox.y(), minbox.z());
gl::end();
}
diff --git a/src/render/dust.cc b/src/render/dust.cc
index 89ef630..a975e5f 100644
--- a/src/render/dust.cc
+++ b/src/render/dust.cc
@@ -99,9 +99,9 @@ void Dust::draw(math::Color const &dustcolor)
dust = (float *) malloc(sizeof(float) * dustsize* 3);
for (size_t i = 0; i < dustsize; i++) {
- dust[i*3] = core::localcontrol()->location().x + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius() * 2.0f);
- dust[i*3+1] = core::localcontrol()->location().y + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius() * 2.0f);
- dust[i*3+2] = core::localcontrol()->location().z + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius() * 2.0f);
+ dust[i*3] = core::localcontrol()->location().x() + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius() * 2.0f);
+ dust[i*3+1] = core::localcontrol()->location().y() + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius() * 2.0f);
+ dust[i*3+2] = core::localcontrol()->location().z() + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius() * 2.0f);
}
}
diff --git a/src/ui/console.cc b/src/ui/console.cc
index 5f7313b..4fcba7d 100644
--- a/src/ui/console.cc
+++ b/src/ui/console.cc
@@ -181,14 +181,14 @@ void Console::draw()
}
math::Vector2f s(size());
- s.x -= 8;
- s.y -= 8;
+ s[0] -= 8;
+ s[1] -= 8;
console_scrollpane->set_location(4, 4);
- console_scrollpane->set_size(s.x, s.y - font()->height());
+ console_scrollpane->set_size(s.width(), s.height() - font()->height());
console_input->set_location(4, height() - font()->height() -4);
- console_input->set_size(s.x, font()->height());
+ console_input->set_size(s.width(), font()->height());
math::Color fancy(palette()->fancy());
fancy.a = 0.5f;
@@ -196,8 +196,8 @@ void Console::draw()
std::string version(core::name() + ' ' + core::version());
s.assign(version.size() * font()->width(), font()->height());
math::Vector2f l(global_location());
- l.x += width() - s.width() -4;
- l.y += height() - s.height() -4;
+ l[0] += width() - s.width() -4;
+ l[1] += height() - s.height() -4;
paint::text(l, s, font(), version);
}
diff --git a/src/ui/font.cc b/src/ui/font.cc
index 9d721fd..1523eeb 100644
--- a/src/ui/font.cc
+++ b/src/ui/font.cc
@@ -31,12 +31,12 @@ void Font::set_size(const math::Vector2f &size)
void Font::set_width(const float width)
{
- font_size.x = width;
+ font_size.get_x() = width;
}
void Font::set_height(const float height)
{
- font_size.y = height;
+ font_size.get_y() = height;
}
void Font::set_name(const char *name)
diff --git a/src/ui/font.h b/src/ui/font.h
index 1261427..4fb6310 100644
--- a/src/ui/font.h
+++ b/src/ui/font.h
@@ -28,11 +28,11 @@ public:
}
inline float width() const {
- return font_size.x;
+ return font_size.width();
}
inline float height() const {
- return font_size.y;
+ return font_size.height();
}
void set_size(const float width, const float height);
diff --git a/src/ui/inputbox.cc b/src/ui/inputbox.cc
index 08b85be..07a0a7e 100644
--- a/src/ui/inputbox.cc
+++ b/src/ui/inputbox.cc
@@ -76,7 +76,7 @@ void InputBox::draw()
// draw the prompt
if (prompt_width) {
paint::text(v, size(), font(), input_prompt);
- v.x += prompt_width * font()->width();
+ v[0] += prompt_width * font()->width();
}
paint::color(palette()->text());
@@ -110,7 +110,7 @@ void InputBox::draw()
}
// draw the part behind the cursor
- v.x += draw_width * font()->width();
+ v[0] += draw_width * font()->width();
if (input_pos < input_text.size()) {
if (input_pos > 1 && aux::is_color_code(input_text.c_str() + input_pos -1)) {
paint::color_code(input_text[input_pos]);
diff --git a/src/ui/modelview.cc b/src/ui/modelview.cc
index e3816cd..1e89397 100755
--- a/src/ui/modelview.cc
+++ b/src/ui/modelview.cc
@@ -87,13 +87,13 @@ void ModelView::draw()
math ::Vector2f center(global_location());
- center.x += width() * 0.5f;
- center.y += height() * 0.5f;
+ center[0] += width() * 0.5f;
+ center[1] += height() * 0.5f;
gl::clear(GL_DEPTH_BUFFER_BIT);
// gl 3d mode
- render::Camera::frustum_default(model->radius() * modelview_zoom, center.x, center.y);
+ render::Camera::frustum_default(model->radius() * modelview_zoom, center.x(), center.y());
gl::disable(GL_BLEND);
gl::depthmask(GL_TRUE); // enable writing to the depth buffer
diff --git a/src/ui/paint.cc b/src/ui/paint.cc
index e6f2402..576484e 100644
--- a/src/ui/paint.cc
+++ b/src/ui/paint.cc
@@ -42,10 +42,10 @@ void border(const math::Vector2f &location, const math::Vector2f &size)
using namespace gl;
begin(LineLoop);
- vertex(location.x +1 , location.y);
- vertex(location.x + size.x, location.y);
- vertex(location.x + size.x, location.y + size.y -1);
- vertex(location.x +1, location.y + size.y - 1);
+ vertex(location.x(), location.y());
+ vertex(location.x() + size.width(), location.y());
+ vertex(location.x() + size.width(), location.y() + size.height());
+ vertex(location.x(), location.y() + size.height());
end();
}
@@ -54,10 +54,10 @@ void rectangle(const math::Vector2f &location, const math::Vector2f &size)
using namespace gl;
begin(Quads);
- vertex(location.x +1 , location.y);
- vertex(location.x + size.x, location.y);
- vertex(location.x + size.x, location.y + size.y -1);
- vertex(location.x +1, location.y + size.y - 1);
+ vertex(location.x(), location.y());
+ vertex(location.x() + size.width(), location.y());
+ vertex(location.x() + size.width(), location.y() + size.height());
+ vertex(location.x(), location.y() + size.height());
end();
}
@@ -70,16 +70,17 @@ void bitmap(const math::Vector2f &location, const math::Vector2f &size, std::str
gl::begin(gl::Quads);
glTexCoord2f(0.0f, 0.0f);
- gl::vertex(location.x +1 , location.y);
-
+ gl::vertex(location.x(), location.y());
+
glTexCoord2f(1.0f, 0.0f);
- gl::vertex(location.x + size.x, location.y);
-
+ gl::vertex(location.x() + size.width(), location.y());
+
glTexCoord2f(1.0f, 1.0f);
- gl::vertex(location.x + size.x, location.y + size.y -1);
-
+ gl::vertex(location.x() + size.width(), location.y() + size.height());
+
glTexCoord2f(0.0f, 1.0f);
- gl::vertex(location.x +1, location.y + size.y - 1);
+ gl::vertex(location.x(), location.y() + size.height());
+
gl::end();
gl::disable(GL_TEXTURE_2D);
@@ -112,29 +113,29 @@ void label(const math::Vector2f &location, const math::Vector2f &size, const Fon
switch (align_horizontal) {
case AlignLeft:
- v.x += font->width();
+ v[0] += font->width();
break;
case AlignHCenter:
- v.x += (size.x - text_width) / 2.0f;
+ v[0] += (size.width() - text_width) / 2.0f;
break;
case AlignRight:
- v.x += size.x - text_width - font->width();
+ v[0] += size.width() - text_width - font->width();
break;
}
switch (align_vertical) {
case AlignTop:
- v.y += font->height()*0.5f;
+ v[1] += font->height()*0.5f;
break;
case AlignVCenter:
- v.y += (size.y - text_height) / 2.0f;
+ v[1] += (size.height() - text_height) / 2.0f;
break;
case AlignBottom:
- v.y += size.y - text_height - font->height()*0.5f;
+ v[1] += size.height() - text_height - font->height()*0.5f;
break;
}
- render::Text::draw(v.x, v.y, text);
+ render::Text::draw(v.x(), v.y(), text);
// disable OpenGL textures
gl::disable(GL_TEXTURE_2D);
@@ -149,7 +150,7 @@ void text(const math::Vector2f &location, const math::Vector2f &size, const Font
// enable OpenGL textures
gl::enable(GL_TEXTURE_2D);
- render::Text::draw(location.x, location.y, text);
+ render::Text::draw(location.x(), location.y(), text);
// disable OpenGL textures
gl::disable(GL_TEXTURE_2D);
@@ -164,7 +165,7 @@ void text(const math::Vector2f &location, const math::Vector2f &size, const Font
// enable OpenGL textures
gl::enable(GL_TEXTURE_2D);
- render::Text::draw(location.x, location.y, textstream);
+ render::Text::draw(location.x(), location.y(), textstream);
// disable OpenGL textures
gl::disable(GL_TEXTURE_2D);
diff --git a/src/ui/scrollpane.cc b/src/ui/scrollpane.cc
index d660663..20325d8 100644
--- a/src/ui/scrollpane.cc
+++ b/src/ui/scrollpane.cc
@@ -171,7 +171,7 @@ void ScrollPane::draw()
int i = (int) lines.size();
for (ui::Text::iterator it = lines.begin(); it != lines.end(); it++) {
if (i <= text_height) {
- render::Text::draw(gl.x, gl.y + y, (*it));
+ render::Text::draw(gl.x(), gl.y() + y, (*it));
y += font()->height();
}
i--;
@@ -179,7 +179,7 @@ void ScrollPane::draw()
} else {
y = height() - font()->height();
for (ui::Text::reverse_iterator rit = lines.rbegin(); (y >= 0) && (rit != lines.rend()); ++rit) {
- render::Text::draw(gl.x, gl.y + y, (*rit));
+ render::Text::draw(gl.x(), gl.y() + y, (*rit));
y -= font()->height();
}
}
diff --git a/src/ui/ui.cc b/src/ui/ui.cc
index b60a65e..82d3990 100644
--- a/src/ui/ui.cc
+++ b/src/ui/ui.cc
@@ -568,7 +568,7 @@ void UI::draw_pointer()
c.a = 0.5f;
}
paint::color(c);
- math::Vector2f pos(mouse_cursor.x - pointer_size * 0.5f, mouse_cursor.y - pointer_size * 0.5f);
+ math::Vector2f pos(mouse_cursor.x() - pointer_size * 0.5f, mouse_cursor.y() - pointer_size * 0.5f);
math::Vector2f s(pointer_size, pointer_size);
std::string texture("pointers/");
@@ -576,12 +576,12 @@ void UI::draw_pointer()
if (mouse_pointer_animated) {
gl::push();
- gl::translate(mouse_cursor.x, mouse_cursor.y, 0);
+ gl::translate(mouse_cursor.x(), mouse_cursor.y(), 0);
float angle = core::application()->time()* 0.75f - floorf(core::application()->time() * 0.75f);
angle *= 360.0f;
gl::rotate(angle, math::Vector3f(0, 0, 1.0f));
- gl::translate(-mouse_cursor.x, -mouse_cursor.y, 0);
+ gl::translate(-mouse_cursor.x(), -mouse_cursor.y(), 0);
}
paint::bitmap(pos, s, texture);
diff --git a/src/ui/widget.cc b/src/ui/widget.cc
index cc53c9f..b1157d5 100644
--- a/src/ui/widget.cc
+++ b/src/ui/widget.cc
@@ -232,12 +232,12 @@ void Widget::set_size(const math::Vector2f &size)
void Widget::set_width(const float w)
{
- widget_size.x = w;
+ widget_size[0] = w;
}
void Widget::set_height(const float h)
{
- widget_size.y = h;
+ widget_size[1] = h;
}
Widget::Children::iterator Widget::find_child(Widget *child)
diff --git a/src/ui/widget.h b/src/ui/widget.h
index 2de7a3d..20e4ac4 100644
--- a/src/ui/widget.h
+++ b/src/ui/widget.h
@@ -55,7 +55,7 @@ public:
* @see location()
*/
inline float left() const {
- return widget_location.x;
+ return widget_location.x();
}
/// x coordinate of the right of the widget
@@ -64,7 +64,7 @@ public:
* @see size()
*/
inline float right() const {
- return widget_location.x + widget_size.x;
+ return widget_location.x() + widget_size.width();
}
/// y coordinate of the top of the widget
@@ -72,7 +72,7 @@ public:
* @see location()
*/
inline float top() const {
- return widget_location.y;
+ return widget_location.y();
}
/// y coordinate of the bottom of the widget
@@ -81,7 +81,7 @@ public:
* @see size()
*/
inline float bottom() const {
- return widget_location.y + widget_size.y;
+ return widget_location.y() + widget_size.height();
}
/// width of the widget in pixels
@@ -89,7 +89,7 @@ public:
* @see size()
*/
inline float width() const {
- return widget_size.x;
+ return widget_size.width();
}
/// height of the widget in pixels
@@ -97,7 +97,7 @@ public:
* @see size()
*/
inline float height() const {
- return widget_size.y;
+ return widget_size.height();
}
/// widget label