Added Box2D
This commit is contained in:
119
external/Box2D-2.3.1/Contributions/Enhancements/Controllers/b2BuoyancyController.cpp
vendored
Normal file
119
external/Box2D-2.3.1/Contributions/Enhancements/Controllers/b2BuoyancyController.cpp
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "b2BuoyancyController.h"
|
||||
#include "../b2Fixture.h"
|
||||
|
||||
b2BuoyancyController::b2BuoyancyController(const b2BuoyancyControllerDef* def) : b2Controller(def)
|
||||
{
|
||||
normal = def->normal;
|
||||
offset = def->offset;
|
||||
density = def->density;
|
||||
velocity = def->velocity;
|
||||
linearDrag = def->linearDrag;
|
||||
angularDrag = def->angularDrag;
|
||||
useDensity = def->useDensity;
|
||||
useWorldGravity = def->useWorldGravity;
|
||||
gravity = def->gravity;
|
||||
}
|
||||
|
||||
void b2BuoyancyController::Step(const b2TimeStep& step)
|
||||
{
|
||||
B2_NOT_USED(step);
|
||||
if(!m_bodyList)
|
||||
return;
|
||||
if(useWorldGravity)
|
||||
{
|
||||
gravity = m_world->GetGravity();
|
||||
}
|
||||
for(b2ControllerEdge *i=m_bodyList;i;i=i->nextBody)
|
||||
{
|
||||
b2Body* body = i->body;
|
||||
if(body->IsSleeping())
|
||||
{
|
||||
//Buoyancy force is just a function of position,
|
||||
//so unlike most forces, it is safe to ignore sleeping bodes
|
||||
continue;
|
||||
}
|
||||
b2Vec2 areac(0,0);
|
||||
b2Vec2 massc(0,0);
|
||||
float32 area = 0;
|
||||
float32 mass = 0;
|
||||
for(b2Fixture* shape=body->GetFixtureList();shape;shape=shape->GetNext())
|
||||
{
|
||||
b2Vec2 sc(0,0);
|
||||
float32 sarea = shape->ComputeSubmergedArea(normal, offset, &sc);
|
||||
area += sarea;
|
||||
areac.x += sarea * sc.x;
|
||||
areac.y += sarea * sc.y;
|
||||
float shapeDensity = 0;
|
||||
if(useDensity)
|
||||
{
|
||||
//TODO: Expose density publicly
|
||||
shapeDensity=shape->GetDensity();
|
||||
}
|
||||
else
|
||||
{
|
||||
shapeDensity = 1;
|
||||
}
|
||||
mass += sarea*shapeDensity;
|
||||
massc.x += sarea * sc.x * shapeDensity;
|
||||
massc.y += sarea * sc.y * shapeDensity;
|
||||
}
|
||||
areac.x/=area;
|
||||
areac.y/=area;
|
||||
b2Vec2 localCentroid = b2MulT(body->GetXForm(),areac);
|
||||
massc.x/=mass;
|
||||
massc.y/=mass;
|
||||
if(area<B2_FLT_EPSILON)
|
||||
continue;
|
||||
//Buoyancy
|
||||
b2Vec2 buoyancyForce = -density*area*gravity;
|
||||
body->ApplyForce(buoyancyForce,massc);
|
||||
//Linear drag
|
||||
b2Vec2 dragForce = body->GetLinearVelocityFromWorldPoint(areac) - velocity;
|
||||
dragForce *= -linearDrag*area;
|
||||
body->ApplyForce(dragForce,areac);
|
||||
//Angular drag
|
||||
//TODO: Something that makes more physical sense?
|
||||
body->ApplyTorque(-body->GetInertia()/body->GetMass()*area*body->GetAngularVelocity()*angularDrag);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void b2BuoyancyController::Draw(b2DebugDraw *debugDraw)
|
||||
{
|
||||
float32 r = 1000;
|
||||
b2Vec2 p1 = offset * normal + b2Cross(normal, r);
|
||||
b2Vec2 p2 = offset * normal - b2Cross(normal, r);
|
||||
|
||||
b2Color color(0,0,0.8f);
|
||||
|
||||
debugDraw->DrawSegment(p1, p2, color);
|
||||
}
|
||||
|
||||
void b2BuoyancyController::Destroy(b2BlockAllocator* allocator)
|
||||
{
|
||||
allocator->Free(this, sizeof(b2BuoyancyController));
|
||||
}
|
||||
|
||||
b2BuoyancyController* b2BuoyancyControllerDef::Create(b2BlockAllocator* allocator) const
|
||||
{
|
||||
void* mem = allocator->Allocate(sizeof(b2BuoyancyController));
|
||||
return new (mem) b2BuoyancyController(this);
|
||||
}
|
||||
102
external/Box2D-2.3.1/Contributions/Enhancements/Controllers/b2BuoyancyController.h
vendored
Normal file
102
external/Box2D-2.3.1/Contributions/Enhancements/Controllers/b2BuoyancyController.h
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef B2_BUOYANCYCONTROLLER_H
|
||||
#define B2_BUOYANCYCONTROLLER_H
|
||||
|
||||
#include "b2Controller.h"
|
||||
|
||||
class b2BuoyancyControllerDef;
|
||||
|
||||
/// Calculates buoyancy forces for fluids in the form of a half plane.
|
||||
class b2BuoyancyController : public b2Controller{
|
||||
public:
|
||||
/// The outer surface normal
|
||||
b2Vec2 normal;
|
||||
/// The height of the fluid surface along the normal
|
||||
float32 offset;
|
||||
/// The fluid density
|
||||
float32 density;
|
||||
/// Fluid velocity, for drag calculations
|
||||
b2Vec2 velocity;
|
||||
/// Linear drag co-efficient
|
||||
float32 linearDrag;
|
||||
/// Linear drag co-efficient
|
||||
float32 angularDrag;
|
||||
/// If false, bodies are assumed to be uniformly dense, otherwise use the shapes densities
|
||||
bool useDensity; //False by default to prevent a gotcha
|
||||
/// If true, gravity is taken from the world instead of the gravity parameter.
|
||||
bool useWorldGravity;
|
||||
/// Gravity vector, if the world's gravity is not used
|
||||
b2Vec2 gravity;
|
||||
|
||||
/// @see b2Controller::Step
|
||||
void Step(const b2TimeStep& step);
|
||||
|
||||
/// @see b2Controller::Draw
|
||||
void Draw(b2DebugDraw *debugDraw);
|
||||
|
||||
protected:
|
||||
void Destroy(b2BlockAllocator* allocator);
|
||||
|
||||
private:
|
||||
friend class b2BuoyancyControllerDef;
|
||||
b2BuoyancyController(const b2BuoyancyControllerDef* def);
|
||||
};
|
||||
|
||||
/// This class is used to build buoyancy controllers
|
||||
class b2BuoyancyControllerDef : public b2ControllerDef
|
||||
{
|
||||
public:
|
||||
/// The outer surface normal
|
||||
b2Vec2 normal;
|
||||
/// The height of the fluid surface along the normal
|
||||
float32 offset;
|
||||
/// The fluid density
|
||||
float32 density;
|
||||
/// Fluid velocity, for drag calculations
|
||||
b2Vec2 velocity;
|
||||
/// Linear drag co-efficient
|
||||
float32 linearDrag;
|
||||
/// Linear drag co-efficient
|
||||
float32 angularDrag;
|
||||
/// If false, bodies are assumed to be uniformly dense, otherwise use the shapes densities
|
||||
bool useDensity; //False by default to prevent a gotcha
|
||||
/// If true, gravity is taken from the world instead of the gravity parameter.
|
||||
bool useWorldGravity;
|
||||
/// Gravity vector, if the world's gravity is not used
|
||||
b2Vec2 gravity;
|
||||
|
||||
b2BuoyancyControllerDef():
|
||||
normal(0,1),
|
||||
offset(0),
|
||||
density(0),
|
||||
velocity(0,0),
|
||||
linearDrag(0),
|
||||
angularDrag(0),
|
||||
useDensity(false),
|
||||
useWorldGravity(true),
|
||||
gravity(0,0)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
b2BuoyancyController* Create(b2BlockAllocator* allocator) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
46
external/Box2D-2.3.1/Contributions/Enhancements/Controllers/b2ConstantAccelController.cpp
vendored
Normal file
46
external/Box2D-2.3.1/Contributions/Enhancements/Controllers/b2ConstantAccelController.cpp
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "b2ConstantAccelController.h"
|
||||
|
||||
b2ConstantAccelController::b2ConstantAccelController(const b2ConstantAccelControllerDef* def) : b2Controller(def)
|
||||
{
|
||||
A = def->A;
|
||||
}
|
||||
|
||||
void b2ConstantAccelController::Step(const b2TimeStep& step)
|
||||
{
|
||||
for(b2ControllerEdge *i=m_bodyList;i;i=i->nextBody){
|
||||
b2Body* body = i->body;
|
||||
if(body->IsSleeping())
|
||||
continue;
|
||||
body->SetLinearVelocity(body->GetLinearVelocity()+step.dt*A);
|
||||
}
|
||||
}
|
||||
|
||||
void b2ConstantAccelController::Destroy(b2BlockAllocator* allocator)
|
||||
{
|
||||
allocator->Free(this, sizeof(b2ConstantAccelController));
|
||||
}
|
||||
|
||||
|
||||
b2ConstantAccelController* b2ConstantAccelControllerDef::Create(b2BlockAllocator* allocator) const
|
||||
{
|
||||
void* mem = allocator->Allocate(sizeof(b2ConstantAccelController));
|
||||
return new (mem) b2ConstantAccelController(this);
|
||||
}
|
||||
54
external/Box2D-2.3.1/Contributions/Enhancements/Controllers/b2ConstantAccelController.h
vendored
Normal file
54
external/Box2D-2.3.1/Contributions/Enhancements/Controllers/b2ConstantAccelController.h
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef B2_CONSTANTACCELCONTROLLER_H
|
||||
#define B2_CONSTANTACCELCONTROLLER_H
|
||||
|
||||
#include "b2Controller.h"
|
||||
|
||||
class b2ConstantAccelControllerDef;
|
||||
|
||||
/// Applies a force every frame
|
||||
class b2ConstantAccelController : public b2Controller{
|
||||
public:
|
||||
/// The force to apply
|
||||
b2Vec2 A;
|
||||
|
||||
/// @see b2Controller::Step
|
||||
void Step(const b2TimeStep& step);
|
||||
|
||||
protected:
|
||||
void Destroy(b2BlockAllocator* allocator);
|
||||
|
||||
private:
|
||||
friend class b2ConstantAccelControllerDef;
|
||||
b2ConstantAccelController(const b2ConstantAccelControllerDef* def);
|
||||
|
||||
};
|
||||
|
||||
/// This class is used to build constant acceleration controllers
|
||||
class b2ConstantAccelControllerDef : public b2ControllerDef
|
||||
{
|
||||
public:
|
||||
/// The force to apply
|
||||
b2Vec2 A;
|
||||
private:
|
||||
b2ConstantAccelController* Create(b2BlockAllocator* allocator) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
47
external/Box2D-2.3.1/Contributions/Enhancements/Controllers/b2ConstantForceController.cpp
vendored
Normal file
47
external/Box2D-2.3.1/Contributions/Enhancements/Controllers/b2ConstantForceController.cpp
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "b2ConstantForceController.h"
|
||||
|
||||
b2ConstantForceController::b2ConstantForceController(const b2ConstantForceControllerDef* def) : b2Controller(def)
|
||||
{
|
||||
F = def->F;
|
||||
}
|
||||
|
||||
void b2ConstantForceController::Step(const b2TimeStep& step)
|
||||
{
|
||||
B2_NOT_USED(step);
|
||||
for(b2ControllerEdge *i=m_bodyList;i;i=i->nextBody){
|
||||
b2Body* body = i->body;
|
||||
if(body->IsSleeping())
|
||||
continue;
|
||||
body->ApplyForce(F,body->GetWorldCenter());
|
||||
}
|
||||
}
|
||||
|
||||
void b2ConstantForceController::Destroy(b2BlockAllocator* allocator)
|
||||
{
|
||||
allocator->Free(this, sizeof(b2ConstantForceController));
|
||||
}
|
||||
|
||||
|
||||
b2ConstantForceController* b2ConstantForceControllerDef::Create(b2BlockAllocator* allocator) const
|
||||
{
|
||||
void* mem = allocator->Allocate(sizeof(b2ConstantForceController));
|
||||
return new (mem) b2ConstantForceController(this);
|
||||
}
|
||||
54
external/Box2D-2.3.1/Contributions/Enhancements/Controllers/b2ConstantForceController.h
vendored
Normal file
54
external/Box2D-2.3.1/Contributions/Enhancements/Controllers/b2ConstantForceController.h
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef B2_CONSTANTFORCECONTROLLER_H
|
||||
#define B2_CONSTANTFORCECONTROLLER_H
|
||||
|
||||
#include "b2Controller.h"
|
||||
|
||||
class b2ConstantForceControllerDef;
|
||||
|
||||
/// Applies a force every frame
|
||||
class b2ConstantForceController : public b2Controller
|
||||
{
|
||||
public:
|
||||
/// The force to apply
|
||||
b2Vec2 F;
|
||||
|
||||
/// @see b2Controller::Step
|
||||
void Step(const b2TimeStep& step);
|
||||
|
||||
protected:
|
||||
void Destroy(b2BlockAllocator* allocator);
|
||||
|
||||
private:
|
||||
friend class b2ConstantForceControllerDef;
|
||||
b2ConstantForceController(const b2ConstantForceControllerDef* def);
|
||||
};
|
||||
|
||||
/// This class is used to build constant force controllers
|
||||
class b2ConstantForceControllerDef : public b2ControllerDef
|
||||
{
|
||||
public:
|
||||
/// The force to apply
|
||||
b2Vec2 F;
|
||||
private:
|
||||
b2ConstantForceController* Create(b2BlockAllocator* allocator) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
110
external/Box2D-2.3.1/Contributions/Enhancements/Controllers/b2Controller.cpp
vendored
Normal file
110
external/Box2D-2.3.1/Contributions/Enhancements/Controllers/b2Controller.cpp
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "b2Controller.h"
|
||||
#include "../../Common/b2BlockAllocator.h"
|
||||
|
||||
|
||||
b2Controller::~b2Controller()
|
||||
{
|
||||
//Remove attached bodies
|
||||
Clear();
|
||||
}
|
||||
|
||||
void b2Controller::AddBody(b2Body* body)
|
||||
{
|
||||
void* mem = m_world->m_blockAllocator.Allocate(sizeof(b2ControllerEdge));
|
||||
b2ControllerEdge* edge = new (mem) b2ControllerEdge;
|
||||
|
||||
edge->body = body;
|
||||
edge->controller = this;
|
||||
|
||||
//Add edge to controller list
|
||||
edge->nextBody = m_bodyList;
|
||||
edge->prevBody = NULL;
|
||||
if(m_bodyList)
|
||||
m_bodyList->prevBody = edge;
|
||||
m_bodyList = edge;
|
||||
++m_bodyCount;
|
||||
|
||||
//Add edge to body list
|
||||
edge->nextController = body->m_controllerList;
|
||||
edge->prevController = NULL;
|
||||
if(body->m_controllerList)
|
||||
body->m_controllerList->prevController = edge;
|
||||
body->m_controllerList = edge;
|
||||
}
|
||||
|
||||
void b2Controller::RemoveBody(b2Body* body)
|
||||
{
|
||||
//Assert that the controller is not empty
|
||||
b2Assert(m_bodyCount>0);
|
||||
|
||||
//Find the corresponding edge
|
||||
b2ControllerEdge* edge = m_bodyList;
|
||||
while(edge && edge->body!=body)
|
||||
edge = edge->nextBody;
|
||||
|
||||
//Assert that we are removing a body that is currently attached to the controller
|
||||
b2Assert(edge!=NULL);
|
||||
|
||||
//Remove edge from controller list
|
||||
if(edge->prevBody)
|
||||
edge->prevBody->nextBody = edge->nextBody;
|
||||
if(edge->nextBody)
|
||||
edge->nextBody->prevBody = edge->prevBody;
|
||||
if(edge == m_bodyList)
|
||||
m_bodyList = edge->nextBody;
|
||||
--m_bodyCount;
|
||||
|
||||
//Remove edge from body list
|
||||
if(edge->prevController)
|
||||
edge->prevController->nextController = edge->nextController;
|
||||
if(edge->nextController)
|
||||
edge->nextController->prevController = edge->prevController;
|
||||
if(edge == body->m_controllerList)
|
||||
body->m_controllerList = edge->nextController;
|
||||
|
||||
//Free the edge
|
||||
m_world->m_blockAllocator.Free(edge, sizeof(b2ControllerEdge));
|
||||
}
|
||||
|
||||
void b2Controller::Clear(){
|
||||
|
||||
while(m_bodyList)
|
||||
{
|
||||
b2ControllerEdge* edge = m_bodyList;
|
||||
|
||||
//Remove edge from controller list
|
||||
m_bodyList = edge->nextBody;
|
||||
|
||||
//Remove edge from body list
|
||||
if(edge->prevController)
|
||||
edge->prevController->nextController = edge->nextController;
|
||||
if(edge->nextController)
|
||||
edge->nextController->prevController = edge->prevController;
|
||||
if(edge == edge->body->m_controllerList)
|
||||
edge->body->m_controllerList = edge->nextController;
|
||||
|
||||
//Free the edge
|
||||
m_world->m_blockAllocator.Free(edge, sizeof(b2ControllerEdge));
|
||||
}
|
||||
|
||||
m_bodyCount = 0;
|
||||
}
|
||||
|
||||
151
external/Box2D-2.3.1/Contributions/Enhancements/Controllers/b2Controller.h
vendored
Normal file
151
external/Box2D-2.3.1/Contributions/Enhancements/Controllers/b2Controller.h
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef B2_CONTROLLER_H
|
||||
#define B2_CONTROLLER_H
|
||||
|
||||
#include "../../Dynamics/b2World.h"
|
||||
#include "../../Dynamics/b2Body.h"
|
||||
|
||||
class b2Body;
|
||||
class b2World;
|
||||
|
||||
class b2Controller;
|
||||
|
||||
/// A controller edge is used to connect bodies and controllers together
|
||||
/// in a bipartite graph.
|
||||
struct b2ControllerEdge
|
||||
{
|
||||
b2Controller* controller; ///< provides quick access to other end of this edge.
|
||||
b2Body* body; ///< the body
|
||||
b2ControllerEdge* prevBody; ///< the previous controller edge in the controllers's joint list
|
||||
b2ControllerEdge* nextBody; ///< the next controller edge in the controllers's joint list
|
||||
b2ControllerEdge* prevController; ///< the previous controller edge in the body's joint list
|
||||
b2ControllerEdge* nextController; ///< the next controller edge in the body's joint list
|
||||
};
|
||||
|
||||
class b2ControllerDef;
|
||||
|
||||
/// Base class for controllers. Controllers are a convience for encapsulating common
|
||||
/// per-step functionality.
|
||||
class b2Controller
|
||||
{
|
||||
public:
|
||||
virtual ~b2Controller();
|
||||
|
||||
/// Controllers override this to implement per-step functionality.
|
||||
virtual void Step(const b2TimeStep& step) = 0;
|
||||
|
||||
/// Controllers override this to provide debug drawing.
|
||||
virtual void Draw(b2DebugDraw *debugDraw) {B2_NOT_USED(debugDraw);};
|
||||
|
||||
/// Adds a body to the controller list.
|
||||
void AddBody(b2Body* body);
|
||||
|
||||
/// Removes a body from the controller list.
|
||||
void RemoveBody(b2Body* body);
|
||||
|
||||
/// Removes all bodies from the controller list.
|
||||
void Clear();
|
||||
|
||||
/// Get the next controller in the world's body list.
|
||||
b2Controller* GetNext();
|
||||
const b2Controller* GetNext() const;
|
||||
|
||||
/// Get the parent world of this body.
|
||||
b2World* GetWorld();
|
||||
const b2World* GetWorld() const;
|
||||
|
||||
/// Get the attached body list
|
||||
b2ControllerEdge* GetBodyList();
|
||||
const b2ControllerEdge* GetBodyList() const;
|
||||
|
||||
|
||||
protected:
|
||||
friend class b2World;
|
||||
|
||||
b2World* m_world;
|
||||
|
||||
b2ControllerEdge* m_bodyList;
|
||||
int32 m_bodyCount;
|
||||
|
||||
b2Controller(const b2ControllerDef* def):
|
||||
m_world(NULL),
|
||||
m_bodyList(NULL),
|
||||
m_bodyCount(0),
|
||||
m_prev(NULL),
|
||||
m_next(NULL)
|
||||
|
||||
{
|
||||
B2_NOT_USED(def);
|
||||
}
|
||||
virtual void Destroy(b2BlockAllocator* allocator) = 0;
|
||||
|
||||
private:
|
||||
b2Controller* m_prev;
|
||||
b2Controller* m_next;
|
||||
|
||||
static void Destroy(b2Controller* controller, b2BlockAllocator* allocator);
|
||||
};
|
||||
|
||||
class b2ControllerDef
|
||||
{
|
||||
public:
|
||||
virtual ~b2ControllerDef() {};
|
||||
|
||||
private:
|
||||
friend class b2World;
|
||||
virtual b2Controller* Create(b2BlockAllocator* allocator) const = 0;
|
||||
};
|
||||
|
||||
inline b2Controller* b2Controller::GetNext()
|
||||
{
|
||||
return m_next;
|
||||
}
|
||||
|
||||
inline const b2Controller* b2Controller::GetNext() const
|
||||
{
|
||||
return m_next;
|
||||
}
|
||||
|
||||
inline b2World* b2Controller::GetWorld()
|
||||
{
|
||||
return m_world;
|
||||
}
|
||||
|
||||
inline const b2World* b2Controller::GetWorld() const
|
||||
{
|
||||
return m_world;
|
||||
}
|
||||
|
||||
inline b2ControllerEdge* b2Controller::GetBodyList()
|
||||
{
|
||||
return m_bodyList;
|
||||
}
|
||||
|
||||
inline const b2ControllerEdge* b2Controller::GetBodyList() const
|
||||
{
|
||||
return m_bodyList;
|
||||
}
|
||||
|
||||
inline void b2Controller::Destroy(b2Controller* controller, b2BlockAllocator* allocator)
|
||||
{
|
||||
controller->Destroy(allocator);
|
||||
}
|
||||
|
||||
#endif
|
||||
70
external/Box2D-2.3.1/Contributions/Enhancements/Controllers/b2GravityController.cpp
vendored
Normal file
70
external/Box2D-2.3.1/Contributions/Enhancements/Controllers/b2GravityController.cpp
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "b2GravityController.h"
|
||||
|
||||
b2GravityController::b2GravityController(const b2GravityControllerDef* def) : b2Controller(def)
|
||||
{
|
||||
G = def->G;
|
||||
invSqr = def->invSqr;
|
||||
}
|
||||
|
||||
void b2GravityController::Step(const b2TimeStep& step)
|
||||
{
|
||||
B2_NOT_USED(step);
|
||||
if(invSqr){
|
||||
for(b2ControllerEdge *i=m_bodyList;i;i=i->nextBody){
|
||||
b2Body* body1 = i->body;
|
||||
for(b2ControllerEdge *j=m_bodyList;j!=i;j=j->nextBody){
|
||||
b2Body* body2 = j->body;
|
||||
b2Vec2 d = body2->GetWorldCenter() - body1->GetWorldCenter();
|
||||
float32 r2 = d.LengthSquared();
|
||||
if(r2 < B2_FLT_EPSILON)
|
||||
continue;
|
||||
b2Vec2 f = G / r2 / sqrt(r2) * body1->GetMass() * body2->GetMass() * d;
|
||||
body1->ApplyForce(f , body1->GetWorldCenter());
|
||||
body2->ApplyForce(-1.0f*f, body2->GetWorldCenter());
|
||||
}
|
||||
}
|
||||
}else{
|
||||
for(b2ControllerEdge *i=m_bodyList;i;i=i->nextBody){
|
||||
b2Body* body1 = i->body;
|
||||
for(b2ControllerEdge *j=m_bodyList;j!=i;j=j->nextBody){
|
||||
b2Body* body2 = j->body;
|
||||
b2Vec2 d = body2->GetWorldCenter() - body1->GetWorldCenter();
|
||||
float32 r2 = d.LengthSquared();
|
||||
if(r2 < B2_FLT_EPSILON)
|
||||
continue;
|
||||
b2Vec2 f = G / r2 * body1->GetMass() * body2->GetMass() * d;
|
||||
body1->ApplyForce(f , body1->GetWorldCenter());
|
||||
body2->ApplyForce(-1.0f*f, body2->GetWorldCenter());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void b2GravityController::Destroy(b2BlockAllocator* allocator)
|
||||
{
|
||||
allocator->Free(this, sizeof(b2GravityController));
|
||||
}
|
||||
|
||||
b2GravityController* b2GravityControllerDef::Create(b2BlockAllocator* allocator) const
|
||||
{
|
||||
void* mem = allocator->Allocate(sizeof(b2GravityController));
|
||||
return new (mem) b2GravityController(this);
|
||||
}
|
||||
59
external/Box2D-2.3.1/Contributions/Enhancements/Controllers/b2GravityController.h
vendored
Normal file
59
external/Box2D-2.3.1/Contributions/Enhancements/Controllers/b2GravityController.h
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef B2_GRAVITYCONTROLLER_H
|
||||
#define B2_GRAVITYCONTROLLER_H
|
||||
|
||||
#include "b2Controller.h"
|
||||
|
||||
class b2GravityControllerDef;
|
||||
|
||||
/// Applies simplified gravity between every pair of bodies
|
||||
class b2GravityController : public b2Controller{
|
||||
public:
|
||||
/// Specifies the strength of the gravitiation force
|
||||
float32 G;
|
||||
/// If true, gravity is proportional to r^-2, otherwise r^-1
|
||||
bool invSqr;
|
||||
|
||||
/// @see b2Controller::Step
|
||||
void Step(const b2TimeStep& step);
|
||||
|
||||
protected:
|
||||
void Destroy(b2BlockAllocator* allocator);
|
||||
|
||||
private:
|
||||
friend class b2GravityControllerDef;
|
||||
b2GravityController(const b2GravityControllerDef* def);
|
||||
|
||||
|
||||
};
|
||||
|
||||
/// This class is used to build gravity controllers
|
||||
class b2GravityControllerDef : public b2ControllerDef
|
||||
{
|
||||
public:
|
||||
/// Specifies the strength of the gravitiation force
|
||||
float32 G;
|
||||
/// If true, gravity is proportional to r^-2, otherwise r^-1
|
||||
bool invSqr;
|
||||
private:
|
||||
b2GravityController* Create(b2BlockAllocator* allocator) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
72
external/Box2D-2.3.1/Contributions/Enhancements/Controllers/b2TensorDampingController.cpp
vendored
Normal file
72
external/Box2D-2.3.1/Contributions/Enhancements/Controllers/b2TensorDampingController.cpp
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "b2TensorDampingController.h"
|
||||
|
||||
b2TensorDampingController::b2TensorDampingController(const b2TensorDampingControllerDef* def) : b2Controller(def)
|
||||
{
|
||||
T = def->T;
|
||||
maxTimestep = def->maxTimestep;
|
||||
}
|
||||
|
||||
void b2TensorDampingController::Step(const b2TimeStep& step)
|
||||
{
|
||||
float32 timestep = step.dt;
|
||||
if(timestep<=B2_FLT_EPSILON)
|
||||
return;
|
||||
if(timestep>maxTimestep && maxTimestep>0)
|
||||
timestep = maxTimestep;
|
||||
for(b2ControllerEdge *i=m_bodyList;i;i=i->nextBody){
|
||||
b2Body* body = i->body;
|
||||
if(body->IsSleeping())
|
||||
continue;
|
||||
b2Vec2 damping = body->GetWorldVector(
|
||||
b2Mul(T,
|
||||
body->GetLocalVector(
|
||||
body->GetLinearVelocity()
|
||||
)
|
||||
)
|
||||
);
|
||||
body->SetLinearVelocity(body->GetLinearVelocity() + timestep * damping);
|
||||
}
|
||||
}
|
||||
|
||||
void b2TensorDampingControllerDef::SetAxisAligned(float32 xDamping, float32 yDamping)
|
||||
{
|
||||
T.col1.x = -xDamping;
|
||||
T.col1.y = 0;
|
||||
T.col2.x = 0;
|
||||
T.col2.y = -yDamping;
|
||||
if(xDamping>0 || yDamping>0){
|
||||
maxTimestep = 1/b2Max(xDamping,yDamping);
|
||||
}else{
|
||||
maxTimestep = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void b2TensorDampingController::Destroy(b2BlockAllocator* allocator)
|
||||
{
|
||||
allocator->Free(this, sizeof(b2TensorDampingController));
|
||||
}
|
||||
|
||||
|
||||
b2TensorDampingController* b2TensorDampingControllerDef::Create(b2BlockAllocator* allocator) const
|
||||
{
|
||||
void* mem = allocator->Allocate(sizeof(b2TensorDampingController));
|
||||
return new (mem) b2TensorDampingController(this);
|
||||
}
|
||||
69
external/Box2D-2.3.1/Contributions/Enhancements/Controllers/b2TensorDampingController.h
vendored
Normal file
69
external/Box2D-2.3.1/Contributions/Enhancements/Controllers/b2TensorDampingController.h
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef B2_TENSORDAMPINGCONTROLLER_H
|
||||
#define B2_TENSORDAMPINGCONTROLLER_H
|
||||
|
||||
#include "b2Controller.h"
|
||||
|
||||
class b2TensorDampingControllerDef;
|
||||
|
||||
/// Applies top down linear damping to the controlled bodies
|
||||
/// The damping is calculated by multiplying velocity by a matrix in local co-ordinates.
|
||||
class b2TensorDampingController : public b2Controller{
|
||||
public:
|
||||
/// Tensor to use in damping model
|
||||
b2Mat22 T;
|
||||
/*Some examples (matrixes in format (row1; row2) )
|
||||
(-a 0;0 -a) Standard isotropic damping with strength a
|
||||
(0 a;-a 0) Electron in fixed field - a force at right angles to velocity with proportional magnitude
|
||||
(-a 0;0 -b) Differing x and y damping. Useful e.g. for top-down wheels.
|
||||
*/
|
||||
//By the way, tensor in this case just means matrix, don't let the terminology get you down.
|
||||
|
||||
/// Set this to a positive number to clamp the maximum amount of damping done.
|
||||
float32 maxTimestep;
|
||||
// Typically one wants maxTimestep to be 1/(max eigenvalue of T), so that damping will never cause something to reverse direction
|
||||
|
||||
/// @see b2Controller::Step
|
||||
void Step(const b2TimeStep& step);
|
||||
|
||||
protected:
|
||||
void Destroy(b2BlockAllocator* allocator);
|
||||
|
||||
private:
|
||||
friend class b2TensorDampingControllerDef;
|
||||
b2TensorDampingController(const b2TensorDampingControllerDef* def);
|
||||
|
||||
};
|
||||
|
||||
/// This class is used to build tensor damping controllers
|
||||
class b2TensorDampingControllerDef : public b2ControllerDef
|
||||
{
|
||||
public:
|
||||
/// Tensor to use in damping model
|
||||
b2Mat22 T;
|
||||
/// Set this to a positive number to clamp the maximum amount of damping done.
|
||||
float32 maxTimestep;
|
||||
/// Sets damping independantly along the x and y axes
|
||||
void SetAxisAligned(float32 xDamping,float32 yDamping);
|
||||
private:
|
||||
b2TensorDampingController* Create(b2BlockAllocator* allocator) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
477
external/Box2D-2.3.1/Contributions/Enhancements/FixedPoint/Fixed.h
vendored
Normal file
477
external/Box2D-2.3.1/Contributions/Enhancements/FixedPoint/Fixed.h
vendored
Normal file
@@ -0,0 +1,477 @@
|
||||
/*
|
||||
Copyright (c) 2006 Henry Strickland & Ryan Seto
|
||||
2007-2008 Tobias Weyand (modifications and extensions)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
(* http://www.opensource.org/licenses/mit-license.php *)
|
||||
*/
|
||||
|
||||
#ifndef _FIXED_H_
|
||||
#define _FIXED_H_
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef TARGET_IS_NDS
|
||||
|
||||
#include "nds.h"
|
||||
|
||||
#endif
|
||||
|
||||
#define FIXED_BP 16
|
||||
#define FIXED_MAX ((1<<(32-FIXED_BP-1))-1)
|
||||
#define FIXED_MIN (-(1<<(32-FIXED_BP-1)))
|
||||
#define FIXED_EPSILON (Fixed(0.00007f))
|
||||
|
||||
#define G_1_DIV_PI 20861
|
||||
|
||||
class Fixed {
|
||||
|
||||
private:
|
||||
|
||||
int g; // the guts
|
||||
|
||||
const static int BP= FIXED_BP; // how many low bits are right of Binary Point
|
||||
const static int BP2= BP*2; // how many low bits are right of Binary Point
|
||||
const static int BPhalf= BP/2; // how many low bits are right of Binary Point
|
||||
|
||||
double STEP(); // smallest step we can represent
|
||||
|
||||
// for private construction via guts
|
||||
enum FixedRaw { RAW };
|
||||
Fixed(FixedRaw, int guts);
|
||||
|
||||
public:
|
||||
|
||||
Fixed();
|
||||
Fixed(const Fixed &a);
|
||||
Fixed(float a);
|
||||
Fixed(double a);
|
||||
Fixed(int a);
|
||||
Fixed(long a);
|
||||
|
||||
Fixed& operator =(const Fixed a);
|
||||
Fixed& operator =(float a);
|
||||
Fixed& operator =(double a);
|
||||
Fixed& operator =(int a);
|
||||
Fixed& operator =(long a);
|
||||
|
||||
operator float();
|
||||
operator double();
|
||||
operator int();
|
||||
operator long();
|
||||
operator unsigned short();
|
||||
|
||||
operator float() const;
|
||||
|
||||
Fixed operator +() const;
|
||||
Fixed operator -() const;
|
||||
|
||||
Fixed operator +(const Fixed a) const;
|
||||
Fixed operator -(const Fixed a) const;
|
||||
#if 1
|
||||
// more acurate, using long long
|
||||
Fixed operator *(const Fixed a) const;
|
||||
#else
|
||||
// faster, but with only half as many bits right of binary point
|
||||
Fixed operator *(const Fixed a) const;
|
||||
#endif
|
||||
Fixed operator /(const Fixed a) const;
|
||||
|
||||
Fixed operator *(unsigned short a) const;
|
||||
Fixed operator *(int a) const;
|
||||
|
||||
Fixed operator +(float a) const;
|
||||
Fixed operator -(float a) const;
|
||||
Fixed operator *(float a) const;
|
||||
Fixed operator /(float a) const;
|
||||
|
||||
Fixed operator +(double a) const;
|
||||
Fixed operator -(double a) const;
|
||||
Fixed operator *(double a) const;
|
||||
Fixed operator /(double a) const;
|
||||
|
||||
Fixed operator >>(int a) const;
|
||||
Fixed operator <<(int a) const;
|
||||
|
||||
Fixed& operator +=(Fixed a);
|
||||
Fixed& operator -=(Fixed a);
|
||||
Fixed& operator *=(Fixed a);
|
||||
Fixed& operator /=(Fixed a);
|
||||
|
||||
Fixed& operator +=(int a);
|
||||
Fixed& operator -=(int a);
|
||||
Fixed& operator *=(int a);
|
||||
Fixed& operator /=(int a);
|
||||
|
||||
Fixed& operator +=(long a);
|
||||
Fixed& operator -=(long a);
|
||||
Fixed& operator *=(long a);
|
||||
Fixed& operator /=(long a);
|
||||
|
||||
Fixed& operator +=(float a);
|
||||
Fixed& operator -=(float a);
|
||||
Fixed& operator *=(float a);
|
||||
Fixed& operator /=(float a);
|
||||
|
||||
Fixed& operator +=(double a);
|
||||
Fixed& operator -=(double a);
|
||||
Fixed& operator *=(double a);
|
||||
Fixed& operator /=(double a);
|
||||
|
||||
bool operator ==(const Fixed a) const;
|
||||
bool operator !=(const Fixed a) const;
|
||||
bool operator <=(const Fixed a) const;
|
||||
bool operator >=(const Fixed a) const;
|
||||
bool operator <(const Fixed a) const;
|
||||
bool operator >(const Fixed a) const;
|
||||
|
||||
bool operator ==(float a) const;
|
||||
bool operator !=(float a) const;
|
||||
bool operator <=(float a) const;
|
||||
bool operator >=(float a) const;
|
||||
bool operator <(float a) const;
|
||||
bool operator >(float a) const;
|
||||
|
||||
bool operator ==(double a) const;
|
||||
bool operator !=(double a) const;
|
||||
bool operator <=(double a) const;
|
||||
bool operator >=(double a) const;
|
||||
bool operator <(double a) const;
|
||||
bool operator >(double a) const;
|
||||
|
||||
bool operator >(int a) const;
|
||||
bool operator <(int a) const;
|
||||
bool operator >=(int a) const;
|
||||
bool operator <=(int a) const;
|
||||
|
||||
Fixed abs();
|
||||
Fixed sqrt();
|
||||
#ifdef TARGET_IS_NDS
|
||||
Fixed cosf();
|
||||
Fixed sinf();
|
||||
Fixed tanf();
|
||||
#endif
|
||||
};
|
||||
|
||||
//
|
||||
// Implementation
|
||||
//
|
||||
|
||||
inline double Fixed::STEP() { return 1.0 / (1<<BP); } // smallest step we can represent
|
||||
|
||||
// for private construction via guts
|
||||
inline Fixed::Fixed(FixedRaw, int guts) : g(guts) {}
|
||||
|
||||
inline Fixed::Fixed() : g(0) {}
|
||||
inline Fixed::Fixed(const Fixed &a) : g( a.g ) {}
|
||||
inline Fixed::Fixed(float a) : g( int(a * (float)(1<<BP)) ) {}
|
||||
inline Fixed::Fixed(double a) : g( int(a * (double)(1<<BP) ) ) {}
|
||||
inline Fixed::Fixed(int a) : g( a << BP ) {}
|
||||
inline Fixed::Fixed(long a) : g( a << BP ) {}
|
||||
|
||||
inline Fixed& Fixed::operator =(const Fixed a) { g= a.g; return *this; }
|
||||
inline Fixed& Fixed::operator =(float a) { g= Fixed(a).g; return *this; }
|
||||
inline Fixed& Fixed::operator =(double a) { g= Fixed(a).g; return *this; }
|
||||
inline Fixed& Fixed::operator =(int a) { g= Fixed(a).g; return *this; }
|
||||
inline Fixed& Fixed::operator =(long a) { g= Fixed(a).g; return *this; }
|
||||
|
||||
inline Fixed::operator float() { return g * (float)STEP(); }
|
||||
inline Fixed::operator double() { return g * (double)STEP(); }
|
||||
inline Fixed::operator int() { return g>>BP; }
|
||||
inline Fixed::operator long() { return g>>BP; }
|
||||
#pragma warning(disable: 4244) //HARDWIRE added pragma to prevent VS2005 compilation error
|
||||
inline Fixed::operator unsigned short() { return g>>BP; }
|
||||
inline Fixed::operator float() const { return g / (float)(1<<BP); }
|
||||
|
||||
inline Fixed Fixed::operator +() const { return Fixed(RAW,g); }
|
||||
inline Fixed Fixed::operator -() const { return Fixed(RAW,-g); }
|
||||
|
||||
inline Fixed Fixed::operator +(const Fixed a) const { return Fixed(RAW, g + a.g); }
|
||||
inline Fixed Fixed::operator -(const Fixed a) const { return Fixed(RAW, g - a.g); }
|
||||
|
||||
#if 1
|
||||
// more acurate, using long long
|
||||
inline Fixed Fixed::operator *(const Fixed a) const { return Fixed(RAW, (int)( ((long long)g * (long long)a.g ) >> BP)); }
|
||||
|
||||
#elif 0
|
||||
|
||||
// check for overflow and figure out where. Must specify -rdynamic in linker
|
||||
#include <execinfo.h>
|
||||
#include <signal.h>
|
||||
#include <exception>
|
||||
|
||||
inline Fixed Fixed::operator *(const Fixed a) const {
|
||||
long long x = ((long long)g * (long long)a.g );
|
||||
if(x > 0x7fffffffffffLL || x < -0x7fffffffffffLL) {
|
||||
printf("overflow");
|
||||
void *array[2];
|
||||
int nSize = backtrace(array, 2);
|
||||
char **symbols = backtrace_symbols(array, nSize);
|
||||
for(int i=0; i<nSize; i++) {
|
||||
printf(" %s", symbols[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
return Fixed(RAW, (int)(x>>BP));
|
||||
}
|
||||
|
||||
#else
|
||||
// faster, but with only half as many bits right of binary point
|
||||
inline Fixed Fixed::operator *(const Fixed a) const { return Fixed(RAW, (g>>BPhalf) * (a.g>>BPhalf) ); }
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef TARGET_IS_NDS
|
||||
// Division using the DS's maths coprocessor
|
||||
inline Fixed Fixed::operator /(const Fixed a) const
|
||||
{
|
||||
//printf("%d %d\n", (long long)g << BP, a.g);
|
||||
return Fixed(RAW, int( div64((long long)g << BP, a.g) ) );
|
||||
}
|
||||
#else
|
||||
inline Fixed Fixed::operator /(const Fixed a) const
|
||||
{
|
||||
return Fixed(RAW, int( (((long long)g << BP2) / (long long)(a.g)) >> BP) );
|
||||
//return Fixed(RAW, int( (((long long)g << BP) / (long long)(a.g)) ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
inline Fixed Fixed::operator *(unsigned short a) const { return operator*(Fixed(a)); }
|
||||
inline Fixed Fixed::operator *(int a) const { return operator*(Fixed(a)); }
|
||||
|
||||
inline Fixed Fixed::operator +(float a) const { return Fixed(RAW, g + Fixed(a).g); }
|
||||
inline Fixed Fixed::operator -(float a) const { return Fixed(RAW, g - Fixed(a).g); }
|
||||
inline Fixed Fixed::operator *(float a) const { return Fixed(RAW, (g>>BPhalf) * (Fixed(a).g>>BPhalf) ); }
|
||||
//inline Fixed Fixed::operator /(float a) const { return Fixed(RAW, int( (((long long)g << BP2) / (long long)(Fixed(a).g)) >> BP) ); }
|
||||
inline Fixed Fixed::operator /(float a) const { return operator/(Fixed(a)); }
|
||||
|
||||
inline Fixed Fixed::operator +(double a) const { return Fixed(RAW, g + Fixed(a).g); }
|
||||
inline Fixed Fixed::operator -(double a) const { return Fixed(RAW, g - Fixed(a).g); }
|
||||
inline Fixed Fixed::operator *(double a) const { return Fixed(RAW, (g>>BPhalf) * (Fixed(a).g>>BPhalf) ); }
|
||||
//inline Fixed Fixed::operator /(double a) const { return Fixed(RAW, int( (((long long)g << BP2) / (long long)(Fixed(a).g)) >> BP) ); }
|
||||
inline Fixed Fixed::operator /(double a) const { return operator/(Fixed(a)); }
|
||||
|
||||
inline Fixed Fixed::operator >>(int a) const { return Fixed(RAW, g >> a); }
|
||||
inline Fixed Fixed::operator <<(int a) const { return Fixed(RAW, g << a); }
|
||||
|
||||
inline Fixed& Fixed::operator +=(Fixed a) { return *this = *this + a; }
|
||||
inline Fixed& Fixed::operator -=(Fixed a) { return *this = *this - a; }
|
||||
inline Fixed& Fixed::operator *=(Fixed a) { return *this = *this * a; }
|
||||
//inline Fixed& Fixed::operator /=(Fixed a) { return *this = *this / a; }
|
||||
inline Fixed& Fixed::operator /=(Fixed a) { return *this = operator/(a); }
|
||||
|
||||
inline Fixed& Fixed::operator +=(int a) { return *this = *this + (Fixed)a; }
|
||||
inline Fixed& Fixed::operator -=(int a) { return *this = *this - (Fixed)a; }
|
||||
inline Fixed& Fixed::operator *=(int a) { return *this = *this * (Fixed)a; }
|
||||
//inline Fixed& Fixed::operator /=(int a) { return *this = *this / (Fixed)a; }
|
||||
inline Fixed& Fixed::operator /=(int a) { return *this = operator/((Fixed)a); }
|
||||
|
||||
inline Fixed& Fixed::operator +=(long a) { return *this = *this + (Fixed)a; }
|
||||
inline Fixed& Fixed::operator -=(long a) { return *this = *this - (Fixed)a; }
|
||||
inline Fixed& Fixed::operator *=(long a) { return *this = *this * (Fixed)a; }
|
||||
//inline Fixed& Fixed::operator /=(long a) { return *this = *this / (Fixed)a; }
|
||||
inline Fixed& Fixed::operator /=(long a) { return *this = operator/((Fixed)a); }
|
||||
|
||||
inline Fixed& Fixed::operator +=(float a) { return *this = *this + a; }
|
||||
inline Fixed& Fixed::operator -=(float a) { return *this = *this - a; }
|
||||
inline Fixed& Fixed::operator *=(float a) { return *this = *this * a; }
|
||||
//inline Fixed& Fixed::operator /=(float a) { return *this = *this / a; }
|
||||
inline Fixed& Fixed::operator /=(float a) { return *this = operator/(a); }
|
||||
|
||||
inline Fixed& Fixed::operator +=(double a) { return *this = *this + a; }
|
||||
inline Fixed& Fixed::operator -=(double a) { return *this = *this - a; }
|
||||
inline Fixed& Fixed::operator *=(double a) { return *this = *this * a; }
|
||||
//inline Fixed& Fixed::operator /=(double a) { return *this = *this / a; }
|
||||
inline Fixed& Fixed::operator /=(double a) { return *this = operator/(a); }
|
||||
|
||||
inline Fixed operator +(int a, const Fixed b) { return Fixed(a)+b; }
|
||||
inline Fixed operator -(int a, const Fixed b) { return Fixed(a)-b; }
|
||||
inline Fixed operator *(int a, const Fixed b) { return Fixed(a)*b; }
|
||||
inline Fixed operator /(int a, const Fixed b) { return Fixed(a)/b; };
|
||||
|
||||
inline Fixed operator +(float a, const Fixed b) { return Fixed(a)+b; }
|
||||
inline Fixed operator -(float a, const Fixed b) { return Fixed(a)-b; }
|
||||
inline Fixed operator *(float a, const Fixed b) { return Fixed(a)*b; }
|
||||
inline Fixed operator /(float a, const Fixed b) { return Fixed(a)/b; }
|
||||
|
||||
inline bool Fixed::operator ==(const Fixed a) const { return g == a.g; }
|
||||
inline bool Fixed::operator !=(const Fixed a) const { return g != a.g; }
|
||||
inline bool Fixed::operator <=(const Fixed a) const { return g <= a.g; }
|
||||
inline bool Fixed::operator >=(const Fixed a) const { return g >= a.g; }
|
||||
inline bool Fixed::operator <(const Fixed a) const { return g < a.g; }
|
||||
inline bool Fixed::operator >(const Fixed a) const { return g > a.g; }
|
||||
|
||||
inline bool Fixed::operator ==(float a) const { return g == Fixed(a).g; }
|
||||
inline bool Fixed::operator !=(float a) const { return g != Fixed(a).g; }
|
||||
inline bool Fixed::operator <=(float a) const { return g <= Fixed(a).g; }
|
||||
inline bool Fixed::operator >=(float a) const { return g >= Fixed(a).g; }
|
||||
inline bool Fixed::operator <(float a) const { return g < Fixed(a).g; }
|
||||
inline bool Fixed::operator >(float a) const { return g > Fixed(a).g; }
|
||||
|
||||
inline bool Fixed::operator ==(double a) const { return g == Fixed(a).g; }
|
||||
inline bool Fixed::operator !=(double a) const { return g != Fixed(a).g; }
|
||||
inline bool Fixed::operator <=(double a) const { return g <= Fixed(a).g; }
|
||||
inline bool Fixed::operator >=(double a) const { return g >= Fixed(a).g; }
|
||||
inline bool Fixed::operator <(double a) const { return g < Fixed(a).g; }
|
||||
inline bool Fixed::operator >(double a) const { return g > Fixed(a).g; }
|
||||
|
||||
inline bool Fixed::operator >(int a) const { return g > Fixed(a).g; }
|
||||
inline bool Fixed::operator <(int a) const { return g < Fixed(a).g; }
|
||||
inline bool Fixed::operator >=(int a) const{ return g >= Fixed(a).g; };
|
||||
inline bool Fixed::operator <=(int a) const{ return g <= Fixed(a).g; };
|
||||
|
||||
inline bool operator ==(float a, const Fixed b) { return Fixed(a) == b; }
|
||||
inline bool operator !=(float a, const Fixed b) { return Fixed(a) != b; }
|
||||
inline bool operator <=(float a, const Fixed b) { return Fixed(a) <= b; }
|
||||
inline bool operator >=(float a, const Fixed b) { return Fixed(a) >= b; }
|
||||
inline bool operator <(float a, const Fixed b) { return Fixed(a) < b; }
|
||||
inline bool operator >(float a, const Fixed b) { return Fixed(a) > b; }
|
||||
|
||||
inline Fixed operator +(double a, const Fixed b) { return Fixed(a)+b; }
|
||||
inline Fixed operator -(double a, const Fixed b) { return Fixed(a)-b; }
|
||||
inline Fixed operator *(double a, const Fixed b) { return Fixed(a)*b; }
|
||||
inline Fixed operator /(double a, const Fixed b) { return Fixed(a)/b; }
|
||||
|
||||
inline bool operator ==(double a, const Fixed b) { return Fixed(a) == b; }
|
||||
inline bool operator !=(double a, const Fixed b) { return Fixed(a) != b; }
|
||||
inline bool operator <=(double a, const Fixed b) { return Fixed(a) <= b; }
|
||||
inline bool operator >=(double a, const Fixed b) { return Fixed(a) >= b; }
|
||||
inline bool operator <(double a, const Fixed b) { return Fixed(a) < b; }
|
||||
inline bool operator >(double a, const Fixed b) { return Fixed(a) > b; }
|
||||
|
||||
inline bool operator ==(int a, const Fixed b) { return Fixed(a) == b; }
|
||||
inline bool operator !=(int a, const Fixed b) { return Fixed(a) != b; }
|
||||
inline bool operator <=(int a, const Fixed b) { return Fixed(a) <= b; }
|
||||
inline bool operator >=(int a, const Fixed b) { return Fixed(a) >= b; }
|
||||
inline bool operator <(int a, const Fixed b) { return Fixed(a) < b; }
|
||||
inline bool operator >(int a, const Fixed b) { return Fixed(a) > b; }
|
||||
|
||||
inline int& operator +=(int& a, const Fixed b) { a = (Fixed)a + b; return a; }
|
||||
inline int& operator -=(int& a, const Fixed b) { a = (Fixed)a - b; return a; }
|
||||
inline int& operator *=(int& a, const Fixed b) { a = (Fixed)a * b; return a; }
|
||||
inline int& operator /=(int& a, const Fixed b) { a = (Fixed)a / b; return a; }
|
||||
|
||||
inline long& operator +=(long& a, const Fixed b) { a = (Fixed)a + b; return a; }
|
||||
inline long& operator -=(long& a, const Fixed b) { a = (Fixed)a - b; return a; }
|
||||
inline long& operator *=(long& a, const Fixed b) { a = (Fixed)a * b; return a; }
|
||||
inline long& operator /=(long& a, const Fixed b) { a = (Fixed)a / b; return a; }
|
||||
|
||||
inline float& operator +=(float& a, const Fixed b) { a = a + b; return a; }
|
||||
inline float& operator -=(float& a, const Fixed b) { a = a - b; return a; }
|
||||
inline float& operator *=(float& a, const Fixed b) { a = a * b; return a; }
|
||||
inline float& operator /=(float& a, const Fixed b) { a = a / b; return a; }
|
||||
|
||||
inline double& operator +=(double& a, const Fixed b) { a = a + b; return a; }
|
||||
inline double& operator -=(double& a, const Fixed b) { a = a - b; return a; }
|
||||
inline double& operator *=(double& a, const Fixed b) { a = a * b; return a; }
|
||||
inline double& operator /=(double& a, const Fixed b) { a = a / b; return a; }
|
||||
|
||||
inline Fixed Fixed::abs() { return (g>0) ? Fixed(RAW, g) : Fixed(RAW, -g); }
|
||||
inline Fixed abs(Fixed f) { return f.abs(); }
|
||||
|
||||
//inline Fixed atan2(Fixed a, Fixed b) { return atan2f((float) a, (float) b); }
|
||||
inline Fixed atan2(Fixed y, Fixed x)
|
||||
{
|
||||
Fixed abs_y = y.abs() + FIXED_EPSILON; // avoid 0/0
|
||||
Fixed r, angle;
|
||||
|
||||
if(x >= 0.0f) {
|
||||
r = (x - abs_y) / (x + abs_y);
|
||||
angle = 3.1415926/4.0;
|
||||
} else {
|
||||
r = (x + abs_y) / (abs_y - x);
|
||||
angle = 3.0*3.1415926/4.0;
|
||||
}
|
||||
angle += Fixed(0.1963) * (r * r * r) - Fixed(0.9817) * r;
|
||||
return (y < 0) ? -angle : angle;
|
||||
}
|
||||
|
||||
#if TARGET_IS_NDS
|
||||
|
||||
static inline long nds_sqrt64(long long a)
|
||||
{
|
||||
SQRT_CR = SQRT_64;
|
||||
while(SQRT_CR & SQRT_BUSY);
|
||||
SQRT_PARAM64 = a;
|
||||
while(SQRT_CR & SQRT_BUSY);
|
||||
|
||||
return SQRT_RESULT32;
|
||||
}
|
||||
|
||||
static inline int32 div6464(int64 num, int64 den)
|
||||
{
|
||||
DIV_CR = DIV_64_64;
|
||||
while(DIV_CR & DIV_BUSY);
|
||||
DIV_NUMERATOR64 = num;
|
||||
DIV_DENOMINATOR64 = den;
|
||||
while(DIV_CR & DIV_BUSY);
|
||||
|
||||
return (DIV_RESULT32);
|
||||
}
|
||||
|
||||
inline Fixed Fixed::sqrt()
|
||||
{
|
||||
return Fixed(RAW, nds_sqrt64(((long long)(g))<<BP));
|
||||
}
|
||||
#else
|
||||
inline Fixed Fixed::sqrt()
|
||||
{
|
||||
long long m, root = 0, left = (long long)g<<FIXED_BP;
|
||||
for ( m = (long long)1<<( (sizeof(long long)<<3) - 2); m; m >>= 2 )
|
||||
{
|
||||
if ( ( left & -m ) > root )
|
||||
left -= ( root += m ), root += m;
|
||||
root >>= 1;
|
||||
}
|
||||
return Fixed(RAW, root);
|
||||
}
|
||||
#endif
|
||||
|
||||
inline Fixed sqrt(Fixed a) { return a.sqrt(); }
|
||||
inline Fixed sqrtf(Fixed a) { return a.sqrt(); }
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_IS_NDS
|
||||
// Use the libnds lookup tables for trigonometry functions
|
||||
inline Fixed Fixed::cosf() {
|
||||
int idx = (((long long)g*(long long)G_1_DIV_PI)>>24)%512;
|
||||
if(idx < 0)
|
||||
idx += 512;
|
||||
return Fixed(RAW, COS_bin[idx] << 4);
|
||||
}
|
||||
inline Fixed cosf(Fixed x) { return x.cosf(); }
|
||||
inline Fixed Fixed::sinf() {
|
||||
int idx = (((long long)g*(long long)G_1_DIV_PI)>>24)%512;
|
||||
if(idx < 0)
|
||||
idx += 512;
|
||||
return Fixed(RAW, SIN_bin[idx] << 4);
|
||||
}
|
||||
inline Fixed sinf(Fixed x) { return x.sinf(); }
|
||||
inline Fixed Fixed::tanf() {
|
||||
int idx = (((long long)g*(long long)G_1_DIV_PI)>>24)%512;
|
||||
if(idx < 0)
|
||||
idx += 512;
|
||||
return Fixed(RAW, TAN_bin[idx] << 4);
|
||||
}
|
||||
inline Fixed tanf(Fixed x) { return x.tanf(); }
|
||||
|
||||
|
||||
#endif
|
||||
139
external/Box2D-2.3.1/Contributions/Enhancements/FixedPoint/jtypes.h
vendored
Normal file
139
external/Box2D-2.3.1/Contributions/Enhancements/FixedPoint/jtypes.h
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
/*---------------------------------------------------------------------------------
|
||||
$Id: jtypes.h,v 1.17 2007/07/18 05:20:45 wntrmute Exp $
|
||||
|
||||
jtypes.h -- Common types (and a few useful macros)
|
||||
|
||||
Copyright (C) 2005
|
||||
Michael Noland (joat)
|
||||
Jason Rogers (dovoto)
|
||||
Dave Murphy (WinterMute)
|
||||
Chris Double (doublec)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you use
|
||||
this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
---------------------------------------------------------------------------------*/
|
||||
#ifndef NDS_JTYPES_INCLUDE
|
||||
#define NDS_JTYPES_INCLUDE
|
||||
//---------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#define PACKED __attribute__ ((packed))
|
||||
#define packed_struct struct PACKED
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// libgba compatible section macros
|
||||
//---------------------------------------------------------------------------------
|
||||
#define ITCM_CODE __attribute__((section(".itcm"), long_call))
|
||||
|
||||
#define DTCM_DATA __attribute__((section(".dtcm")))
|
||||
#define DTCM_BSS __attribute__((section(".sbss")))
|
||||
#define ALIGN(m) __attribute__((aligned (m)))
|
||||
|
||||
#define PACKED __attribute__ ((packed))
|
||||
#define packed_struct struct PACKED
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// These are linked to the bin2o macro in the Makefile
|
||||
//---------------------------------------------------------------------------------
|
||||
#define GETRAW(name) (name)
|
||||
#define GETRAWSIZE(name) ((int)name##_size)
|
||||
#define GETRAWEND(name) ((int)name##_end)
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#define BIT(n) (1 << (n))
|
||||
|
||||
// define libnds types in terms of stdint
|
||||
#include <stdint.h>
|
||||
|
||||
typedef uint8_t uint8;
|
||||
typedef uint16_t uint16;
|
||||
typedef uint32_t uint32;
|
||||
typedef uint64_t uint64;
|
||||
|
||||
typedef int8_t int8;
|
||||
typedef int16_t int16;
|
||||
typedef int32_t int32;
|
||||
typedef int64_t int64;
|
||||
|
||||
//typedef float float32;
|
||||
typedef double float64;
|
||||
|
||||
typedef volatile uint8_t vuint8;
|
||||
typedef volatile uint16_t vuint16;
|
||||
typedef volatile uint32_t vuint32;
|
||||
typedef volatile uint64_t vuint64;
|
||||
|
||||
typedef volatile int8_t vint8;
|
||||
typedef volatile int16_t vint16;
|
||||
typedef volatile int32_t vint32;
|
||||
typedef volatile int64_t vint64;
|
||||
|
||||
typedef volatile float vfloat32;
|
||||
typedef volatile float64 vfloat64;
|
||||
|
||||
typedef uint8_t byte;
|
||||
|
||||
typedef uint8_t u8;
|
||||
typedef uint16_t u16;
|
||||
typedef uint32_t u32;
|
||||
typedef uint64_t u64;
|
||||
|
||||
typedef int8_t s8;
|
||||
typedef int16_t s16;
|
||||
typedef int32_t s32;
|
||||
typedef int64_t s64;
|
||||
|
||||
typedef volatile u8 vu8;
|
||||
typedef volatile u16 vu16;
|
||||
typedef volatile u32 vu32;
|
||||
typedef volatile u64 vu64;
|
||||
|
||||
typedef volatile s8 vs8;
|
||||
typedef volatile s16 vs16;
|
||||
typedef volatile s32 vs32;
|
||||
typedef volatile s64 vs64;
|
||||
|
||||
typedef struct touchPosition {
|
||||
int16 x;
|
||||
int16 y;
|
||||
int16 px;
|
||||
int16 py;
|
||||
int16 z1;
|
||||
int16 z2;
|
||||
} touchPosition;
|
||||
|
||||
|
||||
#ifndef __cplusplus
|
||||
/** C++ compatible bool for C
|
||||
|
||||
*/
|
||||
typedef enum { false, true } bool;
|
||||
#endif
|
||||
|
||||
// Handy function pointer typedefs
|
||||
typedef void ( * IntFn)(void);
|
||||
typedef void (* VoidFunctionPointer)(void);
|
||||
typedef void (* fp)(void);
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
#endif
|
||||
//---------------------------------------------------------------------------------
|
||||
1359
external/Box2D-2.3.1/Contributions/Enhancements/Shapes/capsule88.patch
vendored
Normal file
1359
external/Box2D-2.3.1/Contributions/Enhancements/Shapes/capsule88.patch
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user