cfloats are just floats, no overcomplication
This commit is contained in:
parent
28c4088bdc
commit
b5ba73825e
@ -4,14 +4,14 @@ CollisionShape::CollisionShape() {
|
|||||||
shape = nullptr;
|
shape = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
SphereCollisionShape::SphereCollisionShape(cfloat radius) {
|
SphereCollisionShape::SphereCollisionShape(float radius) {
|
||||||
shape = new btSphereShape(radius);
|
shape = new btSphereShape(radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
BoxCollisionShape::BoxCollisionShape(cfloat width, cfloat height, cfloat depth) {
|
BoxCollisionShape::BoxCollisionShape(float width, float height, float depth) {
|
||||||
shape = new btBoxShape(btVector3(width / 2.0f, height / 2.0f, depth / 2.0f));
|
shape = new btBoxShape(btVector3(width / 2.0f, height / 2.0f, depth / 2.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
CapsuleCollisionShape::CapsuleCollisionShape(cfloat radius, cfloat height) {
|
CapsuleCollisionShape::CapsuleCollisionShape(float radius, float height) {
|
||||||
shape = new btCapsuleShape(radius, height);
|
shape = new btCapsuleShape(radius, height);
|
||||||
}
|
}
|
||||||
|
@ -16,17 +16,17 @@ private:
|
|||||||
|
|
||||||
class SphereCollisionShape : public CollisionShape {
|
class SphereCollisionShape : public CollisionShape {
|
||||||
public:
|
public:
|
||||||
SphereCollisionShape(cfloat radius);
|
SphereCollisionShape(float radius);
|
||||||
};
|
};
|
||||||
|
|
||||||
class BoxCollisionShape : public CollisionShape {
|
class BoxCollisionShape : public CollisionShape {
|
||||||
public:
|
public:
|
||||||
BoxCollisionShape(cfloat width, cfloat height, cfloat depth);
|
BoxCollisionShape(float width, float height, float depth);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CapsuleCollisionShape: public CollisionShape {
|
class CapsuleCollisionShape: public CollisionShape {
|
||||||
public:
|
public:
|
||||||
CapsuleCollisionShape(cfloat radius, cfloat height);
|
CapsuleCollisionShape(float radius, float height);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* COLLISIONSHAPE_H */
|
#endif /* COLLISIONSHAPE_H */
|
||||||
|
@ -30,7 +30,7 @@ DirectionalLight::DirectionalLight() {
|
|||||||
this->specular = 0.0f;
|
this->specular = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectionalLight::DirectionalLight(Vector3 direction, Vector3 color, cfloat ambient, cfloat diffuse, cfloat specular) {
|
DirectionalLight::DirectionalLight(Vector3 direction, Vector3 color, float ambient, float diffuse, float specular) {
|
||||||
this->direction = direction;
|
this->direction = direction;
|
||||||
this->color = color;
|
this->color = color;
|
||||||
this->ambient = ambient;
|
this->ambient = ambient;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
class Light : public Spatial {
|
class Light : public Spatial {
|
||||||
public:
|
public:
|
||||||
Vector3 color;
|
Vector3 color;
|
||||||
cfloat ambient, diffuse, specular;
|
float ambient, diffuse, specular;
|
||||||
virtual Name GetType() const;
|
virtual Name GetType() const;
|
||||||
virtual Light *Create();
|
virtual Light *Create();
|
||||||
virtual Light *Duplicate();
|
virtual Light *Duplicate();
|
||||||
@ -18,7 +18,7 @@ class DirectionalLight : public Light {
|
|||||||
public:
|
public:
|
||||||
Vector3 direction;
|
Vector3 direction;
|
||||||
DirectionalLight();
|
DirectionalLight();
|
||||||
DirectionalLight(Vector3 direction, Vector3 color, cfloat ambient, cfloat diffuse, cfloat specular);
|
DirectionalLight(Vector3 direction, Vector3 color, float ambient, float diffuse, float specular);
|
||||||
virtual Name GetType() const;
|
virtual Name GetType() const;
|
||||||
virtual DirectionalLight *Create();
|
virtual DirectionalLight *Create();
|
||||||
virtual DirectionalLight *Duplicate();
|
virtual DirectionalLight *Duplicate();
|
||||||
|
@ -27,7 +27,7 @@ struct Material {
|
|||||||
|
|
||||||
int shininess;
|
int shininess;
|
||||||
|
|
||||||
cfloat alphaScissor;
|
float alphaScissor;
|
||||||
bool unshaded;
|
bool unshaded;
|
||||||
bool cullBack;
|
bool cullBack;
|
||||||
Material();
|
Material();
|
||||||
|
@ -68,11 +68,11 @@ void Rigidbody::SetCollisionShape(CollisionShape collisionShape) {
|
|||||||
this->collisionShape = collisionShape.shape;
|
this->collisionShape = collisionShape.shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
cfloat Rigidbody::GetMass() {
|
float Rigidbody::GetMass() {
|
||||||
return mass;
|
return mass;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rigidbody::SetMass(cfloat mass) {
|
void Rigidbody::SetMass(float mass) {
|
||||||
this->mass = mass;
|
this->mass = mass;
|
||||||
if (not IsPrefab()) {
|
if (not IsPrefab()) {
|
||||||
btBody->setMassProps(mass, btVector3(0, 0, 0));
|
btBody->setMassProps(mass, btVector3(0, 0, 0));
|
||||||
|
@ -52,14 +52,14 @@ public:
|
|||||||
Gets the mass of this rigidbody
|
Gets the mass of this rigidbody
|
||||||
@return The mass, 0.0 if this is an infinite mass object
|
@return The mass, 0.0 if this is an infinite mass object
|
||||||
*/
|
*/
|
||||||
cfloat GetMass();
|
float GetMass();
|
||||||
/**
|
/**
|
||||||
Sets the mass of this rigidbody.
|
Sets the mass of this rigidbody.
|
||||||
Note that setting mass equal to 0.0 will make it an
|
Note that setting mass equal to 0.0 will make it an
|
||||||
infinite mass object
|
infinite mass object
|
||||||
@param mass The desired mass
|
@param mass The desired mass
|
||||||
*/
|
*/
|
||||||
void SetMass(cfloat mass);
|
void SetMass(float mass);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Add an instantaneous impulse to the object.
|
Add an instantaneous impulse to the object.
|
||||||
@ -93,7 +93,7 @@ private:
|
|||||||
bool character = false;
|
bool character = false;
|
||||||
btRigidBody *btBody;
|
btRigidBody *btBody;
|
||||||
btCollisionShape *collisionShape;
|
btCollisionShape *collisionShape;
|
||||||
cfloat mass = 1.0f;
|
float mass = 1.0f;
|
||||||
|
|
||||||
friend class World;
|
friend class World;
|
||||||
};
|
};
|
||||||
|
@ -63,9 +63,9 @@ void Shader::UpdateMaterial(Material material) {
|
|||||||
glBindTexture(GL_TEXTURE_2D, material.tex.id);
|
glBindTexture(GL_TEXTURE_2D, material.tex.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
glUniform3fv(glGetUniformLocation(id, "material.ambient"), 1, (cfloat*) &material.ambient);
|
glUniform3fv(glGetUniformLocation(id, "material.ambient"), 1, (float*) &material.ambient);
|
||||||
glUniform3fv(glGetUniformLocation(id, "material.diffuse"), 1, (cfloat*) &material.diffuse);
|
glUniform3fv(glGetUniformLocation(id, "material.diffuse"), 1, (float*) &material.diffuse);
|
||||||
glUniform3fv(glGetUniformLocation(id, "material.specular"), 1, (cfloat*) &material.specular);
|
glUniform3fv(glGetUniformLocation(id, "material.specular"), 1, (float*) &material.specular);
|
||||||
glUniform1i(glGetUniformLocation(id, "material.shininess"), material.shininess);
|
glUniform1i(glGetUniformLocation(id, "material.shininess"), material.shininess);
|
||||||
|
|
||||||
glUniform1f(glGetUniformLocation(id, "material.alphaScissor"), material.alphaScissor);
|
glUniform1f(glGetUniformLocation(id, "material.alphaScissor"), material.alphaScissor);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "Skybox.h"
|
#include "Skybox.h"
|
||||||
|
|
||||||
cfloat vertices[] = {
|
float vertices[] = {
|
||||||
// positions
|
// positions
|
||||||
-1.0f, 1.0f, -1.0f,
|
-1.0f, 1.0f, -1.0f,
|
||||||
-1.0f, -1.0f, -1.0f,
|
-1.0f, -1.0f, -1.0f,
|
||||||
@ -57,7 +57,7 @@ Skybox::Skybox() {
|
|||||||
// We're just going to use position data
|
// We're just going to use position data
|
||||||
// UV data is the same
|
// UV data is the same
|
||||||
glEnableVertexAttribArray(0);
|
glEnableVertexAttribArray(0);
|
||||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * (sizeof(cfloat)), (void*) 0);
|
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * (sizeof(float)), (void*) 0);
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,25 +42,25 @@ void Spatial::Translate(Vector3 offset) {
|
|||||||
this->SetTransform(t);
|
this->SetTransform(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spatial::RotateX(cfloat phi) {
|
void Spatial::RotateX(float phi) {
|
||||||
Transform t = this->GetTransform();
|
Transform t = this->GetTransform();
|
||||||
t.rotation.x += phi;
|
t.rotation.x += phi;
|
||||||
this->SetTransform(t);
|
this->SetTransform(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spatial::RotateY(cfloat phi) {
|
void Spatial::RotateY(float phi) {
|
||||||
Transform t = this->GetTransform();
|
Transform t = this->GetTransform();
|
||||||
t.rotation.y += phi;
|
t.rotation.y += phi;
|
||||||
this->SetTransform(t);
|
this->SetTransform(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spatial::RotateZ(cfloat phi) {
|
void Spatial::RotateZ(float phi) {
|
||||||
Transform t = this->GetTransform();
|
Transform t = this->GetTransform();
|
||||||
t.rotation.z += phi;
|
t.rotation.z += phi;
|
||||||
this->SetTransform(t);
|
this->SetTransform(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spatial::UniformScale(cfloat scale) {
|
void Spatial::UniformScale(float scale) {
|
||||||
Transform t = this->GetTransform();
|
Transform t = this->GetTransform();
|
||||||
t.scale *= scale;
|
t.scale *= scale;
|
||||||
this->SetTransform(t);
|
this->SetTransform(t);
|
||||||
|
@ -56,22 +56,22 @@ public:
|
|||||||
Rotates the Camera phi radians about the X axis
|
Rotates the Camera phi radians about the X axis
|
||||||
@param phi The amount to rotate in radians
|
@param phi The amount to rotate in radians
|
||||||
*/
|
*/
|
||||||
void RotateX(cfloat phi);
|
void RotateX(float phi);
|
||||||
/**
|
/**
|
||||||
Rotates the Camera phi radians about the Y axis
|
Rotates the Camera phi radians about the Y axis
|
||||||
@param phi The amount to rotate in radians
|
@param phi The amount to rotate in radians
|
||||||
*/
|
*/
|
||||||
void RotateY(cfloat phi);
|
void RotateY(float phi);
|
||||||
/**
|
/**
|
||||||
Rotates the Camera phi radians about the Z axis
|
Rotates the Camera phi radians about the Z axis
|
||||||
@param phi The amount to rotate in radians
|
@param phi The amount to rotate in radians
|
||||||
*/
|
*/
|
||||||
void RotateZ(cfloat phi);
|
void RotateZ(float phi);
|
||||||
/**
|
/**
|
||||||
Scales the spatial by scale uniformly
|
Scales the spatial by scale uniformly
|
||||||
@param scale The amount to scale by.
|
@param scale The amount to scale by.
|
||||||
*/
|
*/
|
||||||
void UniformScale(cfloat scale);
|
void UniformScale(float scale);
|
||||||
|
|
||||||
virtual Spatial *Create();
|
virtual Spatial *Create();
|
||||||
virtual Spatial *Duplicate();
|
virtual Spatial *Duplicate();
|
||||||
|
@ -11,7 +11,7 @@ Vertex::Vertex() {
|
|||||||
v = 0.0f;
|
v = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vertex::Vertex(cfloat x, cfloat y, cfloat z) {
|
Vertex::Vertex(float x, float y, float z) {
|
||||||
this->x = x;
|
this->x = x;
|
||||||
this->y = y;
|
this->y = y;
|
||||||
this->z = z;
|
this->z = z;
|
||||||
@ -22,7 +22,7 @@ Vertex::Vertex(cfloat x, cfloat y, cfloat z) {
|
|||||||
this->v = 0.0f;
|
this->v = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vertex::Vertex(cfloat x, cfloat y, cfloat z, cfloat u, cfloat v) {
|
Vertex::Vertex(float x, float y, float z, float u, float v) {
|
||||||
this->x = x;
|
this->x = x;
|
||||||
this->y = y;
|
this->y = y;
|
||||||
this->z = z;
|
this->z = z;
|
||||||
@ -33,9 +33,9 @@ Vertex::Vertex(cfloat x, cfloat y, cfloat z, cfloat u, cfloat v) {
|
|||||||
this->v = v;
|
this->v = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vertex::Vertex(cfloat x, cfloat y, cfloat z,
|
Vertex::Vertex(float x, float y, float z,
|
||||||
cfloat nx, float ny, cfloat nz,
|
float nx, float ny, float nz,
|
||||||
cfloat u, cfloat v) {
|
float u, float v) {
|
||||||
this->x = x;
|
this->x = x;
|
||||||
this->y = y;
|
this->y = y;
|
||||||
this->z = z;
|
this->z = z;
|
||||||
|
@ -7,14 +7,14 @@
|
|||||||
|
|
||||||
struct Vertex {
|
struct Vertex {
|
||||||
Vertex();
|
Vertex();
|
||||||
Vertex(cfloat x, cfloat y, cfloat z);
|
Vertex(float x, float y, float z);
|
||||||
Vertex(cfloat x, cfloat y, cfloat z, cfloat u, cfloat v);
|
Vertex(float x, float y, float z, float u, float v);
|
||||||
Vertex(cfloat x, cfloat y, cfloat z,
|
Vertex(float x, float y, float z,
|
||||||
cfloat nx, float ny, cfloat nz,
|
float nx, float ny, float nz,
|
||||||
cfloat u, cfloat v);
|
float u, float v);
|
||||||
cfloat x, y, z;
|
float x, y, z;
|
||||||
cfloat nx, ny, nz;
|
float nx, ny, nz;
|
||||||
cfloat u, v;
|
float u, v;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<Vertex> VertexList;
|
typedef std::vector<Vertex> VertexList;
|
||||||
|
@ -12,7 +12,7 @@ void World::AddRigidbody(Rigidbody *rigidbody) {
|
|||||||
btWorld->addRigidBody(rigidbody->btBody);
|
btWorld->addRigidBody(rigidbody->btBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::Step(cfloat delta) {
|
void World::Step(float delta) {
|
||||||
btWorld->stepSimulation(delta);
|
btWorld->stepSimulation(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class World {
|
|||||||
public:
|
public:
|
||||||
static World* GetWorld();
|
static World* GetWorld();
|
||||||
void AddRigidbody(Rigidbody *rigidbody);
|
void AddRigidbody(Rigidbody *rigidbody);
|
||||||
void Step(cfloat delta);
|
void Step(float delta);
|
||||||
private:
|
private:
|
||||||
static World* world;
|
static World* world;
|
||||||
btDiscreteDynamicsWorld *btWorld;
|
btDiscreteDynamicsWorld *btWorld;
|
||||||
|
@ -10,7 +10,7 @@ Vector3 operator+(const Vector3 &r, const Vector3 &l) {
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 operator*(const Vector3 &r, const cfloat &l) {
|
Vector3 operator*(const Vector3 &r, const float &l) {
|
||||||
Vector3 val(0.0f);
|
Vector3 val(0.0f);
|
||||||
val.x = r.x * l;
|
val.x = r.x * l;
|
||||||
val.y = r.y * l;
|
val.y = r.y * l;
|
||||||
|
@ -12,10 +12,9 @@ typedef GLFWwindow Window;
|
|||||||
typedef glm::vec3 Vector3;
|
typedef glm::vec3 Vector3;
|
||||||
typedef glm::mat4 Matrix;
|
typedef glm::mat4 Matrix;
|
||||||
typedef std::string Name;
|
typedef std::string Name;
|
||||||
typedef GLfloat cfloat;
|
|
||||||
typedef GLuint Id;
|
typedef GLuint Id;
|
||||||
|
|
||||||
Vector3 operator*(const Vector3 &r, const cfloat &l);
|
Vector3 operator*(const Vector3 &r, const float &l);
|
||||||
Vector3 operator+(const Vector3 &r, const Vector3 &l);
|
Vector3 operator+(const Vector3 &r, const Vector3 &l);
|
||||||
|
|
||||||
#endif /* TYPES_H */
|
#endif /* TYPES_H */
|
||||||
|
@ -20,21 +20,18 @@
|
|||||||
#include "CollisionShape.h"
|
#include "CollisionShape.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
typedef float cfloat;
|
|
||||||
%ignore "cfloat";
|
|
||||||
|
|
||||||
class Vector3 {
|
class Vector3 {
|
||||||
public:
|
public:
|
||||||
Vector3();
|
Vector3();
|
||||||
Vector3(cfloat x, cfloat y, cfloat z);
|
Vector3(float x, float y, float z);
|
||||||
cfloat x, y, z;
|
float x, y, z;
|
||||||
};
|
};
|
||||||
|
|
||||||
%extend Vector3 {
|
%extend Vector3 {
|
||||||
Vector3 operator+(const Vector3 &o) const {
|
Vector3 operator+(const Vector3 &o) const {
|
||||||
return *$self + o;
|
return *$self + o;
|
||||||
}
|
}
|
||||||
Vector3 operator*(const cfloat &o) const {
|
Vector3 operator*(const float &o) const {
|
||||||
return *$self * o;
|
return *$self * o;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user