Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux c++11 #22

Open
wants to merge 10 commits into
base: c++11
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# CYCLONEPHYSICS LIB
CXXFLAGS=-O2 -I./include -fPIC
CYCLONEOBJS=src/body.o src/collide_coarse.o src/collide_fine.o src/contacts.o src/core.o src/fgen.o src/joints.o src/particle.o src/pcontacts.o src/pfgen.o src/plinks.o src/pworld.o src/random.o src/world.o


# DEMO FILES
SOURCES=body
LDFLAGS=-lGL -lglut -lGLU -L./Debug -std=c++0x
DEMO_CPP=./src/demos/app.cpp ./src/demos/timing.cpp ./src/demos/main.cpp
CYCLONELIB=./lib/libcyclone.so

DEMOS=ballistic bigballistic blob bridge explosion fireworks flightsim fracture platform ragdoll sailboat



all: libcyclone.so $(DEMOS)

libcyclone.so: $(CYCLONEOBJS)
$(CXX) $(CYCLONEOBJS) -shared -dynamiclib -o lib/libcyclone.so

$(DEMOS):
$(CXX) -o ./bin/$@ $(DEMO_CPP) $(CYCLONELIB) ./src/demos/$@/[email protected] $(CXXFLAGS) $(LDFLAGS)


clean:
rm -f src/*.o lib/libcyclone.so
rm -f \
./bin/fireworks \
./bin/fracture \
./bin/flightsim \
./bin/bridge \
./bin/sailboat \
./bin/explosion \
./bin/ballistic \
./bin/platform \
./bin/bigballistic \
./bin/blob \
./bin/ragdoll
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions include/cyclone/collide_fine.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ namespace cyclone {
* and intersection routines, so they should have
* access to its data.
*/
friend IntersectionTests;
friend CollisionDetector;
friend class IntersectionTests;
friend class CollisionDetector;

/**
* The rigid body that is represented by this primitive.
Expand Down Expand Up @@ -309,4 +309,4 @@ namespace cyclone {

} // namespace cyclone

#endif // CYCLONE_COLLISION_FINE_H
#endif // CYCLONE_COLLISION_FINE_H
2 changes: 1 addition & 1 deletion include/cyclone/contacts.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace cyclone {
* The contact resolver object needs access into the contacts to
* set and effect the contact.
*/
friend ContactResolver;
friend class ContactResolver;

public:
/**
Expand Down
3 changes: 2 additions & 1 deletion include/cyclone/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@
* the accompanying software and documentation license.
*/

#include <math.h>
#include <cmath>
#include <cstddef>

/**
* @file
Expand Down
4 changes: 2 additions & 2 deletions include/cyclone/pcontacts.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace cyclone {
* The contact resolver object needs access into the contacts to
* set and effect the contact.
*/
friend ParticleContactResolver;
friend class ParticleContactResolver;


public:
Expand Down Expand Up @@ -194,4 +194,4 @@ namespace cyclone {

} // namespace cyclone

