Refactorizations:
- Removed TColor3, use sf::Color instead - Introduced more C++11 features: Use constexpr and defaulted/deleted functions - Made several member functions static or const - Removed dead code git-svn-id: https://svn.code.sf.net/p/extremetuxracer/code/trunk@631 0420edf4-82e4-42fc-9478-35b55e6d67a3master
parent
5c127f9d8c
commit
0a80bb84aa
|
@ -1,5 +1,5 @@
|
|||
Prerequisites:
|
||||
- Microsoft Visual Studio 2010 or later (Express/Community Edition is sufficient)
|
||||
- Microsoft Visual Studio 2013 or later (Express/Community Edition is sufficient)
|
||||
- SFML (include and lib path have to be set in Visual Studio)
|
||||
- gltext.h (can be downloaded here: http://www.opengl.org/registry/api/glext.h)
|
||||
|
||||
|
|
3
src/bh.h
3
src/bh.h
|
@ -55,6 +55,9 @@ GNU General Public License for more details.
|
|||
# define SEP "\\"
|
||||
# undef DrawText
|
||||
# undef GetObject
|
||||
# if _MSC_VER < 1900 // VS 2013 or older
|
||||
# define constexpr
|
||||
# endif
|
||||
#elif defined OS_WIN32_MINGW
|
||||
# include <dirent.h>
|
||||
# include <GL/glext.h>
|
||||
|
|
|
@ -602,7 +602,7 @@ bool CCourse::LoadTerrainTypes() {
|
|||
TerrList[i].starttex = SPIntN(*line, "starttex", -1);
|
||||
TerrList[i].tracktex = SPIntN(*line, "tracktex", -1);
|
||||
TerrList[i].stoptex = SPIntN(*line, "stoptex", -1);
|
||||
TerrList[i].col = SPColor3N(*line, "col", TColor3(255, 255, 255));
|
||||
TerrList[i].col = SPColor3N(*line, "col", sf::Color::White);
|
||||
TerrList[i].friction = SPFloatN(*line, "friction", 0.5f);
|
||||
TerrList[i].depth = SPFloatN(*line, "depth", 0.01f);
|
||||
TerrList[i].particles = SPBoolN(*line, "part", false);
|
||||
|
|
|
@ -42,7 +42,7 @@ struct TTerrType {
|
|||
std::string textureFile;
|
||||
TTexture* texture;
|
||||
std::size_t sound;
|
||||
TColor3 col;
|
||||
sf::Color col;
|
||||
|
||||
bool particles;
|
||||
bool trackmarks;
|
||||
|
|
|
@ -199,7 +199,7 @@ void CEnvironment::LoadLight(const std::string& EnvDir) {
|
|||
}
|
||||
}
|
||||
|
||||
void CEnvironment::DrawSkybox(const TVector3d& pos) {
|
||||
void CEnvironment::DrawSkybox(const TVector3d& pos) const {
|
||||
ScopedRenderMode rm(SKY);
|
||||
|
||||
#if defined (OS_LINUX)
|
||||
|
@ -300,7 +300,7 @@ void CEnvironment::DrawSkybox(const TVector3d& pos) {
|
|||
glPopMatrix();
|
||||
}
|
||||
|
||||
void CEnvironment::DrawFog() {
|
||||
void CEnvironment::DrawFog() const {
|
||||
if (!fog.is_on)
|
||||
return;
|
||||
|
||||
|
|
|
@ -76,10 +76,10 @@ public:
|
|||
CEnvironment();
|
||||
bool LoadEnvironmentList();
|
||||
void LoadEnvironment(std::size_t loc, std::size_t light);
|
||||
void DrawSkybox(const TVector3d& pos);
|
||||
void DrawSkybox(const TVector3d& pos) const;
|
||||
void SetupLight();
|
||||
void SetupFog();
|
||||
void DrawFog();
|
||||
void DrawFog() const;
|
||||
const sf::Color& ParticleColor() const { return fog.part_color; }
|
||||
std::size_t GetEnvIdx(const std::string& tag) const;
|
||||
std::size_t GetLightIdx(const std::string& tag) const;
|
||||
|
|
|
@ -20,13 +20,6 @@ GNU General Public License for more details.
|
|||
|
||||
#include "vectors.h"
|
||||
|
||||
struct TColor3 {
|
||||
uint8_t r, g, b;
|
||||
TColor3(uint8_t r_ = 0, uint8_t g_ = 0, uint8_t b_ = 0)
|
||||
: r(r_), g(g_), b(b_)
|
||||
{}
|
||||
};
|
||||
|
||||
enum TToolMode {
|
||||
NONE,
|
||||
TUXSHAPE,
|
||||
|
|
|
@ -186,7 +186,7 @@ unsigned int CFont::AutoSizeN(int rel_val) {
|
|||
return size;
|
||||
}
|
||||
|
||||
int CFont::AutoDistanceN(int rel_val) {
|
||||
int CFont::AutoDistanceN(int rel_val) const {
|
||||
float fact = (rel_val + 5) * 0.2f;
|
||||
float dist = curr_size * fact;
|
||||
return (int) dist;
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
|
||||
// auto
|
||||
unsigned int AutoSizeN(int rel_val); // rel_val = relative size, return: autosize
|
||||
int AutoDistanceN(int rel_val); // rel_val = relative dist
|
||||
int AutoDistanceN(int rel_val) const; // rel_val = relative dist
|
||||
|
||||
// draw
|
||||
void DrawString(float x, float y, const sf::String &s) const; // sf::String class
|
||||
|
@ -74,7 +74,7 @@ public:
|
|||
float GetTextWidth(const sf::String& text) const;
|
||||
float GetTextWidth(const sf::String& text, const std::string &fontname, unsigned int size) const;
|
||||
|
||||
std::vector<std::string> MakeLineList(const char *source, float width);
|
||||
static std::vector<std::string> MakeLineList(const char *source, float width);
|
||||
};
|
||||
|
||||
extern CFont FT;
|
||||
|
|
|
@ -199,7 +199,7 @@ void CKeyframe::InterpolateKeyframe(std::size_t idx, double frac, CCharShape *sh
|
|||
shape->RotateNode("right_ankle", 3, vv);
|
||||
}
|
||||
|
||||
void CKeyframe::CalcKeyframe(std::size_t idx, CCharShape *shape, const TVector3d& refpos_) {
|
||||
void CKeyframe::CalcKeyframe(std::size_t idx, CCharShape *shape, const TVector3d& refpos_) const {
|
||||
double vv;
|
||||
TVector3d pos;
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ public:
|
|||
void Update(float timestep);
|
||||
void UpdateTest(float timestep, CCharShape *shape);
|
||||
bool Load(const std::string& dir, const std::string& filename);
|
||||
void CalcKeyframe(std::size_t idx, CCharShape *shape, const TVector3d& refpos);
|
||||
void CalcKeyframe(std::size_t idx, CCharShape *shape, const TVector3d& refpos) const;
|
||||
|
||||
// test and editing
|
||||
TKeyframe *GetFrame(std::size_t idx);
|
||||
|
|
|
@ -22,7 +22,7 @@ GNU General Public License for more details.
|
|||
#include "bh.h"
|
||||
#include "matrices.h"
|
||||
|
||||
static const TVector3d GravVec(0.0, -1.0, 0.0);
|
||||
static constexpr TVector3d GravVec(0.0, -1.0, 0.0);
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Advanced geometry
|
||||
|
@ -31,7 +31,7 @@ static const TVector3d GravVec(0.0, -1.0, 0.0);
|
|||
struct TPlane {
|
||||
TVector3d nml;
|
||||
double d;
|
||||
explicit TPlane(double nx = 0.0, double ny = 0.0, double nz = 0.0, double d_ = 0.0)
|
||||
constexpr explicit TPlane(double nx = 0.0, double ny = 0.0, double nz = 0.0, double d_ = 0.0)
|
||||
: nml(nx, ny, nz), d(d_)
|
||||
{}
|
||||
};
|
||||
|
@ -77,14 +77,14 @@ struct TOdeData {
|
|||
double h;
|
||||
};
|
||||
|
||||
typedef int (*PNumEstimates)();
|
||||
typedef void (*PInitOdeData)(TOdeData *, double init_val, double h);
|
||||
typedef double(*PNextTime)(TOdeData *, int step);
|
||||
typedef double(*PNextValue)(TOdeData *, int step);
|
||||
typedef void (*PUpdateEstimate)(TOdeData *, int step, double val);
|
||||
typedef double(*PFinalEstimate)(TOdeData *);
|
||||
typedef double(*PEstimateError)(TOdeData *);
|
||||
typedef double(*PTimestepExponent)();
|
||||
typedef int (*PNumEstimates)();
|
||||
typedef void (*PInitOdeData)(TOdeData *, double init_val, double h);
|
||||
typedef double (*PNextTime)(TOdeData *, int step);
|
||||
typedef double (*PNextValue)(TOdeData *, int step);
|
||||
typedef void (*PUpdateEstimate)(TOdeData *, int step, double val);
|
||||
typedef double (*PFinalEstimate)(TOdeData *);
|
||||
typedef double (*PEstimateError)(TOdeData *);
|
||||
typedef double (*PTimestepExponent)();
|
||||
|
||||
struct TOdeSolver {
|
||||
PNumEstimates NumEstimates;
|
||||
|
|
|
@ -23,12 +23,12 @@ template<int ix, int iy>
|
|||
class TMatrix {
|
||||
double _data[ix][iy];
|
||||
public:
|
||||
TMatrix() {}
|
||||
constexpr TMatrix() = default;
|
||||
TMatrix(const TVector3d& w1, const TVector3d& w2, const TVector3d& w3);
|
||||
|
||||
double* operator[](int index) { return _data[index]; }
|
||||
const double* operator[](int index) const { return _data[index]; }
|
||||
const double* data() const { return (double*)_data; }
|
||||
constexpr const double* operator[](int index) const { return _data[index]; }
|
||||
constexpr const double* data() const { return (double*)_data; }
|
||||
|
||||
void SetIdentity();
|
||||
void SetRotationMatrix(double angle, char axis);
|
||||
|
|
|
@ -35,7 +35,6 @@ void draw_ui_snow();
|
|||
// snow particles during race
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
void create_new_particles(const TVector3d& loc, const TVector3d& vel, int num);
|
||||
void update_particles(float time_step);
|
||||
void clear_particles();
|
||||
void draw_particles(const CControl *ctrl);
|
||||
|
|
|
@ -100,7 +100,7 @@ void CControl::Init() {
|
|||
// collision
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
bool CControl::CheckTreeCollisions(const TVector3d& pos, TVector3d *tree_loc) {
|
||||
bool CControl::CheckTreeCollisions(const TVector3d& pos, TVector3d *tree_loc) const {
|
||||
// These variables are used to cache collision detection results
|
||||
static bool last_collision = false;
|
||||
static TVector3d last_collision_tree_loc(-999, -999, -999);
|
||||
|
@ -150,7 +150,7 @@ bool CControl::CheckTreeCollisions(const TVector3d& pos, TVector3d *tree_loc) {
|
|||
return hit;
|
||||
}
|
||||
|
||||
void CControl::AdjustTreeCollision(const TVector3d& pos, TVector3d *vel) {
|
||||
void CControl::AdjustTreeCollision(const TVector3d& pos, TVector3d *vel) const {
|
||||
TVector3d treeLoc;
|
||||
|
||||
if (CheckTreeCollisions(pos, &treeLoc)) {
|
||||
|
|
|
@ -81,9 +81,9 @@ private:
|
|||
double ode_time_step;
|
||||
double finish_speed;
|
||||
|
||||
bool CheckTreeCollisions(const TVector3d& pos, TVector3d *tree_loc);
|
||||
void AdjustTreeCollision(const TVector3d& pos, TVector3d *vel);
|
||||
void CheckItemCollection(const TVector3d& pos);
|
||||
bool CheckTreeCollisions(const TVector3d& pos, TVector3d *tree_loc) const;
|
||||
void AdjustTreeCollision(const TVector3d& pos, TVector3d *vel) const;
|
||||
static void CheckItemCollection(const TVector3d& pos);
|
||||
|
||||
TVector3d CalcRollNormal(double speed);
|
||||
TVector3d CalcAirForce();
|
||||
|
|
|
@ -201,7 +201,6 @@ void CRacing::Enter() {
|
|||
param.view_mode = ABOVE;
|
||||
}
|
||||
set_view_mode(ctrl, param.view_mode);
|
||||
left_turn = right_turn = trick_modifier = false;
|
||||
|
||||
ctrl->turn_fact = 0.0;
|
||||
ctrl->turn_animation = 0.0;
|
||||
|
|
|
@ -168,12 +168,12 @@ sf::Color Str_ColorN(const std::string &s, const sf::Color &def) {
|
|||
else return sf::Color(r * 255, g * 255, b * 255, a * 255);
|
||||
}
|
||||
|
||||
TColor3 Str_Color3N(const std::string &s, const TColor3 &def) {
|
||||
sf::Color Str_Color3N(const std::string &s, const sf::Color &def) {
|
||||
int r, g, b;
|
||||
std::istringstream is(s);
|
||||
is >> r >> g >> b;
|
||||
if (is.fail()) return def;
|
||||
else return TColor3(r, g, b);
|
||||
else return sf::Color(r, g, b);
|
||||
}
|
||||
|
||||
void Str_ArrN(const std::string &s, float *arr, std::size_t count, float def) {
|
||||
|
@ -256,7 +256,7 @@ sf::Color SPColorN(const std::string &s, const std::string &tag, const sf::Color
|
|||
return (Str_ColorN(SPItemN(s, tag), def));
|
||||
}
|
||||
|
||||
TColor3 SPColor3N(const std::string &s, const std::string &tag, const TColor3& def) {
|
||||
sf::Color SPColor3N(const std::string &s, const std::string &tag, const sf::Color& def) {
|
||||
return (Str_Color3N(SPItemN(s, tag), def));
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ TVector3<T> Str_Vector3(const std::string &s, const TVector3<T>& def);
|
|||
template<typename T>
|
||||
TVector4<T> Str_Vector4(const std::string &s, const TVector4<T>& def);
|
||||
sf::Color Str_ColorN(const std::string &s, const sf::Color& def);
|
||||
TColor3 Str_Color3N(const std::string &s, const TColor3& def);
|
||||
sf::Color Str_Color3N(const std::string &s, const sf::Color& def);
|
||||
void Str_ArrN(const std::string &s, float *arr, std::size_t count, float def);
|
||||
|
||||
// ----- SP functions for parsing lines --------------------------------
|
||||
|
@ -74,7 +74,7 @@ TVector4<T> SPVector4(const std::string &s, const std::string &tag, const TVecto
|
|||
static inline TVector4d SPVector4d(const std::string &s, const std::string &tag) { return SPVector4(s, tag, NullVec4); }
|
||||
static inline TVector4i SPVector4i(const std::string &s, const std::string &tag) { return SPVector4(s, tag, NullVec4i); }
|
||||
sf::Color SPColorN(const std::string &s, const std::string &tag, const sf::Color& def);
|
||||
TColor3 SPColor3N(const std::string &s, const std::string &tag, const TColor3& def);
|
||||
sf::Color SPColor3N(const std::string &s, const std::string &tag, const sf::Color& def);
|
||||
void SPArrN(const std::string &s, const std::string &tag, float *arr, std::size_t count, float def);
|
||||
|
||||
// ----- making SP strings --------------------------------------------
|
||||
|
|
|
@ -24,10 +24,10 @@ GNU General Public License for more details.
|
|||
class CWinsys;
|
||||
|
||||
class State {
|
||||
State(const State&);
|
||||
State& operator=(const State&);
|
||||
State(const State&) = delete;
|
||||
State& operator=(const State&) = delete;
|
||||
protected:
|
||||
State() {}
|
||||
State() = default;
|
||||
public:
|
||||
class Manager {
|
||||
friend class State;
|
||||
|
@ -40,7 +40,7 @@ public:
|
|||
bool quit;
|
||||
explicit Manager(CWinsys& winsys) : Winsys(winsys), previous(nullptr), current(nullptr), next(nullptr), quit(false) {}
|
||||
Manager(const Manager&);
|
||||
Manager& operator=(const Manager&);
|
||||
Manager& operator=(const Manager&) = delete;
|
||||
~Manager();
|
||||
|
||||
void PollEvent();
|
||||
|
|
14
src/tux.cpp
14
src/tux.cpp
|
@ -85,7 +85,7 @@ std::size_t CCharShape::GetNodeIdx(std::size_t node_name) const {
|
|||
return Index[node_name];
|
||||
}
|
||||
|
||||
TCharNode *CCharShape::GetNode(std::size_t node_name) {
|
||||
TCharNode *CCharShape::GetNode(std::size_t node_name) const {
|
||||
std::size_t idx = GetNodeIdx(node_name);
|
||||
if (idx >= numNodes) return nullptr;
|
||||
return Nodes[idx];
|
||||
|
@ -363,7 +363,7 @@ void CCharShape::CreateMaterial(const std::string& line) {
|
|||
// drawing
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
void CCharShape::DrawCharSphere(int num_divisions) {
|
||||
void CCharShape::DrawCharSphere(int num_divisions) const {
|
||||
GLUquadricObj *qobj = gluNewQuadric();
|
||||
gluQuadricDrawStyle(qobj, GLU_FILL);
|
||||
gluQuadricOrientation(qobj, GLU_OUTSIDE);
|
||||
|
@ -638,7 +638,7 @@ bool CCharShape::Collision(const TVector3d& pos, const TPolyhedron& ph) {
|
|||
// shadow
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
void CCharShape::DrawShadowVertex(double x, double y, double z, const TMatrix<4, 4>& mat) {
|
||||
void CCharShape::DrawShadowVertex(double x, double y, double z, const TMatrix<4, 4>& mat) const {
|
||||
TVector3d pt(x, y, z);
|
||||
pt = TransformPoint(mat, pt);
|
||||
double old_y = pt.y;
|
||||
|
@ -649,7 +649,7 @@ void CCharShape::DrawShadowVertex(double x, double y, double z, const TMatrix<4,
|
|||
glVertex3(pt);
|
||||
}
|
||||
|
||||
void CCharShape::DrawShadowSphere(const TMatrix<4, 4>& mat) {
|
||||
void CCharShape::DrawShadowSphere(const TMatrix<4, 4>& mat) const {
|
||||
double theta, phi, d_theta, d_phi, eps, twopi;
|
||||
double x, y, z;
|
||||
int div = param.tux_shadow_sphere_divisions;
|
||||
|
@ -730,7 +730,7 @@ void CCharShape::DrawShadowSphere(const TMatrix<4, 4>& mat) {
|
|||
}
|
||||
}
|
||||
|
||||
void CCharShape::TraverseDagForShadow(const TCharNode *node, const TMatrix<4, 4>& mat) {
|
||||
void CCharShape::TraverseDagForShadow(const TCharNode *node, const TMatrix<4, 4>& mat) const {
|
||||
TMatrix<4, 4> new_matrix = mat * node->trans;
|
||||
if (node->visible && node->render_shadow)
|
||||
DrawShadowSphere(new_matrix);
|
||||
|
@ -742,13 +742,13 @@ void CCharShape::TraverseDagForShadow(const TCharNode *node, const TMatrix<4, 4>
|
|||
}
|
||||
}
|
||||
|
||||
void CCharShape::DrawShadow() {
|
||||
void CCharShape::DrawShadow() const {
|
||||
if (g_game.light_id == 1 || g_game.light_id == 3) return;
|
||||
|
||||
ScopedRenderMode rm(TUX_SHADOW);
|
||||
glColor(shad_col);
|
||||
|
||||
TCharNode *node = GetNode(0);
|
||||
const TCharNode *node = GetNode(0);
|
||||
if (node == nullptr) {
|
||||
Message("couldn't find tux's root node");
|
||||
return;
|
||||
|
|
12
src/tux.h
12
src/tux.h
|
@ -81,7 +81,7 @@ private:
|
|||
|
||||
// nodes
|
||||
std::size_t GetNodeIdx(std::size_t node_name) const;
|
||||
TCharNode *GetNode(std::size_t node_name);
|
||||
TCharNode *GetNode(std::size_t node_name) const;
|
||||
void CreateRootNode();
|
||||
bool CreateCharNode(int parent_name, std::size_t node_name, const std::string& joint,
|
||||
const std::string& name, const std::string& order, bool shadow);
|
||||
|
@ -94,7 +94,7 @@ private:
|
|||
void CreateMaterial(const std::string& line);
|
||||
|
||||
// drawing
|
||||
void DrawCharSphere(int num_divisions);
|
||||
void DrawCharSphere(int num_divisions) const;
|
||||
void DrawNodes(const TCharNode *node);
|
||||
TVector3d AdjustRollvector(const CControl *ctrl, const TVector3d& vel, const TVector3d& zvec);
|
||||
|
||||
|
@ -104,9 +104,9 @@ private:
|
|||
bool CheckCollision(const TPolyhedron& ph);
|
||||
|
||||
// shadow
|
||||
void DrawShadowVertex(double x, double y, double z, const TMatrix<4, 4>& mat);
|
||||
void DrawShadowSphere(const TMatrix<4, 4>& mat);
|
||||
void TraverseDagForShadow(const TCharNode *node, const TMatrix<4, 4>& mat);
|
||||
void DrawShadowVertex(double x, double y, double z, const TMatrix<4, 4>& mat) const;
|
||||
void DrawShadowSphere(const TMatrix<4, 4>& mat) const;
|
||||
void TraverseDagForShadow(const TCharNode *node, const TMatrix<4, 4>& mat) const;
|
||||
|
||||
// testing and developing
|
||||
void AddAction(std::size_t node_name, int type, const TVector3d& vec, double val);
|
||||
|
@ -132,7 +132,7 @@ public:
|
|||
// global functions
|
||||
void Reset();
|
||||
void Draw();
|
||||
void DrawShadow();
|
||||
void DrawShadow() const;
|
||||
bool Load(const std::string& dir, const std::string& filename, bool with_actions);
|
||||
|
||||
void AdjustOrientation(CControl *ctrl, double dtime,
|
||||
|
|
|
@ -24,10 +24,10 @@ GNU General Public License for more details.
|
|||
template<typename T>
|
||||
struct TVector2 {
|
||||
T x, y;
|
||||
explicit TVector2(T _x = (T)0, T _y = (T)0)
|
||||
constexpr explicit TVector2(T _x = (T)0, T _y = (T)0)
|
||||
: x(_x), y(_y)
|
||||
{}
|
||||
double Length() const {
|
||||
constexpr double Length() const {
|
||||
return std::hypot(x, y);
|
||||
}
|
||||
double Norm();
|
||||
|
@ -51,10 +51,10 @@ struct TVector2 {
|
|||
template<typename T>
|
||||
struct TVector3 {
|
||||
T x, y, z;
|
||||
explicit TVector3(T _x = (T)0, T _y = (T)0, T _z = (T)0)
|
||||
constexpr explicit TVector3(T _x = (T)0, T _y = (T)0, T _z = (T)0)
|
||||
: x(_x), y(_y), z(_z)
|
||||
{}
|
||||
double Length() const {
|
||||
constexpr double Length() const {
|
||||
return std::sqrt(static_cast<double>(x*x + y*y + z*z));
|
||||
}
|
||||
double Norm();
|
||||
|
@ -81,10 +81,10 @@ struct TVector3 {
|
|||
template<typename T>
|
||||
struct TVector4 {
|
||||
T x, y, z, w;
|
||||
explicit TVector4(T _x = (T)0, T _y = (T)0, T _z = (T)0, T _w = (T)0)
|
||||
constexpr explicit TVector4(T _x = (T)0, T _y = (T)0, T _z = (T)0, T _w = (T)0)
|
||||
: x(_x), y(_y), z(_z), w(_w)
|
||||
{}
|
||||
double Length() const {
|
||||
constexpr double Length() const {
|
||||
return std::sqrt(static_cast<double>(x*x + y*y + z*z + w*w));
|
||||
}
|
||||
double Norm();
|
||||
|
@ -120,63 +120,63 @@ typedef TVector2<int> TVector2i;
|
|||
typedef TVector4d TQuaternion;
|
||||
|
||||
template<typename T>
|
||||
TVector2<T> operator*(T f, const TVector2<T>& v) {
|
||||
constexpr TVector2<T> operator*(T f, const TVector2<T>& v) {
|
||||
return TVector2<T>(v.x*f, v.y*f);
|
||||
}
|
||||
template<typename T>
|
||||
TVector3<T> operator*(T f, const TVector3<T>& v) {
|
||||
constexpr TVector3<T> operator*(T f, const TVector3<T>& v) {
|
||||
return TVector3<T>(v.x*f, v.y*f, v.z*f);
|
||||
}
|
||||
template<typename T>
|
||||
TVector4<T> operator*(T f, const TVector4<T>& v) {
|
||||
constexpr TVector4<T> operator*(T f, const TVector4<T>& v) {
|
||||
return TVector4<T>(v.x*f, v.y*f, v.z*f, v.w*f);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
TVector2<T> operator+(const TVector2<T>& l, const TVector2<T>& r) {
|
||||
constexpr TVector2<T> operator+(const TVector2<T>& l, const TVector2<T>& r) {
|
||||
return TVector2<T>(l.x + r.x, l.y + r.y);
|
||||
}
|
||||
template<typename T>
|
||||
TVector3<T> operator+(const TVector3<T>& l, const TVector3<T>& r) {
|
||||
constexpr TVector3<T> operator+(const TVector3<T>& l, const TVector3<T>& r) {
|
||||
return TVector3<T>(l.x + r.x, l.y + r.y, l.z + r.z);
|
||||
}
|
||||
template<typename T>
|
||||
TVector4<T> operator+(const TVector4<T>& l, const TVector4<T>& r) {
|
||||
constexpr TVector4<T> operator+(const TVector4<T>& l, const TVector4<T>& r) {
|
||||
return TVector4<T>(l.x + r.x, l.y + r.y, l.z + r.z, l.w + r.w);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
TVector2<T> operator-(const TVector2<T>& l, const TVector2<T>& r) {
|
||||
constexpr TVector2<T> operator-(const TVector2<T>& l, const TVector2<T>& r) {
|
||||
return TVector2<T>(l.x - r.x, l.y - r.y);
|
||||
}
|
||||
template<typename T>
|
||||
TVector3<T> operator-(const TVector3<T>& l, const TVector3<T>& r) {
|
||||
constexpr TVector3<T> operator-(const TVector3<T>& l, const TVector3<T>& r) {
|
||||
return TVector3<T>(l.x - r.x, l.y - r.y, l.z - r.z);
|
||||
}
|
||||
template<typename T>
|
||||
TVector4<T> operator-(const TVector4<T>& l, const TVector4<T>& r) {
|
||||
constexpr TVector4<T> operator-(const TVector4<T>& l, const TVector4<T>& r) {
|
||||
return TVector4<T>(l.x - r.x, l.y - r.y, l.z - r.z, l.w - r.w);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
TVector2<T> operator-(const TVector2<T>&r) {
|
||||
constexpr TVector2<T> operator-(const TVector2<T>&r) {
|
||||
return TVector2<T>(-r.x, -r.y);
|
||||
}
|
||||
template<typename T>
|
||||
TVector3<T> operator-(const TVector3<T>& r) {
|
||||
constexpr TVector3<T> operator-(const TVector3<T>& r) {
|
||||
return TVector3<T>(-r.x, -r.y, -r.z);
|
||||
}
|
||||
template<typename T>
|
||||
TVector4<T> operator-(const TVector4<T>& r) {
|
||||
constexpr TVector4<T> operator-(const TVector4<T>& r) {
|
||||
return TVector4<T>(-r.x, -r.y, -r.z, -r.w);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
double DotProduct(const TVector3<T>& v1, const TVector3<T>& v2) {
|
||||
constexpr double DotProduct(const TVector3<T>& v1, const TVector3<T>& v2) {
|
||||
return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
|
||||
}
|
||||
template<typename T>
|
||||
double DotProduct(const TVector4<T>& v1, const TVector4<T>& v2) {
|
||||
constexpr double DotProduct(const TVector4<T>& v1, const TVector4<T>& v2) {
|
||||
return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z + v1.w * v2.w;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ extern TVector2i cursor_pos;
|
|||
|
||||
struct TScreenRes {
|
||||
unsigned int width, height;
|
||||
TScreenRes(unsigned int w = 0, unsigned int h = 0) : width(w), height(h) {}
|
||||
constexpr TScreenRes(unsigned int w = 0, unsigned int h = 0) : width(w), height(h) {}
|
||||
};
|
||||
|
||||
class CWinsys {
|
||||
|
|
Loading…
Reference in New Issue