Merged default into minor

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2014-11-15 20:17:18 -04:00
32 changed files with 348 additions and 22 deletions
+17 -3
View File
@@ -491,6 +491,17 @@ GLenum Image::getCompressedFormat(image::CompressedData::Format cformat) const
return GL_COMPRESSED_RG_RGTC2;
case image::CompressedData::FORMAT_BC5s:
return GL_COMPRESSED_SIGNED_RG_RGTC2;
case image::CompressedData::FORMAT_BC6H:
return GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT;
case image::CompressedData::FORMAT_BC6Hs:
return GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT;
case image::CompressedData::FORMAT_BC7:
if (flags.sRGB)
return GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM;
else
return GL_COMPRESSED_RGBA_BPTC_UNORM;
case image::CompressedData::FORMAT_BC7SRGB:
return GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM;
default:
if (flags.sRGB)
return GL_SRGB8_ALPHA8;
@@ -519,11 +530,14 @@ bool Image::hasCompressedTextureSupport(image::CompressedData::Format format)
case image::CompressedData::FORMAT_BC5:
case image::CompressedData::FORMAT_BC5s:
return (GLAD_VERSION_3_0 || GLAD_ARB_texture_compression_rgtc || GLAD_EXT_texture_compression_rgtc);
case image::CompressedData::FORMAT_BC6H:
case image::CompressedData::FORMAT_BC6Hs:
case image::CompressedData::FORMAT_BC7:
case image::CompressedData::FORMAT_BC7SRGB:
return GLAD_VERSION_4_2 || GLAD_ARB_texture_compression_bptc;
default:
break;
return false;
}
return false;
}
bool Image::hasSRGBSupport()
+4
View File
@@ -110,6 +110,10 @@ StringMap<CompressedData::Format, CompressedData::FORMAT_MAX_ENUM>::Entry Compre
{"bc4s", CompressedData::FORMAT_BC4s},
{"bc5", CompressedData::FORMAT_BC5},
{"bc5s", CompressedData::FORMAT_BC5s},
{"bc6h", CompressedData::FORMAT_BC6H},
{"bc6hs", CompressedData::FORMAT_BC6Hs},
{"bc7", CompressedData::FORMAT_BC7},
{"bc7srgb", CompressedData::FORMAT_BC7SRGB},
};
StringMap<CompressedData::Format, CompressedData::FORMAT_MAX_ENUM> CompressedData::formats(CompressedData::formatEntries, sizeof(CompressedData::formatEntries));
+4
View File
@@ -54,6 +54,10 @@ public:
FORMAT_BC4s,
FORMAT_BC5,
FORMAT_BC5s,
FORMAT_BC6H,
FORMAT_BC6Hs,
FORMAT_BC7,
FORMAT_BC7SRGB,
FORMAT_MAX_ENUM
};
+8 -2
View File
@@ -117,11 +117,17 @@ CompressedData::Format ddsHandler::convertFormat(dds::Format ddsformat)
return CompressedData::FORMAT_BC5;
case dds::FORMAT_BC5s:
return CompressedData::FORMAT_BC5s;
case dds::FORMAT_BC6H:
return CompressedData::FORMAT_BC6H;
case dds::FORMAT_BC6Hs:
return CompressedData::FORMAT_BC6Hs;
case dds::FORMAT_BC7:
return CompressedData::FORMAT_BC7;
case dds::FORMAT_BC7srgb:
return CompressedData::FORMAT_BC7SRGB;
default:
return CompressedData::FORMAT_UNKNOWN;
}
return CompressedData::FORMAT_UNKNOWN;
}
} // magpie
@@ -489,6 +489,10 @@ void JoystickModule::loadGamepadMappings(const std::string &mappings)
if (mapping.empty())
continue;
// Lines starting with "#" are comments.
if (mapping[0] == '#')
continue;
// Strip out and compare any "platform:XYZ," in the mapping.
size_t pstartpos = mapping.find("platform:");
if (pstartpos != std::string::npos)
@@ -499,7 +503,11 @@ void JoystickModule::loadGamepadMappings(const std::string &mappings)
std::string platform = mapping.substr(pstartpos, pendpos - pstartpos);
if (platform.compare(SDL_GetPlatform()) != 0)
{
// Ignore the mapping but still acknowledge that it is one.
success = true;
continue;
}
pstartpos -= strlen("platform:");
mapping.erase(pstartpos, pendpos - pstartpos + 1);
+9 -5
View File
@@ -179,13 +179,17 @@ int w_getGamepadMapping(lua_State *L)
int w_loadGamepadMappings(lua_State *L)
{
lua_pushvalue(L, 1);
luax_convobj(L, -1, "filesystem", "isFile");
bool isfile = luax_toboolean(L, -1);
lua_pop(L, 1);
bool isfile = true;
std::string mappings;
if (lua_isstring(L, 1))
{
lua_pushvalue(L, 1);
luax_convobj(L, -1, "filesystem", "isFile");
isfile = luax_toboolean(L, -1);
lua_pop(L, 1);
}
if (isfile)
{
love::filesystem::FileData *fd = love::filesystem::luax_getfiledata(L, 1);
+27
View File
@@ -28,6 +28,9 @@
#include "World.h"
#include "Physics.h"
// Needed for luax_pushjoint.
#include "wrap_Joint.h"
namespace love
{
namespace physics
@@ -440,6 +443,30 @@ int Body::getFixtureList(lua_State *L) const
return 1;
}
int Body::getJointList(lua_State *L) const
{
lua_newtable(L);
const b2JointEdge *je = body->GetJointList();
int i = 1;
do
{
if (!je)
break;
Joint *joint = (Joint *) Memoizer::find(je->joint);
if (!joint)
throw love::Exception("A joint has escaped Memoizer!");
luax_pushjoint(L, joint);
lua_rawseti(L, -2, i);
i++;
}
while ((je = je->next));
return 1;
}
int Body::getContactList(lua_State *L) const
{
lua_newtable(L);
+5
View File
@@ -393,6 +393,11 @@ public:
**/
int getFixtureList(lua_State *L) const;
/**
* Get an array of all Joints attached to this Body.
**/
int getJointList(lua_State *L) const;
/**
* Get an array of all active Contacts attached to this Body.
* This list changes during World:update and you may miss some collisions
+27
View File
@@ -23,6 +23,7 @@
// Module
#include "Body.h"
#include "World.h"
#include "common/Memoizer.h"
namespace love
{
@@ -60,6 +61,32 @@ float GearJoint::getRatio() const
return joint->GetRatio();
}
Joint *GearJoint::getJointA() const
{
b2Joint *b2joint = joint->GetJoint1();
if (b2joint == nullptr)
return nullptr;
Joint *j = (Joint *) Memoizer::find(b2joint);
if (j == nullptr)
throw love::Exception("A joint has escaped Memoizer!");
return j;
}
Joint *GearJoint::getJointB() const
{
b2Joint *b2joint = joint->GetJoint2();
if (b2joint == nullptr)
return nullptr;
Joint *j = (Joint *) Memoizer::find(b2joint);
if (j == nullptr)
throw love::Exception("A joint has escaped Memoizer!");
return j;
}
} // box2d
} // physics
} // love
+3
View File
@@ -64,6 +64,9 @@ public:
**/
float getRatio() const;
Joint *getJointA() const;
Joint *getJointB() const;
private:
// The Box2D GearJoint object.
b2GearJoint *joint;
+28
View File
@@ -90,11 +90,39 @@ Joint::Type Joint::getType() const
return JOINT_WHEEL;
case e_ropeJoint:
return JOINT_ROPE;
case e_motorJoint:
return JOINT_MOTOR;
default:
return JOINT_INVALID;
}
}
Body *Joint::getBodyA() const
{
b2Body *b2body = joint->GetBodyA();
if (b2body == nullptr)
return nullptr;
Body *body = (Body *) Memoizer::find(b2body);
if (body == nullptr)
throw love::Exception("A body has escaped Memoizer!");
return body;
}
Body *Joint::getBodyB() const
{
b2Body *b2body = joint->GetBodyB();
if (b2body == nullptr)
return nullptr;
Body *body = (Body *) Memoizer::find(b2body);
if (body == nullptr)
throw love::Exception("A body has escaped Memoizer!");
return body;
}
bool Joint::isValid() const
{
return joint != 0;
+3 -1
View File
@@ -79,12 +79,14 @@ public:
**/
bool isValid() const;
/**
* Gets the type of joint.
**/
Type getType() const;
Body *getBodyA() const;
Body *getBodyB() const;
/**
* Gets the anchor positions of the Joint in world
* coordinates. This is useful for debugdrawing the joint.
+10
View File
@@ -539,6 +539,15 @@ int w_Body_getFixtureList(lua_State *L)
return n;
}
int w_Body_getJointList(lua_State *L)
{
Body *t = luax_checkbody(L, 1);
lua_remove(L, 1);
int n = 0;
luax_catchexcept(L, [&](){ n = t->getJointList(L); });
return n;
}
int w_Body_getContactList(lua_State *L)
{
Body *t = luax_checkbody(L, 1);
@@ -623,6 +632,7 @@ static const luaL_Reg functions[] =
{ "isFixedRotation", w_Body_isFixedRotation },
{ "getWorld", w_Body_getWorld },
{ "getFixtureList", w_Body_getFixtureList },
{ "getJointList", w_Body_getJointList },
{ "getContactList", w_Body_getContactList },
{ "destroy", w_Body_destroy },
{ "setUserData", w_Body_setUserData },
+1
View File
@@ -85,6 +85,7 @@ int w_Body_setFixedRotation(lua_State *L);
int w_Body_isFixedRotation(lua_State *L);
int w_Body_getWorld(lua_State *L);
int w_Body_getFixtureList(lua_State *L);
int w_Body_getJointList(lua_State *L);
int w_Body_getContactList(lua_State *L);
int w_Body_destroy(lua_State *L);
int w_Body_setUserData(lua_State *L);
@@ -90,6 +90,7 @@ static const luaL_Reg functions[] =
{ "getDampingRatio", w_DistanceJoint_getDampingRatio },
// From Joint.
{ "getType", w_Joint_getType },
{ "getBodies", w_Joint_getBodies },
{ "getAnchors", w_Joint_getAnchors },
{ "getReactionForce", w_Joint_getReactionForce },
{ "getReactionTorque", w_Joint_getReactionTorque },
@@ -74,6 +74,7 @@ static const luaL_Reg functions[] =
{ "getMaxTorque", w_FrictionJoint_getMaxTorque },
// From Joint.
{ "getType", w_Joint_getType },
{ "getBodies", w_Joint_getBodies },
{ "getAnchors", w_Joint_getAnchors },
{ "getReactionForce", w_Joint_getReactionForce },
{ "getReactionTorque", w_Joint_getReactionTorque },
@@ -51,12 +51,30 @@ int w_GearJoint_getRatio(lua_State *L)
return 1;
}
int w_GearJoint_getJoints(lua_State *L)
{
GearJoint *t = luax_checkgearjoint(L, 1);
Joint *j1 = nullptr;
Joint *j2 = nullptr;
luax_catchexcept(L, [&]() {
j1 = t->getJointA();
j2 = t->getJointB();
});
luax_pushjoint(L, j1);
luax_pushjoint(L, j2);
return 2;
}
static const luaL_Reg functions[] =
{
{ "setRatio", w_GearJoint_setRatio },
{ "getRatio", w_GearJoint_getRatio },
{ "getJoints", w_GearJoint_getJoints },
// From Joint.
{ "getType", w_Joint_getType },
{ "getBodies", w_Joint_getBodies },
{ "getAnchors", w_Joint_getAnchors },
{ "getReactionForce", w_Joint_getReactionForce },
{ "getReactionTorque", w_Joint_getReactionTorque },
@@ -36,6 +36,7 @@ namespace box2d
GearJoint *luax_checkgearjoint(lua_State *L, int idx);
int w_GearJoint_setRatio(lua_State *L);
int w_GearJoint_getRatio(lua_State *L);
int w_GearJoint_getJoints(lua_State *L);
extern "C" int luaopen_gearjoint(lua_State *L);
} // box2d
+52
View File
@@ -21,6 +21,7 @@
// LOVE
#include "wrap_Joint.h"
#include "common/StringMap.h"
#include "Body.h"
namespace love
{
@@ -29,6 +30,40 @@ namespace physics
namespace box2d
{
void luax_pushjoint(lua_State *L, Joint *j)
{
if (j == nullptr)
return lua_pushnil(L);
switch (j->getType())
{
case Joint::JOINT_DISTANCE:
return luax_pushtype(L, "DistanceJoint", PHYSICS_DISTANCE_JOINT_T, j);
case Joint::JOINT_REVOLUTE:
return luax_pushtype(L, "RevoluteJoint", PHYSICS_REVOLUTE_JOINT_T, j);
case Joint::JOINT_PRISMATIC:
return luax_pushtype(L, "PrismaticJoint", PHYSICS_PRISMATIC_JOINT_T, j);
case Joint::JOINT_MOUSE:
return luax_pushtype(L, "MouseJoint", PHYSICS_MOUSE_JOINT_T, j);
case Joint::JOINT_PULLEY:
return luax_pushtype(L, "PulleyJoint", PHYSICS_PULLEY_JOINT_T, j);
case Joint::JOINT_GEAR:
return luax_pushtype(L, "GearJoint", PHYSICS_GEAR_JOINT_T, j);
case Joint::JOINT_FRICTION:
return luax_pushtype(L, "FrictionJoint", PHYSICS_FRICTION_JOINT_T, j);
case Joint::JOINT_WELD:
return luax_pushtype(L, "WeldJoint", PHYSICS_WELD_JOINT_T, j);
case Joint::JOINT_WHEEL:
return luax_pushtype(L, "WheelJoint", PHYSICS_WHEEL_JOINT_T, j);
case Joint::JOINT_ROPE:
return luax_pushtype(L, "RopeJoint", PHYSICS_ROPE_JOINT_T, j);
case Joint::JOINT_MOTOR:
return luax_pushtype(L, "MotorJoint", PHYSICS_MOTOR_JOINT_T, j);
default:
return lua_pushnil(L);
}
}
Joint *luax_checkjoint(lua_State *L, int idx)
{
Joint *t = luax_checktype<Joint>(L, idx, "Joint", PHYSICS_JOINT_T);
@@ -46,6 +81,22 @@ int w_Joint_getType(lua_State *L)
return 1;
}
int w_Joint_getBodies(lua_State *L)
{
Joint *t = luax_checkjoint(L, 1);
Body *b1 = nullptr;
Body *b2 = nullptr;
luax_catchexcept(L, [&]() {
b1 = t->getBodyA();
b2 = t->getBodyB();
});
luax_pushtype(L, "Body", PHYSICS_BODY_T, b1);
luax_pushtype(L, "Body", PHYSICS_BODY_T, b2);
return 2;
}
int w_Joint_getAnchors(lua_State *L)
{
Joint *t = luax_checkjoint(L, 1);
@@ -99,6 +150,7 @@ int w_Joint_destroy(lua_State *L)
static const luaL_Reg functions[] =
{
{ "getType", w_Joint_getType },
{ "getBodies", w_Joint_getBodies },
{ "getAnchors", w_Joint_getAnchors },
{ "getReactionForce", w_Joint_getReactionForce },
{ "getReactionTorque", w_Joint_getReactionTorque },
+2
View File
@@ -32,8 +32,10 @@ namespace physics
namespace box2d
{
void luax_pushjoint(lua_State *L, Joint *j);
Joint *luax_checkjoint(lua_State *L, int idx);
int w_Joint_getType(lua_State *L);
int w_Joint_getBodies(lua_State *L);
int w_Joint_getAnchors(lua_State *L);
int w_Joint_getReactionForce(lua_State *L);
int w_Joint_getReactionTorque(lua_State *L);
@@ -124,6 +124,7 @@ static const luaL_Reg functions[] =
{ "getCorrectionFactor", w_MotorJoint_getCorrectionFactor },
// From Joint.
{ "getType", w_Joint_getType },
{ "getBodies", w_Joint_getBodies },
{ "getAnchors", w_Joint_getAnchors },
{ "getReactionForce", w_Joint_getReactionForce },
{ "getReactionTorque", w_Joint_getReactionTorque },
@@ -108,6 +108,7 @@ static const luaL_Reg functions[] =
{ "getDampingRatio", w_MouseJoint_getDampingRatio },
// From Joint.
{ "getType", w_Joint_getType },
{ "getBodies", w_Joint_getBodies },
{ "getAnchors", w_Joint_getAnchors },
{ "getReactionForce", w_Joint_getReactionForce },
{ "getReactionTorque", w_Joint_getReactionTorque },
@@ -185,6 +185,7 @@ static const luaL_Reg functions[] =
{ "getLimits", w_PrismaticJoint_getLimits },
// From Joint.
{ "getType", w_Joint_getType },
{ "getBodies", w_Joint_getBodies },
{ "getAnchors", w_Joint_getAnchors },
{ "getReactionForce", w_Joint_getReactionForce },
{ "getReactionTorque", w_Joint_getReactionTorque },
@@ -71,6 +71,7 @@ static const luaL_Reg functions[] =
{ "getRatio", w_PulleyJoint_getRatio },
// From Joint.
{ "getType", w_Joint_getType },
{ "getBodies", w_Joint_getBodies },
{ "getAnchors", w_Joint_getAnchors },
{ "getReactionForce", w_Joint_getReactionForce },
{ "getReactionTorque", w_Joint_getReactionTorque },
@@ -185,6 +185,7 @@ static const luaL_Reg functions[] =
{ "getLimits", w_RevoluteJoint_getLimits },
// From Joint.
{ "getType", w_Joint_getType },
{ "getBodies", w_Joint_getBodies },
{ "getAnchors", w_Joint_getAnchors },
{ "getReactionForce", w_Joint_getReactionForce },
{ "getReactionTorque", w_Joint_getReactionTorque },
@@ -47,6 +47,7 @@ static const luaL_Reg functions[] =
{ "getMaxLength", w_RopeJoint_getMaxLength },
// From Joint.
{ "getType", w_Joint_getType },
{ "getBodies", w_Joint_getBodies },
{ "getAnchors", w_Joint_getAnchors },
{ "getReactionForce", w_Joint_getReactionForce },
{ "getReactionTorque", w_Joint_getReactionTorque },
@@ -73,6 +73,7 @@ static const luaL_Reg functions[] =
{ "getDampingRatio", w_WeldJoint_getDampingRatio },
// From Joint.
{ "getType", w_Joint_getType },
{ "getBodies", w_Joint_getBodies },
{ "getAnchors", w_Joint_getAnchors },
{ "getReactionForce", w_Joint_getReactionForce },
{ "getReactionTorque", w_Joint_getReactionTorque },
@@ -149,6 +149,7 @@ static const luaL_Reg functions[] =
{ "getSpringDampingRatio", w_WheelJoint_getSpringDampingRatio },
// From Joint.
{ "getType", w_Joint_getType },
{ "getBodies", w_Joint_getBodies },
{ "getAnchors", w_Joint_getAnchors },
{ "getReactionForce", w_Joint_getReactionForce },
{ "getReactionTorque", w_Joint_getReactionTorque },