#endif // CYCLONE_CONTACTS_H
#endif // CYCLONE_CONTACTS_H
11 changes: 10 additions & 1 deletion include/cyclone/random.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ namespace cyclone {
class Random
{
public:
/**
* left bitwise rotation
*/

unsigned rotl(unsigned n, unsigned r);
/**
* right bitwise rotation
*/
unsigned rotr(unsigned n, unsigned r);

/**
* Creates a new random number stream with a seed based on
Expand Down Expand Up @@ -122,4 +131,4 @@ namespace cyclone {

} // namespace cyclone

#endif // CYCLONE_BODY_H
#endif // CYCLONE_BODY_H
2 changes: 1 addition & 1 deletion include/cyclone/world.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ namespace cyclone {

} // namespace cyclone

#endif // CYCLONE_PWORLD_H
#endif // CYCLONE_PWORLD_H
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions src/collide_fine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ static inline real penetrationOnAxis(
static inline bool tryAxis(
const CollisionBox &one,
const CollisionBox &two,
Vector3& axis,
Vector3 axis,
const Vector3& toCentre,
unsigned index,

Expand Down Expand Up @@ -420,7 +420,7 @@ unsigned CollisionDetector::boxAndBox(

// We start assuming there is no contact
real pen = REAL_MAX;
unsigned best = 0xffffff;
unsigned best = (~0);

// Now we check each axes, returning if it gives us
// a separating axis, and keeping track of the axis with
Expand Down Expand Up @@ -448,7 +448,7 @@ unsigned CollisionDetector::boxAndBox(
CHECK_OVERLAP(one.getAxis(2) % two.getAxis(2), 14);

// Make sure we've got a result.
assert(best != 0xffffff);
assert(best != (~0));

// We now know there's a collision, and we know which
// of the axes gave the smallest penetration. We now
Expand Down Expand Up @@ -695,10 +695,10 @@ unsigned CollisionDetector::boxAndHalfSpace(
// Move onto the next contact
contact++;
contactsUsed++;
if (contactsUsed == data->contactsLeft) return contactsUsed;
if (contactsUsed == (unsigned)data->contactsLeft) return contactsUsed;
}
}

data->addContacts(contactsUsed);
return contactsUsed;
}
}
3 changes: 2 additions & 1 deletion src/contacts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ void Contact::calculateDesiredDeltaVelocity(real duration)

if (body[0]->getAwake())
{
body[0]->getLastFrameAcceleration() * duration * contactNormal;
velocityFromAcc+=
body[0]->getLastFrameAcceleration() * duration * contactNormal;
}

if (body[1] && body[1]->getAwake())
Expand Down
4 changes: 2 additions & 2 deletions src/demos/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void MassAggregateApplication::display()
p++)
{
cyclone::Particle *particle = *p;
cyclone::Vector3 &pos = particle->getPosition();
const cyclone::Vector3 &pos = particle->getPosition();
glPushMatrix();
glTranslatef(pos.x, pos.y, pos.z);
glutSolidSphere(0.1f, 20, 10);
Expand Down Expand Up @@ -324,4 +324,4 @@ void RigidBodyApplication::key(unsigned char key)
}

Application::key(key);
}
}
4 changes: 2 additions & 2 deletions src/demos/ballistic/ballistic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class BallisticDemo : public Application
{
cyclone::Particle particle;
ShotType type;
unsigned startTime;
double startTime;

/** Draws the round. */
void render()
Expand Down Expand Up @@ -272,4 +272,4 @@ void BallisticDemo::key(unsigned char key)
Application* getApplication()
{
return new BallisticDemo();
}
}
4 changes: 2 additions & 2 deletions src/demos/bigballistic/bigballistic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AmmoRound : public cyclone::CollisionSphere
{
public:
ShotType type;
unsigned startTime;
double startTime;

AmmoRound()
{
Expand Down Expand Up @@ -460,4 +460,4 @@ void BigBallisticDemo::key(unsigned char key)
Application* getApplication()
{
return new BigBallisticDemo();
}
}
12 changes: 6 additions & 6 deletions src/demos/fireworks/fireworks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include <stdio.h>

static cyclone::Random random;
static cyclone::Random crandom;

/**
* Fireworks are particles, with additional data for rendering and
Expand Down Expand Up @@ -143,7 +143,7 @@ struct FireworkRule
void create(Firework *firework, const Firework *parent = NULL) const
{
firework->type = type;
firework->age = random.randomReal(minAge, maxAge);
firework->age = crandom.randomReal(minAge, maxAge);

cyclone::Vector3 vel;
if (parent) {
Expand All @@ -154,12 +154,12 @@ struct FireworkRule
else
{
cyclone::Vector3 start;
int x = (int)random.randomInt(3) - 1;
int x = (int)crandom.randomInt(3) - 1;
start.x = 5.0f * cyclone::real(x);
firework->setPosition(start);
}

vel += random.randomVector(minVelocity, maxVelocity);
vel += crandom.randomVector(minVelocity, maxVelocity);
firework->setVelocity(vel);

// We use a mass of one in all cases (no point having fireworks
Expand Down Expand Up @@ -442,7 +442,7 @@ void FireworksDemo::display()
case 9: glColor3f(1,0.5f,0.5f); break;
};

cyclone::Vector3 &pos = firework->getPosition();
const cyclone::Vector3 &pos = firework->getPosition();
glVertex3f(pos.x-size, pos.y-size, pos.z);
glVertex3f(pos.x+size, pos.y-size, pos.z);
glVertex3f(pos.x+size, pos.y+size, pos.z);
Expand Down Expand Up @@ -481,4 +481,4 @@ void FireworksDemo::key(unsigned char key)
Application* getApplication()
{
return new FireworksDemo();
}
}
4 changes: 2 additions & 2 deletions src/demos/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void motion(int x, int y)
/**
* The main entry point. We pass arguments onto GLUT.
*/
void main(int argc, char** argv)
int main(int argc, char** argv)
{
// Set up GLUT and the timers
glutInit(&argc, argv);
Expand All @@ -126,4 +126,4 @@ void main(int argc, char** argv)
app->deinit();
delete app;
TimingData::deinit();
}
}
Loading