zoomedit:
* Removed unused vector maths * Added missing const to set*-methods in Triangle
This commit is contained in:
parent
36d892d1f0
commit
094c72221e
7 changed files with 8 additions and 204 deletions
|
@ -1,3 +1,3 @@
|
||||||
noinst_LTLIBRARIES = libdata.la
|
noinst_LTLIBRARIES = libdata.la
|
||||||
|
|
||||||
libdata_la_SOURCES = Info.cpp Gate.cpp Level.cpp Room.cpp Texture.cpp Triangle.cpp Vector.cpp Vertex.cpp
|
libdata_la_SOURCES = Info.cpp Gate.cpp Level.cpp Room.cpp Texture.cpp Triangle.cpp
|
||||||
|
|
|
@ -44,7 +44,7 @@ CONFIG_CLEAN_FILES =
|
||||||
LTLIBRARIES = $(noinst_LTLIBRARIES)
|
LTLIBRARIES = $(noinst_LTLIBRARIES)
|
||||||
libdata_la_LIBADD =
|
libdata_la_LIBADD =
|
||||||
am_libdata_la_OBJECTS = Info.lo Gate.lo Level.lo Room.lo Texture.lo \
|
am_libdata_la_OBJECTS = Info.lo Gate.lo Level.lo Room.lo Texture.lo \
|
||||||
Triangle.lo Vector.lo Vertex.lo
|
Triangle.lo
|
||||||
libdata_la_OBJECTS = $(am_libdata_la_OBJECTS)
|
libdata_la_OBJECTS = $(am_libdata_la_OBJECTS)
|
||||||
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
|
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
|
||||||
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
||||||
|
@ -180,7 +180,7 @@ target_alias = @target_alias@
|
||||||
top_builddir = @top_builddir@
|
top_builddir = @top_builddir@
|
||||||
top_srcdir = @top_srcdir@
|
top_srcdir = @top_srcdir@
|
||||||
noinst_LTLIBRARIES = libdata.la
|
noinst_LTLIBRARIES = libdata.la
|
||||||
libdata_la_SOURCES = Info.cpp Gate.cpp Level.cpp Room.cpp Texture.cpp Triangle.cpp Vector.cpp Vertex.cpp
|
libdata_la_SOURCES = Info.cpp Gate.cpp Level.cpp Room.cpp Texture.cpp Triangle.cpp
|
||||||
all: all-am
|
all: all-am
|
||||||
|
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
|
@ -238,8 +238,6 @@ distclean-compile:
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Room.Plo@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Room.Plo@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Texture.Plo@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Texture.Plo@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Triangle.Plo@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Triangle.Plo@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Vector.Plo@am__quote@
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Vertex.Plo@am__quote@
|
|
||||||
|
|
||||||
.cpp.o:
|
.cpp.o:
|
||||||
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#define ZOOMEDIT_DATA_TRIANGLE_H_
|
#define ZOOMEDIT_DATA_TRIANGLE_H_
|
||||||
|
|
||||||
#include "Vertex.h"
|
#include "Vertex.h"
|
||||||
|
#include "Vector.h"
|
||||||
#include "TexCoords.h"
|
#include "TexCoords.h"
|
||||||
#include <libxml++/nodes/element.h>
|
#include <libxml++/nodes/element.h>
|
||||||
|
|
||||||
|
@ -52,7 +53,7 @@ class Triangle {
|
||||||
const Vertex& getVertex(unsigned int i) const {return vertices[i%3];}
|
const Vertex& getVertex(unsigned int i) const {return vertices[i%3];}
|
||||||
void setVertex(unsigned int i, const Vertex &v);
|
void setVertex(unsigned int i, const Vertex &v);
|
||||||
|
|
||||||
void setVertices(Vertex *v) {
|
void setVertices(const Vertex *v) {
|
||||||
for(int i = 0; i < 3; ++i)
|
for(int i = 0; i < 3; ++i)
|
||||||
setVertex(i, v[i]);
|
setVertex(i, v[i]);
|
||||||
}
|
}
|
||||||
|
@ -60,7 +61,7 @@ class Triangle {
|
||||||
const Vector& getNormal(unsigned int i) const {return normals[i%3];}
|
const Vector& getNormal(unsigned int i) const {return normals[i%3];}
|
||||||
void setNormal(unsigned int i, const Vector &n);
|
void setNormal(unsigned int i, const Vector &n);
|
||||||
|
|
||||||
void setNormals(Vector *n) {
|
void setNormals(const Vector *n) {
|
||||||
for(int i = 0; i < 3; ++i)
|
for(int i = 0; i < 3; ++i)
|
||||||
setNormal(i, n[i]);
|
setNormal(i, n[i]);
|
||||||
}
|
}
|
||||||
|
@ -68,7 +69,7 @@ class Triangle {
|
||||||
const TexCoords& getTexCoords(unsigned int i) const {return texCoords[i%3];}
|
const TexCoords& getTexCoords(unsigned int i) const {return texCoords[i%3];}
|
||||||
void setTexCoords(unsigned int i, const TexCoords &t);
|
void setTexCoords(unsigned int i, const TexCoords &t);
|
||||||
|
|
||||||
void setTexCoords(TexCoords *t) {
|
void setTexCoords(const TexCoords *t) {
|
||||||
for(int i = 0; i < 3; ++i)
|
for(int i = 0; i < 3; ++i)
|
||||||
setTexCoords(i, t[i]);
|
setTexCoords(i, t[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,96 +0,0 @@
|
||||||
/*
|
|
||||||
* Vector.cpp
|
|
||||||
*
|
|
||||||
* Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License as published by the
|
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
* See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Vector.h"
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
namespace ZoomEdit {
|
|
||||||
namespace Data {
|
|
||||||
|
|
||||||
float Vector::lengthSq() const {
|
|
||||||
return x*x + y*y + z*z;
|
|
||||||
}
|
|
||||||
|
|
||||||
float Vector::length() const {
|
|
||||||
return std::sqrt(lengthSq());
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector Vector::operator+(const Vector &v) const {
|
|
||||||
return Vector(x + v.x, y + v.y, z + v.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector Vector::operator-(const Vector &v) const {
|
|
||||||
return Vector(x - v.x, y - v.y, z - v.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
float Vector::operator*(const Vector &v) const {
|
|
||||||
return (x*v.x + y*v.y + z*v.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector Vector::operator*(float f) const {
|
|
||||||
return Vector(x*f, y*f, z*f);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector Vector::operator/(float f) const {
|
|
||||||
return Vector(x/f, y/f, z/f);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector Vector::operator%(const Vector &v) const {
|
|
||||||
return Vector(y*v.z-z*v.y, z*v.x-x*v.z, x*v.y-y*v.x);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector& Vector::operator+=(const Vector &v) {
|
|
||||||
x += v.x;
|
|
||||||
y += v.y;
|
|
||||||
z += v.z;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector& Vector::operator-=(const Vector &v) {
|
|
||||||
x -= v.x;
|
|
||||||
y -= v.y;
|
|
||||||
z -= v.z;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector& Vector::operator*=(float f) {
|
|
||||||
x *= f;
|
|
||||||
y *= f;
|
|
||||||
z *= f;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector& Vector::operator/=(float f) {
|
|
||||||
x /= f;
|
|
||||||
y /= f;
|
|
||||||
z /= f;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector& Vector::operator%=(const Vector &v) {
|
|
||||||
*this = *this % v;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -39,31 +39,6 @@ class Vector {
|
||||||
|
|
||||||
float getZ() const {return z;}
|
float getZ() const {return z;}
|
||||||
void setZ(float z0) {z = z0;}
|
void setZ(float z0) {z = z0;}
|
||||||
|
|
||||||
float lengthSq() const;
|
|
||||||
float length() const;
|
|
||||||
|
|
||||||
void normalize() {
|
|
||||||
if(lengthSq())
|
|
||||||
*this /= length();
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector operator+(const Vector &v) const;
|
|
||||||
Vector operator-(const Vector &v) const;
|
|
||||||
float operator*(const Vector &v) const;
|
|
||||||
|
|
||||||
Vector operator*(float f) const;
|
|
||||||
Vector operator/(float f) const;
|
|
||||||
|
|
||||||
Vector operator%(const Vector &v) const;
|
|
||||||
|
|
||||||
Vector& operator+=(const Vector &v);
|
|
||||||
Vector& operator-=(const Vector &v);
|
|
||||||
|
|
||||||
Vector& operator*=(float f);
|
|
||||||
Vector& operator/=(float f);
|
|
||||||
|
|
||||||
Vector& operator%=(const Vector &v);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
/*
|
|
||||||
* Vertex.cpp
|
|
||||||
*
|
|
||||||
* Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License as published by the
|
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
* See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Vertex.h"
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
namespace ZoomEdit {
|
|
||||||
namespace Data {
|
|
||||||
|
|
||||||
float Vertex::distanceSq(const Vertex &v) const {
|
|
||||||
return (x - v.x)*(x - v.x) + (y - v.y)*(y - v.y) + (z - v.z)*(z - v.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
float Vertex::distance(const Vertex &v) const {
|
|
||||||
return std::sqrt(distanceSq(v));
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector Vertex::operator-(const Vertex &v) const {
|
|
||||||
return Vector(x - v.x, y - v.y, z - v.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vertex Vertex::operator+(const Vector &v) const {
|
|
||||||
return Vertex(x + v.getX(), y + v.getY(), z + v.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
Vertex Vertex::operator-(const Vector &v) const {
|
|
||||||
return Vertex(x - v.getX(), y - v.getY(), z - v.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
Vertex& Vertex::operator+=(const Vector &v) {
|
|
||||||
x += v.getX();
|
|
||||||
y += v.getY();
|
|
||||||
z += v.getZ();
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vertex& Vertex::operator-=(const Vector &v) {
|
|
||||||
x -= v.getX();
|
|
||||||
y -= v.getY();
|
|
||||||
z -= v.getZ();
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -20,7 +20,7 @@
|
||||||
#ifndef ZOOMEDIT_DATA_VERTEX_H_
|
#ifndef ZOOMEDIT_DATA_VERTEX_H_
|
||||||
#define ZOOMEDIT_DATA_VERTEX_H_
|
#define ZOOMEDIT_DATA_VERTEX_H_
|
||||||
|
|
||||||
#include "Vector.h"
|
//#include "Vector.h"
|
||||||
|
|
||||||
namespace ZoomEdit {
|
namespace ZoomEdit {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
@ -41,17 +41,6 @@ class Vertex {
|
||||||
|
|
||||||
float getZ() const {return z;}
|
float getZ() const {return z;}
|
||||||
void setZ(float z0) {z = z0;}
|
void setZ(float z0) {z = z0;}
|
||||||
|
|
||||||
float distanceSq(const Vertex &v) const;
|
|
||||||
float distance(const Vertex &v) const;
|
|
||||||
|
|
||||||
Vector operator-(const Vertex &v) const;
|
|
||||||
|
|
||||||
Vertex operator+(const Vector &v) const;
|
|
||||||
Vertex operator-(const Vector &v) const;
|
|
||||||
|
|
||||||
Vertex& operator+=(const Vector &v);
|
|
||||||
Vertex& operator-=(const Vector &v);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue