2013-09-09 10:29:02 +08:00
|
|
|
|
/****************************************************************************
|
2018-01-29 16:25:32 +08:00
|
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2021-10-24 14:09:59 +08:00
|
|
|
|
Copyright (c) 2021 Bytedance Inc.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
|
https://axys1.github.io/
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2013-09-09 10:29:02 +08:00
|
|
|
|
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:
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2013-09-09 10:29:02 +08:00
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
|
all copies or substantial portions of the Software.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2013-09-09 10:29:02 +08:00
|
|
|
|
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 __CCPHYSICS_BODY_H__
|
|
|
|
|
#define __CCPHYSICS_BODY_H__
|
|
|
|
|
|
2014-04-30 08:37:36 +08:00
|
|
|
|
#include "base/ccConfig.h"
|
2022-07-15 19:17:01 +08:00
|
|
|
|
#if AX_USE_PHYSICS
|
2013-11-06 14:51:56 +08:00
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
|
# include "2d/CCComponent.h"
|
|
|
|
|
# include "math/CCMath.h"
|
|
|
|
|
# include "physics/CCPhysicsShape.h"
|
|
|
|
|
# include "base/CCVector.h"
|
2013-09-09 10:29:02 +08:00
|
|
|
|
|
2015-01-06 10:29:07 +08:00
|
|
|
|
struct cpBody;
|
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
|
NS_AX_BEGIN
|
2014-02-20 10:53:49 +08:00
|
|
|
|
|
|
|
|
|
class Node;
|
2013-09-09 10:29:02 +08:00
|
|
|
|
class PhysicsWorld;
|
2013-09-09 16:36:19 +08:00
|
|
|
|
class PhysicsJoint;
|
2013-10-09 17:53:12 +08:00
|
|
|
|
|
2013-11-01 14:50:06 +08:00
|
|
|
|
const PhysicsMaterial PHYSICSBODY_MATERIAL_DEFAULT(0.1f, 0.5f, 0.5f);
|
2013-10-09 17:53:12 +08:00
|
|
|
|
|
2015-03-19 17:58:08 +08:00
|
|
|
|
/**
|
2015-05-28 15:47:03 +08:00
|
|
|
|
* @addtogroup physics
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* @{
|
2015-06-15 10:28:37 +08:00
|
|
|
|
* @addtogroup physics_2d
|
|
|
|
|
* @{
|
2015-03-19 17:58:08 +08:00
|
|
|
|
*/
|
|
|
|
|
|
2013-09-17 16:27:43 +08:00
|
|
|
|
/**
|
|
|
|
|
* A body affect by physics.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
*
|
|
|
|
|
* It can attach one or more shapes.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
* If you create body with createXXX, it will automatically compute mass and moment with density your specified(which is
|
|
|
|
|
* PHYSICSBODY_MATERIAL_DEFAULT by default, and the density value is 0.1f), and it based on the formula: mass = density
|
|
|
|
|
* * area. If you create body with createEdgeXXX, the mass and moment will be PHYSICS_INFINITY by default. And it's a
|
|
|
|
|
* static body. You can change mass and moment with setMass() and setMoment(). And you can change the body to be dynamic
|
|
|
|
|
* or static by use function setDynamic().
|
2013-09-17 16:27:43 +08:00
|
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
|
class AX_DLL PhysicsBody : public Component
|
2013-09-09 10:29:02 +08:00
|
|
|
|
{
|
|
|
|
|
public:
|
2015-09-18 11:48:43 +08:00
|
|
|
|
const static std::string COMPONENT_NAME;
|
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
|
/**
|
2015-09-18 11:48:43 +08:00
|
|
|
|
* Create a body with default mass and moment.
|
|
|
|
|
*
|
|
|
|
|
* This default mass value is 1.0.
|
|
|
|
|
* This default moment value is 200.
|
|
|
|
|
* @return An autoreleased PhysicsBody object pointer.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
*/
|
2013-10-10 18:31:43 +08:00
|
|
|
|
static PhysicsBody* create();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2015-09-18 11:48:43 +08:00
|
|
|
|
* Create a body with mass and default moment.
|
|
|
|
|
*
|
|
|
|
|
* @param mass This body's mass.
|
|
|
|
|
* @return An autoreleased PhysicsBody object pointer.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
*/
|
2013-10-28 11:08:41 +08:00
|
|
|
|
static PhysicsBody* create(float mass);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2015-09-18 11:48:43 +08:00
|
|
|
|
* Create a body with mass and moment.
|
|
|
|
|
*
|
|
|
|
|
* @param mass This body's mass.
|
|
|
|
|
* @param moment This body's moment.
|
|
|
|
|
* @return An autoreleased PhysicsBody object pointer.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
*/
|
2013-10-28 11:08:41 +08:00
|
|
|
|
static PhysicsBody* create(float mass, float moment);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2015-09-18 11:48:43 +08:00
|
|
|
|
/**
|
|
|
|
|
* Create a body contains a circle.
|
|
|
|
|
*
|
|
|
|
|
* @param radius A float number, it is the circle's radius.
|
|
|
|
|
* @param material A PhysicsMaterial object, the default value is PHYSICSSHAPE_MATERIAL_DEFAULT.
|
2015-09-22 16:08:23 +08:00
|
|
|
|
* @param offset A Vec2 object, it is the offset from the body's center of gravity in body local coordinates.
|
2015-09-18 11:48:43 +08:00
|
|
|
|
* @return An autoreleased PhysicsBody object pointer.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
|
static PhysicsBody* createCircle(float radius,
|
|
|
|
|
const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT,
|
|
|
|
|
const Vec2& offset = Vec2::ZERO);
|
2015-09-18 11:48:43 +08:00
|
|
|
|
/**
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* Create a body contains a box shape.
|
|
|
|
|
*
|
2021-10-24 14:09:59 +08:00
|
|
|
|
* @param size Size contains this box's width and height.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* @param material A PhysicsMaterial object, the default value is PHYSICSSHAPE_MATERIAL_DEFAULT.
|
2015-09-22 16:08:23 +08:00
|
|
|
|
* @param offset A Vec2 object, it is the offset from the body's center of gravity in body local coordinates.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* @return An autoreleased PhysicsBody object pointer.
|
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
|
static PhysicsBody* createBox(const Vec2& size,
|
|
|
|
|
const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT,
|
|
|
|
|
const Vec2& offset = Vec2::ZERO);
|
2015-09-18 11:48:43 +08:00
|
|
|
|
|
2013-09-17 16:27:43 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Create a body contains a polygon shape.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
*
|
|
|
|
|
* @param points Points is an array of Vec2 structs defining a convex hull with a clockwise winding.
|
2015-09-22 16:08:23 +08:00
|
|
|
|
* @param count An integer number, contains the count of the points array.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* @param material A PhysicsMaterial object, the default value is PHYSICSSHAPE_MATERIAL_DEFAULT.
|
2015-09-22 16:08:23 +08:00
|
|
|
|
* @param offset A Vec2 object, it is the offset from the body's center of gravity in body local coordinates.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* @return An autoreleased PhysicsBody object pointer.
|
2013-09-17 16:27:43 +08:00
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
|
static PhysicsBody* createPolygon(const Vec2* points,
|
|
|
|
|
int count,
|
|
|
|
|
const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT,
|
|
|
|
|
const Vec2& offset = Vec2::ZERO);
|
2015-09-18 11:48:43 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a body contains a EdgeSegment shape.
|
|
|
|
|
*
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* @param a It's the edge's begin position.
|
|
|
|
|
* @param b It's the edge's end position.
|
|
|
|
|
* @param material A PhysicsMaterial object, the default value is PHYSICSSHAPE_MATERIAL_DEFAULT.
|
|
|
|
|
* @param border It's a edge's border width.
|
|
|
|
|
* @return An autoreleased PhysicsBody object pointer.
|
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
|
static PhysicsBody* createEdgeSegment(const Vec2& a,
|
|
|
|
|
const Vec2& b,
|
|
|
|
|
const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT,
|
|
|
|
|
float border = 1);
|
2015-03-19 17:58:08 +08:00
|
|
|
|
|
2015-09-18 11:48:43 +08:00
|
|
|
|
/**
|
|
|
|
|
* Create a body contains a EdgeBox shape.
|
2021-10-24 22:06:13 +08:00
|
|
|
|
* @param size The size contains this box's width and height.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* @param material A PhysicsMaterial object, the default value is PHYSICSSHAPE_MATERIAL_DEFAULT.
|
|
|
|
|
* @param border It's a edge's border width.
|
2015-09-22 16:08:23 +08:00
|
|
|
|
* @param offset A Vec2 object, it is the offset from the body's center of gravity in body local coordinates.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* @return An autoreleased PhysicsBody object pointer.
|
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
|
static PhysicsBody* createEdgeBox(const Vec2& size,
|
|
|
|
|
const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT,
|
|
|
|
|
float border = 1,
|
|
|
|
|
const Vec2& offset = Vec2::ZERO);
|
2015-09-18 11:48:43 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a body contains a EdgePolygon shape.
|
|
|
|
|
*
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* @param points Points is an array of Vec2 structs defining a convex hull with a clockwise winding.
|
2015-09-22 16:08:23 +08:00
|
|
|
|
* @param count An integer number, contains the count of the points array.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* @param material A PhysicsMaterial object, the default value is PHYSICSSHAPE_MATERIAL_DEFAULT.
|
|
|
|
|
* @param border It's a edge's border width.
|
|
|
|
|
* @return An autoreleased PhysicsBody object pointer.
|
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
|
static PhysicsBody* createEdgePolygon(const Vec2* points,
|
|
|
|
|
int count,
|
|
|
|
|
const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT,
|
|
|
|
|
float border = 1);
|
2015-09-18 11:48:43 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a body contains a EdgeChain shape.
|
|
|
|
|
*
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* @param points A Vec2 object pointer, it contains an array of points.
|
2015-09-22 16:08:23 +08:00
|
|
|
|
* @param count An integer number, contains the count of the points array.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* @param material A PhysicsMaterial object, the default value is PHYSICSSHAPE_MATERIAL_DEFAULT.
|
|
|
|
|
* @param border It's a edge's border width.
|
2015-09-18 11:48:43 +08:00
|
|
|
|
* @return An autoreleased PhysicsBody object pointer.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
|
static PhysicsBody* createEdgeChain(const Vec2* points,
|
|
|
|
|
int count,
|
|
|
|
|
const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT,
|
|
|
|
|
float border = 1);
|
2015-09-18 11:48:43 +08:00
|
|
|
|
|
2015-03-19 17:58:08 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Add a shape to body.
|
|
|
|
|
* @param shape The shape to be added.
|
|
|
|
|
* @param addMassAndMoment If this is true, the shape's mass and moment will be added to body. The default is true.
|
|
|
|
|
* @return This shape's pointer if added success or nullptr if failed.
|
2013-09-17 16:27:43 +08:00
|
|
|
|
*/
|
2013-11-12 15:28:07 +08:00
|
|
|
|
virtual PhysicsShape* addShape(PhysicsShape* shape, bool addMassAndMoment = true);
|
2015-03-19 17:58:08 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Remove a shape from body.
|
|
|
|
|
* @param shape Shape the shape to be removed.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
* @param reduceMassAndMoment If this is true, the body mass and moment will be reduced by shape. The default is
|
|
|
|
|
* true.
|
2013-09-17 16:27:43 +08:00
|
|
|
|
*/
|
2013-11-12 15:28:07 +08:00
|
|
|
|
void removeShape(PhysicsShape* shape, bool reduceMassAndMoment = true);
|
2015-03-19 17:58:08 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Remove a shape from body.
|
|
|
|
|
* @param tag The tag of the shape to be removed.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
* @param reduceMassAndMoment If this is true, the body mass and moment will be reduced by shape. The default is
|
|
|
|
|
* true.
|
2013-09-17 16:27:43 +08:00
|
|
|
|
*/
|
2013-11-12 15:28:07 +08:00
|
|
|
|
void removeShape(int tag, bool reduceMassAndMoment = true);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2015-09-18 11:48:43 +08:00
|
|
|
|
* Remove all shapes.
|
|
|
|
|
*
|
2021-12-25 10:04:45 +08:00
|
|
|
|
* @param reduceMassAndMoment If this is true, the body mass and moment will be reduced by shape. The default is
|
|
|
|
|
* true.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
*/
|
2013-11-12 15:28:07 +08:00
|
|
|
|
void removeAllShapes(bool reduceMassAndMoment = true);
|
2015-03-19 17:58:08 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2015-09-18 11:48:43 +08:00
|
|
|
|
* Get the body shapes.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
*
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* @return A Vector<PhysicsShape*> object contains PhysicsShape pointer.
|
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
|
const Vector<PhysicsShape*>& getShapes() const { return _shapes; }
|
2015-03-19 17:58:08 +08:00
|
|
|
|
|
2016-08-30 10:23:14 +08:00
|
|
|
|
/**
|
|
|
|
|
* Get the first shape of the body shapes.
|
|
|
|
|
*
|
|
|
|
|
* @return The first shape in this body.
|
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
|
PhysicsShape* getFirstShape() const { return _shapes.size() >= 1 ? _shapes.at(0) : nullptr; }
|
2016-08-30 10:23:14 +08:00
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
|
/**
|
2015-09-18 11:48:43 +08:00
|
|
|
|
* get the shape of the body.
|
|
|
|
|
*
|
2015-09-22 16:08:23 +08:00
|
|
|
|
* @param tag An integer number that identifies a PhysicsShape object.
|
2015-09-18 11:48:43 +08:00
|
|
|
|
* @return A PhysicsShape object pointer or nullptr if no shapes were found.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
*/
|
2013-11-12 15:28:07 +08:00
|
|
|
|
PhysicsShape* getShape(int tag) const;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2015-09-18 11:48:43 +08:00
|
|
|
|
* Applies a continuous force to body.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
*
|
2015-09-18 11:48:43 +08:00
|
|
|
|
* @param force The force is applies to this body.
|
2015-09-22 16:08:23 +08:00
|
|
|
|
* @param offset A Vec2 object, it is the offset from the body's center of gravity in world coordinates.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
*/
|
2015-09-18 11:48:43 +08:00
|
|
|
|
virtual void applyForce(const Vec2& force, const Vec2& offset = Vec2::ZERO);
|
2015-03-19 17:58:08 +08:00
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
|
/**
|
|
|
|
|
* reset all the force applied to body.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
*/
|
2013-11-18 16:27:23 +08:00
|
|
|
|
virtual void resetForces();
|
2015-03-19 17:58:08 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2015-09-18 11:48:43 +08:00
|
|
|
|
* Applies a immediate force to body.
|
|
|
|
|
*
|
|
|
|
|
* @param impulse The impulse is applies to this body.
|
2015-09-22 16:08:23 +08:00
|
|
|
|
* @param offset A Vec2 object, it is the offset from the body's center of gravity in world coordinates.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
*/
|
2015-09-18 11:48:43 +08:00
|
|
|
|
virtual void applyImpulse(const Vec2& impulse, const Vec2& offset = Vec2::ZERO);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2015-09-18 11:48:43 +08:00
|
|
|
|
* Applies a torque force to body.
|
|
|
|
|
*
|
|
|
|
|
* @param torque The torque is applies to this body.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
*/
|
2013-09-09 10:29:02 +08:00
|
|
|
|
virtual void applyTorque(float torque);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2015-09-18 11:48:43 +08:00
|
|
|
|
* Set the velocity of a body.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
*
|
2015-09-18 11:48:43 +08:00
|
|
|
|
* @param velocity The velocity is set to this body.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
*/
|
2015-09-18 11:48:43 +08:00
|
|
|
|
virtual void setVelocity(const Vec2& velocity);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2015-03-19 17:58:08 +08:00
|
|
|
|
/** Get the velocity of a body. */
|
2014-05-15 01:07:09 +08:00
|
|
|
|
virtual Vec2 getVelocity();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2015-09-18 11:48:43 +08:00
|
|
|
|
* Set the angular velocity of a body.
|
|
|
|
|
*
|
|
|
|
|
* @param velocity The angular velocity is set to this body.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
*/
|
2013-10-18 15:34:13 +08:00
|
|
|
|
virtual void setAngularVelocity(float velocity);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2015-03-19 17:58:08 +08:00
|
|
|
|
/** Get the angular velocity of a body at a local point.*/
|
2014-05-15 01:07:09 +08:00
|
|
|
|
virtual Vec2 getVelocityAtLocalPoint(const Vec2& point);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2013-11-12 15:28:07 +08:00
|
|
|
|
/** get the angular velocity of a body at a world point */
|
2014-05-15 01:07:09 +08:00
|
|
|
|
virtual Vec2 getVelocityAtWorldPoint(const Vec2& point);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2013-11-12 15:28:07 +08:00
|
|
|
|
/** get the angular velocity of a body */
|
2013-10-18 15:34:13 +08:00
|
|
|
|
virtual float getAngularVelocity();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2013-11-12 15:28:07 +08:00
|
|
|
|
/** set the max of velocity */
|
2013-10-18 15:34:13 +08:00
|
|
|
|
virtual void setVelocityLimit(float limit);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2013-11-12 15:28:07 +08:00
|
|
|
|
/** get the max of velocity */
|
2013-10-18 15:34:13 +08:00
|
|
|
|
virtual float getVelocityLimit();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2013-11-12 15:28:07 +08:00
|
|
|
|
/** set the max of angular velocity */
|
2013-10-18 15:34:13 +08:00
|
|
|
|
virtual void setAngularVelocityLimit(float limit);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2013-11-12 15:28:07 +08:00
|
|
|
|
/** get the max of angular velocity */
|
2013-10-18 15:34:13 +08:00
|
|
|
|
virtual float getAngularVelocityLimit();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2013-11-12 15:28:07 +08:00
|
|
|
|
/** remove the body from the world it added to */
|
2013-10-28 11:08:41 +08:00
|
|
|
|
void removeFromWorld();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2013-11-12 15:28:07 +08:00
|
|
|
|
/** get the world body added to. */
|
2016-09-12 09:44:21 +08:00
|
|
|
|
PhysicsWorld* getWorld() const { return _world; }
|
2015-09-18 11:48:43 +08:00
|
|
|
|
|
2013-11-12 15:28:07 +08:00
|
|
|
|
/** get all joints the body have */
|
2016-09-12 09:44:21 +08:00
|
|
|
|
const std::vector<PhysicsJoint*>& getJoints() const { return _joints; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2015-09-18 11:48:43 +08:00
|
|
|
|
/** get the node the body set to. */
|
|
|
|
|
Node* getNode() const { return _owner; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2013-11-12 15:28:07 +08:00
|
|
|
|
/**
|
|
|
|
|
* A mask that defines which categories this physics body belongs to.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
*
|
|
|
|
|
* Every physics body in a scene can be assigned to up to 32 different categories, each corresponding to a bit in
|
|
|
|
|
* the bit mask. You define the mask values used in your game. In conjunction with the collisionBitMask and
|
|
|
|
|
* contactTestBitMask properties, you define which physics bodies interact with each other and when your game is
|
|
|
|
|
* notified of these interactions.
|
2015-09-22 16:08:23 +08:00
|
|
|
|
* @param bitmask An integer number, the default value is 0xFFFFFFFF (all bits set).
|
2013-11-12 15:28:07 +08:00
|
|
|
|
*/
|
2013-10-29 17:31:35 +08:00
|
|
|
|
void setCategoryBitmask(int bitmask);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2013-11-12 15:28:07 +08:00
|
|
|
|
* A mask that defines which categories of bodies cause intersection notifications with this physics body.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
*
|
2021-12-25 10:04:45 +08:00
|
|
|
|
* When two bodies share the same space, each body's category mask is tested against the other body's contact mask
|
|
|
|
|
* by performing a logical AND operation. If either comparison results in a non-zero value, an PhysicsContact object
|
|
|
|
|
* is created and passed to the physics world’s delegate. For best performance, only set bits in the contacts mask
|
|
|
|
|
* for interactions you are interested in.
|
2015-09-22 16:08:23 +08:00
|
|
|
|
* @param bitmask An integer number, the default value is 0x00000000 (all bits cleared).
|
2013-11-12 15:28:07 +08:00
|
|
|
|
*/
|
2013-10-29 17:31:35 +08:00
|
|
|
|
void setContactTestBitmask(int bitmask);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2013-11-12 15:28:07 +08:00
|
|
|
|
/**
|
|
|
|
|
* A mask that defines which categories of physics bodies can collide with this physics body.
|
2015-03-19 17:58:08 +08:00
|
|
|
|
*
|
2021-12-25 10:04:45 +08:00
|
|
|
|
* When two physics bodies contact each other, a collision may occur. This body's collision mask is compared to the
|
|
|
|
|
* other body's category mask by performing a logical AND operation. If the result is a non-zero value, then this
|
|
|
|
|
* body is affected by the collision. Each body independently chooses whether it wants to be affected by the other
|
|
|
|
|
* body. For example, you might use this to avoid collision calculations that would make negligible changes to a
|
|
|
|
|
* body's velocity.
|
2015-09-22 16:08:23 +08:00
|
|
|
|
* @param bitmask An integer number, the default value is 0xFFFFFFFF (all bits set).
|
2013-11-12 15:28:07 +08:00
|
|
|
|
*/
|
2013-10-29 17:31:35 +08:00
|
|
|
|
void setCollisionBitmask(int bitmask);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2015-09-18 11:48:43 +08:00
|
|
|
|
* Return bitmask of first shape.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
*
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* @return If there is no shape in body, return default value.(0xFFFFFFFF)
|
|
|
|
|
*/
|
2014-08-08 16:38:20 +08:00
|
|
|
|
int getCategoryBitmask() const;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2015-09-18 11:48:43 +08:00
|
|
|
|
* Return bitmask of first shape.
|
|
|
|
|
*
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* @return If there is no shape in body, return default value.(0x00000000)
|
|
|
|
|
*/
|
2014-08-08 16:38:20 +08:00
|
|
|
|
int getContactTestBitmask() const;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2015-09-18 11:48:43 +08:00
|
|
|
|
* Return bitmask of first shape.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
*
|
2015-09-18 11:48:43 +08:00
|
|
|
|
* @return If there is no shape in body, return default value.(0xFFFFFFFF)
|
2015-03-19 17:58:08 +08:00
|
|
|
|
*/
|
2014-08-08 16:38:20 +08:00
|
|
|
|
int getCollisionBitmask() const;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* Set the group of body.
|
|
|
|
|
*
|
2021-12-25 10:04:45 +08:00
|
|
|
|
* Collision groups let you specify an integral group index. You can have all fixtures with the same group index
|
|
|
|
|
* always collide (positive index) or never collide (negative index). It have high priority than bit masks.
|
2013-11-12 15:28:07 +08:00
|
|
|
|
*/
|
2013-10-29 17:31:35 +08:00
|
|
|
|
void setGroup(int group);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2015-09-18 11:48:43 +08:00
|
|
|
|
* Return group of first shape.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
*
|
|
|
|
|
* @return If there is no shape in body, return default value.(0)
|
2015-03-19 17:58:08 +08:00
|
|
|
|
*/
|
2014-08-08 16:38:20 +08:00
|
|
|
|
int getGroup() const;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2013-11-12 15:28:07 +08:00
|
|
|
|
/** get the body position. */
|
2015-09-08 09:54:01 +08:00
|
|
|
|
Vec2 getPosition() const;
|
2015-09-18 11:48:43 +08:00
|
|
|
|
|
2013-11-12 15:28:07 +08:00
|
|
|
|
/** get the body rotation. */
|
2015-01-08 14:25:06 +08:00
|
|
|
|
float getRotation();
|
2015-09-18 11:48:43 +08:00
|
|
|
|
|
2014-02-28 15:31:25 +08:00
|
|
|
|
/** set body position offset, it's the position witch relative to node */
|
2014-05-15 01:07:09 +08:00
|
|
|
|
void setPositionOffset(const Vec2& position);
|
2015-09-18 11:48:43 +08:00
|
|
|
|
|
2014-02-28 15:31:25 +08:00
|
|
|
|
/** get body position offset. */
|
2015-01-08 14:25:06 +08:00
|
|
|
|
const Vec2& getPositionOffset() const { return _positionOffset; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2014-02-28 15:31:25 +08:00
|
|
|
|
/** set body rotation offset, it's the rotation witch relative to node */
|
|
|
|
|
void setRotationOffset(float rotation);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2014-02-28 15:31:25 +08:00
|
|
|
|
/** set the body rotation offset */
|
2015-01-08 14:25:06 +08:00
|
|
|
|
float getRotationOffset() const { return _rotationOffset; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2013-11-12 15:28:07 +08:00
|
|
|
|
/**
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* @brief Test the body is dynamic or not.
|
|
|
|
|
*
|
|
|
|
|
* A dynamic body will effect with gravity.
|
2013-09-17 16:27:43 +08:00
|
|
|
|
*/
|
2016-09-12 09:44:21 +08:00
|
|
|
|
bool isDynamic() const { return _dynamic; }
|
2013-11-12 15:28:07 +08:00
|
|
|
|
/**
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* @brief Set dynamic to body.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
*
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* A dynamic body will effect with gravity.
|
2013-09-17 16:27:43 +08:00
|
|
|
|
*/
|
2013-09-16 21:22:22 +08:00
|
|
|
|
void setDynamic(bool dynamic);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2013-11-12 15:28:07 +08:00
|
|
|
|
/**
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* @brief Set the body mass.
|
|
|
|
|
*
|
2021-12-25 10:04:45 +08:00
|
|
|
|
* @attention If you need add/subtract mass to body, don't use setMass(getMass() +/- mass), because the mass of body
|
|
|
|
|
* may be equal to PHYSICS_INFINITY, it will cause some unexpected result, please use addMass() instead.
|
2013-09-17 16:27:43 +08:00
|
|
|
|
*/
|
2013-09-16 21:22:22 +08:00
|
|
|
|
void setMass(float mass);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2015-03-19 17:58:08 +08:00
|
|
|
|
/** Get the body mass. */
|
2016-09-12 09:44:21 +08:00
|
|
|
|
float getMass() const { return _mass; }
|
2015-09-18 11:48:43 +08:00
|
|
|
|
|
2013-11-12 15:28:07 +08:00
|
|
|
|
/**
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* @brief Add mass to body.
|
|
|
|
|
*
|
|
|
|
|
* @param mass If _mass(mass of the body) == PHYSICS_INFINITY, it remains.
|
2013-11-27 17:33:33 +08:00
|
|
|
|
* if mass == PHYSICS_INFINITY, _mass will be PHYSICS_INFINITY.
|
|
|
|
|
* if mass == -PHYSICS_INFINITY, _mass will not change.
|
2013-10-18 15:34:13 +08:00
|
|
|
|
* if mass + _mass <= 0, _mass will equal to MASS_DEFAULT(1.0)
|
|
|
|
|
* other wise, mass = mass + _mass;
|
|
|
|
|
*/
|
|
|
|
|
void addMass(float mass);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2013-11-12 15:28:07 +08:00
|
|
|
|
/**
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* @brief Set the body moment of inertia.
|
|
|
|
|
*
|
2021-12-25 10:04:45 +08:00
|
|
|
|
* @note If you need add/subtract moment to body, don't use setMoment(getMoment() +/- moment), because the moment of
|
|
|
|
|
* body may be equal to PHYSICS_INFINITY, it will cause some unexpected result, please use addMoment() instead.
|
2013-10-18 15:34:13 +08:00
|
|
|
|
*/
|
|
|
|
|
void setMoment(float moment);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2015-03-19 17:58:08 +08:00
|
|
|
|
/** Get the body moment of inertia. */
|
2016-09-12 09:44:21 +08:00
|
|
|
|
float getMoment() const { return _moment; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2013-11-12 15:28:07 +08:00
|
|
|
|
/**
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* @brief Add moment of inertia to body.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
*
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* @param moment If _moment(moment of the body) == PHYSICS_INFINITY, it remains.
|
2013-11-27 17:33:33 +08:00
|
|
|
|
* if moment == PHYSICS_INFINITY, _moment will be PHYSICS_INFINITY.
|
|
|
|
|
* if moment == -PHYSICS_INFINITY, _moment will not change.
|
2013-10-18 15:34:13 +08:00
|
|
|
|
* if moment + _moment <= 0, _moment will equal to MASS_DEFAULT(1.0)
|
|
|
|
|
* other wise, moment = moment + _moment;
|
|
|
|
|
*/
|
|
|
|
|
void addMoment(float moment);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2013-11-12 15:28:07 +08:00
|
|
|
|
/** get linear damping. */
|
2016-09-12 09:44:21 +08:00
|
|
|
|
float getLinearDamping() const { return _linearDamping; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* Set linear damping.
|
|
|
|
|
*
|
|
|
|
|
* it is used to simulate fluid or air friction forces on the body.
|
|
|
|
|
* @param damping The value is 0.0f to 1.0f.
|
2013-11-12 15:28:07 +08:00
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
|
void setLinearDamping(float damping)
|
|
|
|
|
{
|
|
|
|
|
_linearDamping = damping;
|
|
|
|
|
updateDamping();
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-19 17:58:08 +08:00
|
|
|
|
/** Get angular damping. */
|
2016-09-12 09:44:21 +08:00
|
|
|
|
float getAngularDamping() const { return _angularDamping; }
|
2015-09-18 11:48:43 +08:00
|
|
|
|
|
2013-11-12 15:28:07 +08:00
|
|
|
|
/**
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* Set angular damping.
|
|
|
|
|
*
|
|
|
|
|
* It is used to simulate fluid or air friction forces on the body.
|
|
|
|
|
* @param damping The value is 0.0f to 1.0f.
|
2013-11-12 15:28:07 +08:00
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
|
void setAngularDamping(float damping)
|
|
|
|
|
{
|
|
|
|
|
_angularDamping = damping;
|
|
|
|
|
updateDamping();
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-19 17:58:08 +08:00
|
|
|
|
/** Whether the body is at rest. */
|
2013-11-01 16:26:03 +08:00
|
|
|
|
bool isResting() const;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2014-02-24 16:29:14 +08:00
|
|
|
|
/** set body to rest */
|
2014-02-26 19:56:52 +08:00
|
|
|
|
void setResting(bool rest) const;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2013-11-12 15:28:07 +08:00
|
|
|
|
/**
|
2015-03-19 17:58:08 +08:00
|
|
|
|
* Set the enable value.
|
|
|
|
|
*
|
|
|
|
|
* If the body it isn't enabled, it will not has simulation by world.
|
2013-11-12 15:28:07 +08:00
|
|
|
|
*/
|
2015-09-18 11:48:43 +08:00
|
|
|
|
virtual void setEnabled(bool enable) override;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2015-03-19 17:58:08 +08:00
|
|
|
|
/** Whether the body can rotation. */
|
2016-09-12 09:44:21 +08:00
|
|
|
|
bool isRotationEnabled() const { return _rotationEnabled; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2015-03-19 17:58:08 +08:00
|
|
|
|
/** Set the body is allow rotation or not */
|
2013-10-18 15:34:13 +08:00
|
|
|
|
void setRotationEnable(bool enable);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2015-09-22 16:08:23 +08:00
|
|
|
|
/** Whether this physics body is affected by the physics world's gravitational force. */
|
2016-09-12 09:44:21 +08:00
|
|
|
|
bool isGravityEnabled() const { return _gravityEnabled; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2015-03-19 17:58:08 +08:00
|
|
|
|
/** Set the body is affected by the physics world's gravitational force or not. */
|
2013-10-18 15:34:13 +08:00
|
|
|
|
void setGravityEnable(bool enable);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2015-03-19 17:58:08 +08:00
|
|
|
|
/** Get the body's tag. */
|
2016-09-12 09:44:21 +08:00
|
|
|
|
int getTag() const { return _tag; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2015-03-19 17:58:08 +08:00
|
|
|
|
/** set the body's tag. */
|
2016-09-12 09:44:21 +08:00
|
|
|
|
void setTag(int tag) { _tag = tag; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2015-03-19 17:58:08 +08:00
|
|
|
|
/** Convert the world point to local. */
|
2014-05-15 01:07:09 +08:00
|
|
|
|
Vec2 world2Local(const Vec2& point);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2015-03-19 17:58:08 +08:00
|
|
|
|
/** Convert the local point to world. */
|
2014-05-15 01:07:09 +08:00
|
|
|
|
Vec2 local2World(const Vec2& point);
|
2015-01-06 10:29:07 +08:00
|
|
|
|
|
2015-03-19 17:58:08 +08:00
|
|
|
|
/** Get the rigid body of chipmunk. */
|
2015-09-08 09:54:01 +08:00
|
|
|
|
cpBody* getCPBody() const { return _cpBody; }
|
2015-09-18 11:48:43 +08:00
|
|
|
|
|
|
|
|
|
virtual void onEnter() override;
|
|
|
|
|
virtual void onExit() override;
|
|
|
|
|
virtual void onAdd() override;
|
|
|
|
|
virtual void onRemove() override;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2013-09-09 10:29:02 +08:00
|
|
|
|
protected:
|
2015-09-18 11:48:43 +08:00
|
|
|
|
PhysicsBody();
|
|
|
|
|
virtual ~PhysicsBody();
|
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
|
virtual bool init() override;
|
|
|
|
|
|
2015-09-18 11:48:43 +08:00
|
|
|
|
virtual void setPosition(float positionX, float positionY);
|
|
|
|
|
|
2013-09-16 21:22:22 +08:00
|
|
|
|
virtual void setRotation(float rotation);
|
2015-09-18 11:48:43 +08:00
|
|
|
|
|
2014-06-27 17:30:21 +08:00
|
|
|
|
virtual void setScale(float scaleX, float scaleY);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
|
|
void update(float delta) override;
|
|
|
|
|
|
2013-11-07 14:17:57 +08:00
|
|
|
|
void removeJoint(PhysicsJoint* joint);
|
2015-09-18 11:48:43 +08:00
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
|
void updateDamping() { _isDamping = _linearDamping != 0.0f || _angularDamping != 0.0f; }
|
2015-09-18 11:48:43 +08:00
|
|
|
|
|
|
|
|
|
void addToPhysicsWorld();
|
|
|
|
|
void removeFromPhysicsWorld();
|
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
|
void beforeSimulation(const Mat4& parentToWorldTransform,
|
|
|
|
|
const Mat4& nodeToWorldTransform,
|
|
|
|
|
float scaleX,
|
|
|
|
|
float scaleY,
|
|
|
|
|
float rotation);
|
2015-09-18 11:48:43 +08:00
|
|
|
|
void afterSimulation(const Mat4& parentToWorldTransform, float parentRotation);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2013-09-10 17:36:49 +08:00
|
|
|
|
protected:
|
2014-01-17 13:35:58 +08:00
|
|
|
|
std::vector<PhysicsJoint*> _joints;
|
|
|
|
|
Vector<PhysicsShape*> _shapes;
|
|
|
|
|
PhysicsWorld* _world;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2015-01-06 10:29:07 +08:00
|
|
|
|
cpBody* _cpBody;
|
2014-01-17 13:35:58 +08:00
|
|
|
|
bool _dynamic;
|
2014-03-20 10:21:59 +08:00
|
|
|
|
bool _rotationEnabled;
|
|
|
|
|
bool _gravityEnabled;
|
2014-01-17 13:35:58 +08:00
|
|
|
|
bool _massDefault;
|
|
|
|
|
bool _momentDefault;
|
|
|
|
|
float _mass;
|
|
|
|
|
float _area;
|
|
|
|
|
float _density;
|
|
|
|
|
float _moment;
|
2016-03-01 05:53:00 +08:00
|
|
|
|
float _velocityLimit;
|
|
|
|
|
float _angularVelocityLimit;
|
2014-02-25 15:27:25 +08:00
|
|
|
|
bool _isDamping;
|
2014-01-17 13:35:58 +08:00
|
|
|
|
float _linearDamping;
|
|
|
|
|
float _angularDamping;
|
2015-09-18 11:48:43 +08:00
|
|
|
|
|
2014-01-17 13:35:58 +08:00
|
|
|
|
int _tag;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2015-09-08 09:54:01 +08:00
|
|
|
|
// when setMass() is invoked, it means body's mass is not calculated by shapes
|
|
|
|
|
bool _massSetByUser;
|
|
|
|
|
// when setMoment() is invoked, it means body's moment is not calculated by shapes
|
|
|
|
|
bool _momentSetByUser;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
|
Vec2 _positionOffset;
|
2014-02-28 15:31:25 +08:00
|
|
|
|
float _rotationOffset;
|
2015-01-08 14:25:06 +08:00
|
|
|
|
float _recordedRotation;
|
|
|
|
|
double _recordedAngle;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
2015-09-18 11:48:43 +08:00
|
|
|
|
// offset between owner's center point and down left point
|
|
|
|
|
Vec3 _ownerCenterOffset;
|
|
|
|
|
// offset of owner's center point and anchor point in parent coordinate
|
|
|
|
|
Vec2 _offset;
|
|
|
|
|
float _recordScaleX;
|
|
|
|
|
float _recordScaleY;
|
|
|
|
|
|
|
|
|
|
float _recordPosX;
|
|
|
|
|
float _recordPosY;
|
|
|
|
|
|
2013-09-16 21:22:22 +08:00
|
|
|
|
friend class PhysicsWorld;
|
|
|
|
|
friend class PhysicsShape;
|
|
|
|
|
friend class PhysicsJoint;
|
2013-09-09 10:29:02 +08:00
|
|
|
|
};
|
|
|
|
|
|
2015-03-19 17:58:08 +08:00
|
|
|
|
/** @} */
|
2015-06-15 10:28:37 +08:00
|
|
|
|
/** @} */
|
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
|
NS_AX_END
|
2013-09-09 10:29:02 +08:00
|
|
|
|
|
2022-07-15 19:17:01 +08:00
|
|
|
|
#endif // AX_USE_PHYSICS
|
2021-12-25 10:04:45 +08:00
|
|
|
|
#endif // __CCPHYSICS_BODY_H__
|