Added body.getAllowSleeping, resolves #52

This commit is contained in:
Bart van Strien
2010-08-27 22:19:16 +02:00
parent 944a1a6e8b
commit 9a86aab97d
4 changed files with 40 additions and 25 deletions
+8 -3
View File
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2006-2010 LOVE Development Team
*
*
* 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
@@ -281,6 +281,11 @@ namespace box2d
body->AllowSleeping(allow);
}
bool Body::getAllowSleeping()
{
return (body->m_flags & b2Body::e_allowSleepFlag);
}
void Body::putToSleep()
{
body->PutToSleep();
+15 -14
View File
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2006-2010 LOVE Development Team
*
*
* 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
@@ -41,8 +41,8 @@ namespace box2d
/**
* A Body is an entity which has position and orientation
* in world space. A Body does have collision geometry
* by itself, but depend on an arbitrary number of child Shape objects
* in world space. A Body does have collision geometry
* by itself, but depend on an arbitrary number of child Shape objects
* which together constitute the final geometry for the Body.
**/
class Body : public Object
@@ -57,14 +57,14 @@ namespace box2d
private:
// We need a shared_ptr to the parent World,
// We need a shared_ptr to the parent World,
// because World can not be destroyed as long as
// bodies exists in it.
//
// This ensures that a World only can be destroyed
// once all bodies have been destroyed too.
World * world;
public:
// The Box2D body. (Should not be public?)
@@ -72,7 +72,7 @@ namespace box2d
/**
* Create a Body at position p.
**/
**/
Body(World * world, b2Vec2 p, float m, float i);
virtual ~Body();
@@ -169,7 +169,7 @@ namespace box2d
* Apply force (fx, fy) with offset (rx, ry).
**/
void applyForce(float fx, float fy, float rx, float ry);
/**
* Sets the x-position of the Body.
**/
@@ -191,18 +191,18 @@ namespace box2d
void setAngle(float d);
/**
* Sets the current spin of the Body.
* Sets the current spin of the Body.
**/
void setAngularVelocity(float r);
/**
* Sets the current position of the Body.
**/
**/
void setPosition(float x, float y);
/**
* Sets the mass from the currently attatched shapes.
**/
**/
void setMassFromShapes();
/**
@@ -325,8 +325,9 @@ namespace box2d
/**
* Controls whether this Body should be allowed to sleep.
**/
**/
void setAllowSleeping(bool allow);
bool getAllowSleeping();
/**
* Puts the body to sleep.
@@ -348,7 +349,7 @@ namespace box2d
b2Vec2 getVector(lua_State * L);
/**
* Pushed the x- and y-components of a vector on
* Pushed the x- and y-components of a vector on
* the stack.
**/
int pushVector(lua_State * L, const b2Vec2 & v);
+13 -5
View File
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2006-2010 LOVE Development Team
*
*
* 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
@@ -155,7 +155,7 @@ namespace box2d
{
return luaL_error(L, "Wrong number of parameters.");
}
return 0;
}
@@ -188,7 +188,7 @@ namespace box2d
{
return luaL_error(L, "Wrong number of parameters.");
}
return 0;
}
@@ -419,6 +419,13 @@ namespace box2d
return 0;
}
int w_Body_getAllowSleeping(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
lua_pushboolean(L, t->getAllowSleeping());
return 1;
}
int w_Body_putToSleep(lua_State * L)
{
Body * t = luax_checkbody(L, 1);
@@ -500,6 +507,7 @@ namespace box2d
{ "isFrozen", w_Body_isFrozen },
{ "isSleeping", w_Body_isSleeping },
{ "setAllowSleeping", w_Body_setAllowSleeping },
{ "getAllowSleeping", w_Body_getAllowSleeping },
{ "putToSleep", w_Body_putToSleep },
{ "wakeUp", w_Body_wakeUp },
{ "setFixedRotation", w_Body_setFixedRotation },
+4 -3
View File
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2006-2010 LOVE Development Team
*
*
* 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
@@ -72,6 +72,7 @@ namespace box2d
int w_Body_isFrozen(lua_State * L);
int w_Body_isSleeping(lua_State * L);
int w_Body_setAllowSleeping(lua_State * L);
int w_Body_getAllowSleeping(lua_State * L);
int w_Body_putToSleep(lua_State * L);
int w_Body_wakeUp(lua_State * L);
int w_Body_setFixedRotation(lua_State * L);