axmol/core/physics/cpCompat62.h

123 lines
3.5 KiB
C
Raw Normal View History

2019-11-23 20:27:39 +08:00
/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software
*
* 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.
*/
#ifndef CHIPMUNK_COMPAT_62_H
#define CHIPMUNK_COMPAT_62_H
#include "chipmunk/chipmunk.h"
//
// Body
//
2021-12-25 10:04:45 +08:00
inline cpVect cpBodyGetVelAtWorldPoint(const cpBody* body)
2019-11-23 20:27:39 +08:00
{
return cpBodyGetVelocityAtWorldPoint(body);
}
2021-12-25 10:04:45 +08:00
inline cpVect cpBodyGetVelAtLocalPoint(const cpBody* body)
2019-11-23 20:27:39 +08:00
{
return cpBodyGetVelocityAtLocalPoint(body);
}
2021-12-25 10:04:45 +08:00
inline cpVect cpBodyGetVel(const cpBody* body)
2019-11-23 20:27:39 +08:00
{
return cpBodyGetVelocity(body);
}
2021-12-25 10:04:45 +08:00
inline void cpBodySetVel(cpBody* body, cpVect velocity)
2019-11-23 20:27:39 +08:00
{
cpBodySetVelocity(body, velocity);
}
2021-12-25 10:04:45 +08:00
inline cpVect cpBodyGetPos(const cpBody* body)
2019-11-23 20:27:39 +08:00
{
return cpBodyGetPosition(body);
}
2021-12-25 10:04:45 +08:00
inline void cpBodySetPos(cpBody* body, cpVect pos)
2019-11-23 20:27:39 +08:00
{
cpBodySetPosition(body, pos);
}
2021-12-25 10:04:45 +08:00
inline cpVect cpBodyGetRot(const cpBody* body)
2019-11-23 20:27:39 +08:00
{
return cpBodyGetRotation(body);
}
2021-12-25 10:04:45 +08:00
inline cpFloat cpBodyGetAngVel(const cpBody* body)
2019-11-23 20:27:39 +08:00
{
return cpBodyGetAngularVelocity(body);
}
2021-12-25 10:04:45 +08:00
inline void cpBodySetAngVel(cpBody* body, cpFloat angularVelocity)
2019-11-23 20:27:39 +08:00
{
cpBodySetAngularVelocity(body, angularVelocity);
}
2021-12-25 10:04:45 +08:00
inline cpVect cpBodyLocal2World(const cpBody* body, const cpVect point)
2019-11-23 20:27:39 +08:00
{
return cpBodyLocalToWorld(body, point);
}
2021-12-25 10:04:45 +08:00
inline cpVect cpBodyWorld2Local(const cpBody* body, const cpVect point)
2019-11-23 20:27:39 +08:00
{
return cpBodyWorldToLocal(body, point);
}
2021-12-25 10:04:45 +08:00
inline void cpBodyApplyImpulse(cpBody* body, const cpVect j, const cpVect r)
2019-11-23 20:27:39 +08:00
{
cpBodyApplyImpulseAtWorldPoint(body, j, r);
}
//
// Shapes
//
inline void cpShapeSetLayers(cpShape* shape, unsigned int layer)
{
cpShapeFilter filter = cpShapeGetFilter(shape);
2021-12-25 10:04:45 +08:00
filter.mask = layer;
filter.categories = layer;
2019-11-23 20:27:39 +08:00
cpShapeSetFilter(shape, filter);
}
inline unsigned int cpShapeGetLayers(cpShape* shape)
{
cpShapeFilter filter = cpShapeGetFilter(shape);
return filter.mask;
}
inline void cpShapeSetGroup(cpShape* shape, uintptr_t group)
{
cpShapeFilter filter = cpShapeGetFilter(shape);
2021-12-25 10:04:45 +08:00
filter.group = group;
2019-11-23 20:27:39 +08:00
cpShapeSetFilter(shape, filter);
}
inline uintptr_t cpShapeGetGroup(cpShape* shape)
{
cpShapeFilter filter = cpShapeGetFilter(shape);
return filter.group;
}
2021-12-25 10:04:45 +08:00
inline int cpPolyShapeGetNumVerts(const cpShape* shape)
2019-11-23 20:27:39 +08:00
{
return cpPolyShapeGetCount(shape);
}
2021-12-25 10:04:45 +08:00
inline cpFloat cpShapeNearestPointQuery(cpShape* shape, cpVect p, cpPointQueryInfo* out)
2019-11-23 20:27:39 +08:00
{
return cpShapePointQuery(shape, p, out);
}
//
// Space
//
2021-12-25 10:04:45 +08:00
inline cpShape* cpSpaceAddStaticShape(cpSpace* space, cpShape* shape)
2019-11-23 20:27:39 +08:00
{
return cpSpaceAddShape(space, shape);
}
2021-12-25 10:04:45 +08:00
#endif // CHIPMUNK_COMPAT_62_H