mirror of
https://github.com/love2d/love.git
synced 2026-08-20 04:30:09 +02:00
Added meter parameter to newWorld
This commit is contained in:
+2
-1
@@ -7,7 +7,8 @@ LOVE 0.7.0
|
|||||||
* Added get/setGroupIndex to CircleShape and PolygonShape.
|
* Added get/setGroupIndex to CircleShape and PolygonShape.
|
||||||
* Added Font:getWrap.
|
* Added Font:getWrap.
|
||||||
* Added identity field to love.conf.
|
* Added identity field to love.conf.
|
||||||
* Added love.quit callback.
|
* Added love.quit callback.
|
||||||
|
* Added extra meter parameter to love.physics.newWorld.
|
||||||
* Enabled love.filesystem.FileData.
|
* Enabled love.filesystem.FileData.
|
||||||
* Fixed bug where the debug module was not an upvalue of the error handlers. (you can now override debug)
|
* Fixed bug where the debug module was not an upvalue of the error handlers. (you can now override debug)
|
||||||
* Fixed bug where love.audio.pause and friends were acting on everything, not just the passed Source.
|
* Fixed bug where love.audio.pause and friends were acting on everything, not just the passed Source.
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2006-2010 LOVE Development Team
|
* Copyright (c) 2006-2010 LOVE Development Team
|
||||||
*
|
*
|
||||||
* This software is provided 'as-is', without any express or implied
|
* This software is provided 'as-is', without any express or implied
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
* arising from the use of this software.
|
* arising from the use of this software.
|
||||||
*
|
*
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
* including commercial applications, and to alter it and redistribute it
|
* including commercial applications, and to alter it and redistribute it
|
||||||
* freely, subject to the following restrictions:
|
* freely, subject to the following restrictions:
|
||||||
*
|
*
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
* 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
|
* claim that you wrote the original software. If you use this software
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
@@ -33,10 +33,18 @@ namespace physics
|
|||||||
{
|
{
|
||||||
namespace box2d
|
namespace box2d
|
||||||
{
|
{
|
||||||
|
|
||||||
const char * Physics::getName() const
|
const char * Physics::getName() const
|
||||||
{
|
{
|
||||||
return "love.physics.box2d";
|
return "love.physics.box2d";
|
||||||
|
}
|
||||||
|
|
||||||
|
World * Physics::newWorld(float lx, float ly, float ux, float uy, float gx, float gy, bool sleep, int meter)
|
||||||
|
{
|
||||||
|
b2AABB aabb;
|
||||||
|
aabb.lowerBound.Set(lx, ly);
|
||||||
|
aabb.upperBound.Set(ux, uy);
|
||||||
|
return new World(aabb, b2Vec2(gx, gy), sleep, meter);
|
||||||
}
|
}
|
||||||
|
|
||||||
World * Physics::newWorld(float lx, float ly, float ux, float uy, float gx, float gy, bool sleep)
|
World * Physics::newWorld(float lx, float ly, float ux, float uy, float gx, float gy, bool sleep)
|
||||||
@@ -166,7 +174,7 @@ namespace box2d
|
|||||||
{
|
{
|
||||||
return new PrismaticJoint(body1, body2, x, y, ax, ay);
|
return new PrismaticJoint(body1, body2, x, y, ax, ay);
|
||||||
}
|
}
|
||||||
|
|
||||||
PulleyJoint * Physics::newPulleyJoint(Body * body1, Body * body2, b2Vec2 groundAnchor1, b2Vec2 groundAnchor2, b2Vec2 anchor1, b2Vec2 anchor2, float ratio)
|
PulleyJoint * Physics::newPulleyJoint(Body * body1, Body * body2, b2Vec2 groundAnchor1, b2Vec2 groundAnchor2, b2Vec2 anchor1, b2Vec2 anchor2, float ratio)
|
||||||
{
|
{
|
||||||
return new PulleyJoint(body1, body2, groundAnchor1, groundAnchor2, anchor1, anchor2, ratio);
|
return new PulleyJoint(body1, body2, groundAnchor1, groundAnchor2, anchor1, anchor2, ratio);
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2006-2010 LOVE Development Team
|
* Copyright (c) 2006-2010 LOVE Development Team
|
||||||
*
|
*
|
||||||
* This software is provided 'as-is', without any express or implied
|
* This software is provided 'as-is', without any express or implied
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
* arising from the use of this software.
|
* arising from the use of this software.
|
||||||
*
|
*
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
* including commercial applications, and to alter it and redistribute it
|
* including commercial applications, and to alter it and redistribute it
|
||||||
* freely, subject to the following restrictions:
|
* freely, subject to the following restrictions:
|
||||||
*
|
*
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
* 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
|
* claim that you wrote the original software. If you use this software
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
@@ -50,6 +50,19 @@ namespace box2d
|
|||||||
// Implements Module.
|
// Implements Module.
|
||||||
const char * getName() const;
|
const char * getName() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new World.
|
||||||
|
* @param lx Lower bound on the x-axis.
|
||||||
|
* @param ly Lower bound on the y-axis.
|
||||||
|
* @param ux Upper bound on the x-axis.
|
||||||
|
* @param uy Upper bound on the y-axis.
|
||||||
|
* @param gx Gravity along x-axis.
|
||||||
|
* @param gy Gravity along y-axis.
|
||||||
|
* @param sleep Whether the World allows sleep.
|
||||||
|
* @param meter The scale in px/m.
|
||||||
|
**/
|
||||||
|
World * newWorld(float lx, float ly, float ux, float uy, float gx, float gy, bool sleep, int meter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new World.
|
* Creates a new World.
|
||||||
* @param lx Lower bound on the x-axis.
|
* @param lx Lower bound on the x-axis.
|
||||||
@@ -176,7 +189,7 @@ namespace box2d
|
|||||||
* @param ay The y-component of the world-axis.
|
* @param ay The y-component of the world-axis.
|
||||||
**/
|
**/
|
||||||
PrismaticJoint * newPrismaticJoint(Body * body1, Body * body2, float x, float y, float ax, float ay);
|
PrismaticJoint * newPrismaticJoint(Body * body1, Body * body2, float x, float y, float ax, float ay);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new PulleyJoint connecting body1 with body2.
|
* Creates a new PulleyJoint connecting body1 with body2.
|
||||||
* @param groundAnchor1 World ground-anchor for body1.
|
* @param groundAnchor1 World ground-anchor for body1.
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2006-2010 LOVE Development Team
|
* Copyright (c) 2006-2010 LOVE Development Team
|
||||||
*
|
*
|
||||||
* This software is provided 'as-is', without any express or implied
|
* This software is provided 'as-is', without any express or implied
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
* arising from the use of this software.
|
* arising from the use of this software.
|
||||||
*
|
*
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
* including commercial applications, and to alter it and redistribute it
|
* including commercial applications, and to alter it and redistribute it
|
||||||
* freely, subject to the following restrictions:
|
* freely, subject to the following restrictions:
|
||||||
*
|
*
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
* 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
|
* claim that you wrote the original software. If you use this software
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
@@ -64,22 +64,22 @@ namespace box2d
|
|||||||
{
|
{
|
||||||
// Push the function.
|
// Push the function.
|
||||||
ref->push();
|
ref->push();
|
||||||
|
|
||||||
// Push first userdata.
|
// Push first userdata.
|
||||||
{
|
{
|
||||||
shapeudata * d = (shapeudata *)(contacts[i]->point.shape1->GetUserData());
|
shapeudata * d = (shapeudata *)(contacts[i]->point.shape1->GetUserData());
|
||||||
if(d->ref != 0)
|
if(d->ref != 0)
|
||||||
d->ref->push();
|
d->ref->push();
|
||||||
else
|
else
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Push first userdata.
|
// Push first userdata.
|
||||||
{
|
{
|
||||||
shapeudata * d = (shapeudata *)(contacts[i]->point.shape2->GetUserData());
|
shapeudata * d = (shapeudata *)(contacts[i]->point.shape2->GetUserData());
|
||||||
if(d->ref != 0)
|
if(d->ref != 0)
|
||||||
d->ref->push();
|
d->ref->push();
|
||||||
else
|
else
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,8 +102,8 @@ namespace box2d
|
|||||||
world->SetContactListener(this);
|
world->SetContactListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
World::World(b2AABB aabb, b2Vec2 gravity, bool sleep)
|
World::World(b2AABB aabb, b2Vec2 gravity, bool sleep, int meter)
|
||||||
: meter(DEFAULT_METER)
|
: meter(meter)
|
||||||
{
|
{
|
||||||
world = new b2World(scaleDown(aabb), scaleDown(gravity), sleep);
|
world = new b2World(scaleDown(aabb), scaleDown(gravity), sleep);
|
||||||
world->SetContactListener(this);
|
world->SetContactListener(this);
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2006-2010 LOVE Development Team
|
* Copyright (c) 2006-2010 LOVE Development Team
|
||||||
*
|
*
|
||||||
* This software is provided 'as-is', without any express or implied
|
* This software is provided 'as-is', without any express or implied
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
* arising from the use of this software.
|
* arising from the use of this software.
|
||||||
*
|
*
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
* including commercial applications, and to alter it and redistribute it
|
* including commercial applications, and to alter it and redistribute it
|
||||||
* freely, subject to the following restrictions:
|
* freely, subject to the following restrictions:
|
||||||
*
|
*
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
* 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
|
* claim that you wrote the original software. If you use this software
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
@@ -38,18 +38,18 @@ namespace physics
|
|||||||
{
|
{
|
||||||
namespace box2d
|
namespace box2d
|
||||||
{
|
{
|
||||||
|
|
||||||
class Contact;
|
class Contact;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The World is the "God" container class,
|
* The World is the "God" container class,
|
||||||
* which contains all Bodies and Joints. Shapes
|
* which contains all Bodies and Joints. Shapes
|
||||||
* are contained in their associated Body.
|
* are contained in their associated Body.
|
||||||
*
|
*
|
||||||
* Bodies in different worlds can obviously not
|
* Bodies in different worlds can obviously not
|
||||||
* collide.
|
* collide.
|
||||||
*
|
*
|
||||||
* The world also controls global parameters, like
|
* The world also controls global parameters, like
|
||||||
* gravity.
|
* gravity.
|
||||||
**/
|
**/
|
||||||
class World : public Object, public b2ContactListener
|
class World : public Object, public b2ContactListener
|
||||||
@@ -105,7 +105,7 @@ namespace box2d
|
|||||||
* @param sleep True if the bodies should be able to sleep,
|
* @param sleep True if the bodies should be able to sleep,
|
||||||
* false otherwise.
|
* false otherwise.
|
||||||
**/
|
**/
|
||||||
World(b2AABB aabb, b2Vec2 gravity, bool sleep);
|
World(b2AABB aabb, b2Vec2 gravity, bool sleep, int meter = DEFAULT_METER);
|
||||||
|
|
||||||
virtual ~World();
|
virtual ~World();
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ namespace box2d
|
|||||||
* Receives up to four Lua functions as arguments. Each function is
|
* Receives up to four Lua functions as arguments. Each function is
|
||||||
* collision callback for the four events (in order): add, persist,
|
* collision callback for the four events (in order): add, persist,
|
||||||
* remove and result. The value "nil" is accepted if one or more events
|
* remove and result. The value "nil" is accepted if one or more events
|
||||||
* are uninteresting.
|
* are uninteresting.
|
||||||
**/
|
**/
|
||||||
int setCallbacks(lua_State * L);
|
int setCallbacks(lua_State * L);
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ namespace box2d
|
|||||||
* Returns the functions previously set by setCallbacks.
|
* Returns the functions previously set by setCallbacks.
|
||||||
**/
|
**/
|
||||||
int getCallbacks(lua_State * L);
|
int getCallbacks(lua_State * L);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the current gravity of the World.
|
* Sets the current gravity of the World.
|
||||||
* @param x Gravity in the x-direction.
|
* @param x Gravity in the x-direction.
|
||||||
@@ -175,7 +175,7 @@ namespace box2d
|
|||||||
int getJointCount();
|
int getJointCount();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the number of pixels in one meter.
|
* Sets the number of pixels in one meter.
|
||||||
* @param pixels The number of pixels in one meter. (1m ~= 3.3ft).
|
* @param pixels The number of pixels in one meter. (1m ~= 3.3ft).
|
||||||
**/
|
**/
|
||||||
void setMeter(int meter);
|
void setMeter(int meter);
|
||||||
|
|||||||
@@ -53,6 +53,20 @@ namespace box2d
|
|||||||
luax_newtype(L, "World", PHYSICS_WORLD_T, (void*)w);
|
luax_newtype(L, "World", PHYSICS_WORLD_T, (void*)w);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
else if (top == 8)
|
||||||
|
{
|
||||||
|
float lx = (float)luaL_checknumber(L, 1);
|
||||||
|
float ly = (float)luaL_checknumber(L, 2);
|
||||||
|
float ux = (float)luaL_checknumber(L, 3);
|
||||||
|
float uy = (float)luaL_checknumber(L, 4);
|
||||||
|
float gx = (float)luaL_checknumber(L, 5);
|
||||||
|
float gy = (float)luaL_checknumber(L, 6);
|
||||||
|
bool sleep = lua_toboolean(L, 7);
|
||||||
|
int meter = (int)luaL_checknumber(L, 8);
|
||||||
|
World * w = instance->newWorld(lx, ly, ux, uy, gx, gy, sleep, meter);
|
||||||
|
luax_newtype(L, "World", PHYSICS_WORLD_T, (void*)w);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return luaL_error(L, "Incorrect number of parameters");
|
return luaL_error(L, "Incorrect number of parameters");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user