Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions cocos/physics/CCPhysicsBody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ PhysicsBody::PhysicsBody()
, _linearDamping(0.0f)
, _angularDamping(0.0f)
, _tag(0)
, _categoryBitmask(UINT_MAX)
, _collisionBitmask(UINT_MAX)
, _contactTestBitmask(0)
{
}

Expand Down Expand Up @@ -109,11 +112,6 @@ PhysicsBody* PhysicsBody::create()
return nullptr;
}

void update(float delta)
{

}

PhysicsBody* PhysicsBody::createCircle(float radius, PhysicsMaterial material)
{
PhysicsBody* body = new PhysicsBody();
Expand Down
2 changes: 1 addition & 1 deletion cocos/physics/CCPhysicsBody.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ class PhysicsBody : public Object//, public Clonable
int _tag;

int _categoryBitmask;
int _contactTestBitmask;
int _collisionBitmask;
int _contactTestBitmask;

friend class PhysicsWorld;
friend class PhysicsShape;
Expand Down
13 changes: 7 additions & 6 deletions cocos/physics/CCPhysicsContact.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class PhysicsContact
bool _notify;

friend class PhysicsWorld;
friend class PhysicsWorldCallback;
};

/*
Expand All @@ -94,7 +95,7 @@ class PhysicsContactPreSolve
static PhysicsContactPreSolve* create();
bool init();

friend class PhysicsWorld;
friend class PhysicsWorldCallback;
};

/*
Expand All @@ -109,7 +110,7 @@ class PhysicsContactPostSolve
static PhysicsContactPostSolve* create();
bool init();

friend class PhysicsWorld;
friend class PhysicsWorldCallback;
};

/*
Expand All @@ -125,20 +126,20 @@ class PhysicsContactListener
/*
* @brief it will called at two shapes start to contact, and only call it once.
*/
std::function<bool(const PhysicsContact& contact)> onContactBegin;
std::function<bool(PhysicsWorld& world, const PhysicsContact& contact)> onContactBegin;
/*
* @brief Two shapes are touching during this step. Return false from the callback to make world ignore the collision this step or true to process it normally. Additionally, you may override collision values, elasticity, or surface velocity values.
*/
std::function<bool(const PhysicsContact& contact, const PhysicsContactPreSolve& solve)> onContactPreSolve;
std::function<bool(PhysicsWorld& world, const PhysicsContact& contact, const PhysicsContactPreSolve& solve)> onContactPreSolve;
/*
* @brief Two shapes are touching and their collision response has been processed. You can retrieve the collision impulse or kinetic energy at this time if you want to use it to calculate sound volumes or damage amounts. See cpArbiter for more info
*/
std::function<void(const PhysicsContact& contact, const PhysicsContactPostSolve& solve)> onContactPostSolve;
std::function<void(PhysicsWorld& world, const PhysicsContact& contact, const PhysicsContactPostSolve& solve)> onContactPostSolve;
/*
* @brief it will called at two shapes separated, and only call it once.
* onContactBegin and onContactEnd will called in pairs.
*/
std::function<void(const PhysicsContact& contact)> onContactEnd;
std::function<void(PhysicsWorld& world, const PhysicsContact& contact)> onContactEnd;
};

NS_CC_END
Expand Down
18 changes: 9 additions & 9 deletions cocos/physics/CCPhysicsJoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ void PhysicsJoint::setEnable(bool enable)
}
}

//PhysicsJointPin::PhysicsJointPin()
//{
//
//}
//
//PhysicsJointPin::~PhysicsJointPin()
//{
//
//}
PhysicsJointPin::PhysicsJointPin()
{

}

PhysicsJointPin::~PhysicsJointPin()
{

}

PhysicsJointFixed::PhysicsJointFixed()
{
Expand Down
16 changes: 6 additions & 10 deletions cocos/physics/CCPhysicsShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,11 @@ typedef struct PhysicsMaterial
float restitution;
float friction;

PhysicsMaterial()
: density(0.0f)
, restitution(0.0f)
, friction(0.0f){}

PhysicsMaterial(float density, float restitution, float friction)
: density(density)
, restitution(restitution)
, friction(friction){}
static PhysicsMaterial make(float density, float restitution, float friction)
{
PhysicsMaterial var = {density, restitution, friction};
return var;
}
}PhysicsMaterial;

const PhysicsMaterial PHYSICSSHAPE_MATERIAL_DEFAULT = {0.0f, 1.0f, 1.0f};
Expand Down Expand Up @@ -97,7 +93,7 @@ class PhysicsShape : public Object
virtual Point getOffset() { return Point::ZERO; }
virtual Point getCenter() { return getOffset(); }

static Point* recenterPoints(Point* points, int count, Point center);
static Point* recenterPoints(Point* points, int count, Point center = Point::ZERO);
static Point getPolyonCenter(Point* points, int count);

protected:
Expand Down
Loading