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