On passe -ansi -pedantic -Wconversion -Wformat=2 -Winit-self -Wmissing-include-dirs -Wswitch-default -Wsync-nand -Wunused -Wstrict-overflow=5 -Wfloat-equal -Wundef -Wno-endif-labels -Wshadow -Wunsafe-loop-optimizations -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wlogical-op -Wmissing-declarations -Wnormalized=nfc -Wpacked -Wredundant-decls -Winline -Winvalid-pch -Wdisabled-optimization -Woverlength-strings .
This commit is contained in:
parent
0016a66cbd
commit
8239cd8fbe
1
Makefile
1
Makefile
|
@ -1,5 +1,6 @@
|
|||
CXX=g++
|
||||
# -ansi -pedantic -Wconversion
|
||||
# -Wformat=2 -Winit-self -Wmissing-include-dirs -Wswitch-default -Wsync-nand -Wunused -Wstrict-overflow=5 -Wfloat-equal -Wundef -Wno-endif-labels -Wshadow -Wunsafe-loop-optimizations -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wlogical-op -Wmissing-declarations -Wnormalized=nfc -Wpacked -Wredundant-decls -Winline -Winvalid-pch -Wdisabled-optimization -Woverlength-strings
|
||||
CCWARN=-Wall -Wextra -Werror
|
||||
# TODO : -O3 -m32 ou -m64
|
||||
# -g -rdynamic uniquement pour le debug.
|
||||
|
|
4
geometry/angle.cpp
Normal file
4
geometry/angle.cpp
Normal file
|
@ -0,0 +1,4 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
float Angle::r2d(float rad) { return rad / Pi * 180; }
|
||||
float Angle::d2r(float deg) { return deg / 180 * Pi; }
|
|
@ -4,8 +4,8 @@
|
|||
namespace Angle {
|
||||
const double dPi = 3.141592653589793238462643383279;
|
||||
const float Pi = (float)(dPi);
|
||||
float r2d(float rad) { return rad / Pi * 180; }
|
||||
float d2r(float deg) { return deg / 180 * Pi; }
|
||||
float r2d(float rad);
|
||||
float d2r(float deg);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
Segment::Segment(Vertex u, Vertex v): u(u), v(v) {}
|
||||
Segment::Segment(Vertex _u, Vertex _v): u(_u), v(_v) {}
|
||||
|
||||
float Segment::length() {
|
||||
return (u-v).norm();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
Vertex::Vertex() {}
|
||||
|
||||
Vertex::Vertex(float x, float y, float z): x(x), y(y), z(z) {}
|
||||
Vertex::Vertex(float _x, float _y, float _z): x(_x), y(_y), z(_z) {}
|
||||
|
||||
float Vertex::norm() const { return std::sqrt(x*x + y*y + z*z); }
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
GPUTriangle::GPUTriangle(Vertex left, Vertex top, Vertex right, unsigned char r, unsigned char g, unsigned char b)
|
||||
: c(left, top, right), r(r), g(g), b(b), vnormal(normal(left,top,right)) {
|
||||
GPUTriangle::GPUTriangle(Vertex left, Vertex top, Vertex right, unsigned char _r, unsigned char _g, unsigned char _b)
|
||||
: c(left, top, right), r(_r), g(_g), b(_b), vnormal(normal(left,top,right)) {
|
||||
}
|
||||
|
||||
GPUTriangle::GPUTriangle(Triangle c, unsigned char r, unsigned char g, unsigned char b)
|
||||
: c(c), r(r), g(g), b(b), vnormal(normal(c[LEFT], c[TOP], c[RIGHT])) {
|
||||
GPUTriangle::GPUTriangle(Triangle _c, unsigned char _r, unsigned char _g, unsigned char _b)
|
||||
: c(_c), r(_r), g(_g), b(_b), vnormal(normal(c[LEFT], c[TOP], c[RIGHT])) {
|
||||
}
|
||||
|
||||
Vertex GPUTriangle::normal(Vertex left, Vertex top, Vertex right) {
|
||||
Vertex normal = (left - top)*(right - top);
|
||||
return normal / normal.norm();
|
||||
Vertex v = (left - top)*(right - top);
|
||||
return v / v.norm();
|
||||
}
|
||||
|
||||
void GPUTriangle::display() {
|
||||
|
|
2
heap.cpp
2
heap.cpp
|
@ -3,7 +3,7 @@ Heap::Heap()
|
|||
bucketArraySize(1), lastNode(-1) {
|
||||
}
|
||||
|
||||
void Heap::init(int id, int factor) { this->id = id; this->factor = (float)factor; }
|
||||
void Heap::init(int _id, int _factor) { this->id = _id; this->factor = (float)_factor; }
|
||||
|
||||
void Heap::insert(float key, Chose* value) {
|
||||
++lastNode;
|
||||
|
|
10
lod.cpp
10
lod.cpp
|
@ -1,16 +1,16 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
Lod::Lod(Vertex camera, Chose* root) {
|
||||
Lod::Lod(Vertex _camera, Chose* root) {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
merge[i].init(i, (i & 1) ? 1 : -1);
|
||||
splitIn[i].init(6+i, (i & 1) ? 1 : -1);
|
||||
splitOut[i].init(12+i, (i & 1) ? -1 : 1);
|
||||
}
|
||||
this->camera[0] = camera.x;
|
||||
this->camera[1] = camera.y;
|
||||
this->camera[2] = camera.z;
|
||||
this->camera[0] = _camera.x;
|
||||
this->camera[1] = _camera.y;
|
||||
this->camera[2] = _camera.z;
|
||||
addSplitCube(root);
|
||||
setCamera(camera);
|
||||
setCamera(_camera);
|
||||
}
|
||||
|
||||
void Lod::setCamera(Vertex newCamera) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
BatimentQuad::BatimentQuad(Quad c, Cardinal entry) : Chose(), c(c), entry(entry) {
|
||||
BatimentQuad::BatimentQuad(Quad _c, Cardinal _entry) : Chose(), c(_c), entry(_entry) {
|
||||
addEntropy(c);
|
||||
addEntropy(entry);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
BatimentQuadBlock::BatimentQuadBlock(Quad c, float height) : Chose(), c(c), height(height) {
|
||||
BatimentQuadBlock::BatimentQuadBlock(Quad _c, float _height) : Chose(), c(_c), height(_height) {
|
||||
addEntropy(c);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
BatimentQuadFenetre::BatimentQuadFenetre(Quad c, float height) : Chose(), c(c), height(height) {
|
||||
BatimentQuadFenetre::BatimentQuadFenetre(Quad _c, float _height) : Chose(), c(_c), height(_height) {
|
||||
addEntropy(c);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
BatimentQuadJardin::BatimentQuadJardin(Quad c) : Chose(), c(c) {
|
||||
BatimentQuadJardin::BatimentQuadJardin(Quad _c) : Chose(), c(_c) {
|
||||
addEntropy(c);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
BatimentQuadMaison::BatimentQuadMaison(Quad c) : Chose(), c(c) {
|
||||
BatimentQuadMaison::BatimentQuadMaison(Quad _c) : Chose(), c(_c) {
|
||||
addEntropy(c);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
BatimentQuadMaisonPont::BatimentQuadMaisonPont(Quad c, float height) : Chose(), c(c), height(height) {
|
||||
BatimentQuadMaisonPont::BatimentQuadMaisonPont(Quad _c, float _height) : Chose(), c(_c), height(_height) {
|
||||
addEntropy(c);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
BatimentQuadMur::BatimentQuadMur(Quad c, float height) : Chose(), c(c), height(height) {
|
||||
BatimentQuadMur::BatimentQuadMur(Quad _c, float _height) : Chose(), c(_c), height(_height) {
|
||||
addEntropy(c);
|
||||
this->window = false;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
BatimentQuadPont::BatimentQuadPont(Quad c, float height) : Chose(), c(c), height(height) {
|
||||
BatimentQuadPont::BatimentQuadPont(Quad _c, float _height) : Chose(), c(_c), height(_height) {
|
||||
addEntropy(c);
|
||||
}
|
||||
|
||||
|
@ -9,12 +9,12 @@ void BatimentQuadPont::getBoundingBoxPoints() {
|
|||
addBBPoints(c + Vertex(0,0,height)); // TODO
|
||||
}
|
||||
|
||||
float ct(float x) {
|
||||
float BatimentQuadPont::ct(float x) {
|
||||
return (float)(1 - cosh(x / 1.f));
|
||||
}
|
||||
|
||||
float nt(float x, float height) {
|
||||
return (ct(x) + -ct(-1.7f))/(ct(0)+ -ct(-1.7f)) * height;
|
||||
float BatimentQuadPont::nt(float x, float _height) {
|
||||
return (ct(x) + -ct(-1.7f))/(ct(0)+ -ct(-1.7f)) * _height;
|
||||
}
|
||||
|
||||
void BatimentQuadPont::triangulation() {
|
||||
|
|
|
@ -5,14 +5,17 @@
|
|||
|
||||
|
||||
class BatimentQuadPont: public Chose {
|
||||
private :
|
||||
private :
|
||||
Quad c;
|
||||
float height;
|
||||
|
||||
public :
|
||||
public :
|
||||
BatimentQuadPont(Quad c, float height);
|
||||
virtual void triangulation();
|
||||
virtual void getBoundingBoxPoints();
|
||||
private:
|
||||
float ct(float x);
|
||||
float nt(float x, float height);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
BatimentQuadToit::BatimentQuadToit(Quad c, float height) : Chose(), c(c), height(height) {
|
||||
BatimentQuadToit::BatimentQuadToit(Quad _c, float _height) : Chose(), c(_c), height(_height) {
|
||||
addEntropy(c);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
BatimentTri::BatimentTri(Triangle c) : Chose(), c(c) {
|
||||
BatimentTri::BatimentTri(Triangle _c) : Chose(), c(_c) {
|
||||
addEntropy(c);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
QuartierQuad::QuartierQuad(Quad c) : Chose(), c(c) {
|
||||
QuartierQuad::QuartierQuad(Quad _c) : Chose(), c(_c) {
|
||||
addEntropy(c);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
QuartierQuadAngle::QuartierQuadAngle(Quad c) : QuartierQuad(c) {
|
||||
QuartierQuadAngle::QuartierQuadAngle(Quad _c) : QuartierQuad(_c) {
|
||||
}
|
||||
|
||||
bool QuartierQuadAngle::split() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
QuartierQuadCarre::QuartierQuadCarre(Quad c) : QuartierQuad(c) {
|
||||
QuartierQuadCarre::QuartierQuadCarre(Quad _c) : QuartierQuad(_c) {
|
||||
}
|
||||
|
||||
bool QuartierQuadCarre::split() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
QuartierQuadRect::QuartierQuadRect(Quad c) : QuartierQuad(c) {
|
||||
QuartierQuadRect::QuartierQuadRect(Quad _c) : QuartierQuad(_c) {
|
||||
}
|
||||
|
||||
bool QuartierQuadRect::split() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
QuartierTri::QuartierTri(Triangle c) : Chose(), c(c) {
|
||||
QuartierTri::QuartierTri(Triangle _c) : Chose(), c(_c) {
|
||||
addEntropy(c);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
QuartierTriCentre::QuartierTriCentre(Triangle c) : QuartierTri(c) {
|
||||
QuartierTriCentre::QuartierTriCentre(Triangle _c) : QuartierTri(_c) {
|
||||
}
|
||||
|
||||
bool QuartierTriCentre::split() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
QuartierTriHauteur::QuartierTriHauteur(Triangle c) : QuartierTri(c) {
|
||||
QuartierTriHauteur::QuartierTriHauteur(Triangle _c) : QuartierTri(_c) {
|
||||
}
|
||||
|
||||
bool QuartierTriHauteur::split() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
QuartierTriTrapeze::QuartierTriTrapeze(Triangle c) : QuartierTri(c) {
|
||||
QuartierTriTrapeze::QuartierTriTrapeze(Triangle _c) : QuartierTri(_c) {
|
||||
}
|
||||
|
||||
bool QuartierTriTrapeze::split() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
RouteQuadCarrefour::RouteQuadCarrefour(Quad c) : Chose(), c(c) {
|
||||
RouteQuadCarrefour::RouteQuadCarrefour(Quad _c) : Chose(), c(_c) {
|
||||
addEntropy(c);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
RouteQuadChaussee::RouteQuadChaussee(Quad c) : Chose(), c(c) {
|
||||
RouteQuadChaussee::RouteQuadChaussee(Quad _c) : Chose(), c(_c) {
|
||||
addEntropy(c);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
RouteTriChaussee::RouteTriChaussee(Triangle c) : Chose(), c(c) {
|
||||
RouteTriChaussee::RouteTriChaussee(Triangle _c) : Chose(), c(_c) {
|
||||
addEntropy(c);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
TrottoirQuadNormal::TrottoirQuadNormal(Quad c, float height) : Chose(), c(c), height(height) {
|
||||
TrottoirQuadNormal::TrottoirQuadNormal(Quad _c, float _height) : Chose(), c(_c), height(_height) {
|
||||
}
|
||||
|
||||
void TrottoirQuadNormal::getBoundingBoxPoints() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
TerrainQuadHerbe::TerrainQuadHerbe(Quad c) : Chose(), c(c) {
|
||||
TerrainQuadHerbe::TerrainQuadHerbe(Quad _c) : Chose(), c(_c) {
|
||||
addEntropy(c);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
TerrainTriHerbe::TerrainTriHerbe(Triangle c) : Chose(), c(c) {
|
||||
TerrainTriHerbe::TerrainTriHerbe(Triangle _c) : Chose(), c(_c) {
|
||||
addEntropy(c);
|
||||
}
|
||||
|
||||
|
|
26
view.cpp
26
view.cpp
|
@ -1,9 +1,9 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
View::View(Chose* root)
|
||||
: root(root),
|
||||
View::View(Chose* _root)
|
||||
: root(_root),
|
||||
camera(Camera(Vertex(9600,10000,15300),0,179,1000,0.6f)),
|
||||
lod(camera.cameraCenter, root) {
|
||||
lod(camera.cameraCenter, _root) {
|
||||
initWindow();
|
||||
mainLoop();
|
||||
}
|
||||
|
@ -145,13 +145,13 @@ void View::mainLoop() {
|
|||
SDL_Quit();
|
||||
}
|
||||
|
||||
Camera::Camera(Vertex pos, float xA, float yA, int moveSensitivity, float mouseSensitivity)
|
||||
: cameraCenter(pos),
|
||||
cameraSight(cameraCenter + Vertex::fromSpherical(100,yA,xA)),
|
||||
xAngle(xA),
|
||||
yAngle(yA),
|
||||
moveDist(moveSensitivity),
|
||||
mouseSensitivity(mouseSensitivity),
|
||||
Camera::Camera(Vertex _cameraCenter, float _xAngle, float _yAngle, int _moveSensitivity, float _mouseSensitivity)
|
||||
: cameraCenter(_cameraCenter),
|
||||
cameraSight(cameraCenter + Vertex::fromSpherical(100,_yAngle,_xAngle)),
|
||||
xAngle(_xAngle),
|
||||
yAngle(_yAngle),
|
||||
moveSensitivity(_moveSensitivity),
|
||||
mouseSensitivity(_mouseSensitivity),
|
||||
up(false), down(false), left(false), right(false),
|
||||
pageUp(false), pageDown(false)
|
||||
{
|
||||
|
@ -207,11 +207,11 @@ void Camera::keyboard(const SDL_KeyboardEvent &eventKey) {
|
|||
break;
|
||||
case 's':
|
||||
if (eventKey.type != SDL_KEYDOWN) break;
|
||||
moveDist = std::min(50000,std::max(moveDist+1, moveDist*10/9));
|
||||
moveSensitivity = std::min(50000,std::max(moveSensitivity+1, moveSensitivity*10/9));
|
||||
break;
|
||||
case 'x':
|
||||
if (eventKey.type != SDL_KEYDOWN) break;
|
||||
moveDist = std::max(10, moveDist*9/10);
|
||||
moveSensitivity = std::max(10, moveSensitivity*9/10);
|
||||
break;
|
||||
case 'p': // _Print _Position
|
||||
if (eventKey.type != SDL_KEYDOWN) break;
|
||||
|
@ -225,7 +225,7 @@ void Camera::keyboard(const SDL_KeyboardEvent &eventKey) {
|
|||
}
|
||||
|
||||
void Camera::animation(int elapsedTime) {
|
||||
float diff = ((float)(elapsedTime+1)/1000.f)*(float)moveDist;
|
||||
float diff = ((float)(elapsedTime+1)/1000.f)*(float)moveSensitivity;
|
||||
|
||||
if(up)
|
||||
cameraCenter = cameraCenter + Vertex::fromSpherical(diff, yAngle, xAngle);
|
||||
|
|
Loading…
Reference in New Issue
Block a user