mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
Bullet: contact added callback
This commit is contained in:
parent
a762ee42f4
commit
8d66921d79
@ -21,6 +21,7 @@
|
|||||||
bulletConeShape.h bulletConeShape.I \
|
bulletConeShape.h bulletConeShape.I \
|
||||||
bulletConeTwistConstraint.h bulletConeTwistConstraint.I \
|
bulletConeTwistConstraint.h bulletConeTwistConstraint.I \
|
||||||
bulletConstraint.h bulletConstraint.I \
|
bulletConstraint.h bulletConstraint.I \
|
||||||
|
bulletContactCallbackData.h bulletContactCallbackData.I \
|
||||||
bulletContactCallbacks.h \
|
bulletContactCallbacks.h \
|
||||||
bulletContactResult.h bulletContactResult.I \
|
bulletContactResult.h bulletContactResult.I \
|
||||||
bulletConvexHullShape.h bulletConvexHullShape.I \
|
bulletConvexHullShape.h bulletConvexHullShape.I \
|
||||||
@ -67,6 +68,7 @@
|
|||||||
bulletConeShape.cxx \
|
bulletConeShape.cxx \
|
||||||
bulletConeTwistConstraint.cxx \
|
bulletConeTwistConstraint.cxx \
|
||||||
bulletConstraint.cxx \
|
bulletConstraint.cxx \
|
||||||
|
bulletContactCallbackData.cxx \
|
||||||
bulletContactResult.cxx \
|
bulletContactResult.cxx \
|
||||||
bulletConvexHullShape.cxx \
|
bulletConvexHullShape.cxx \
|
||||||
bulletConvexPointCloudShape.cxx \
|
bulletConvexPointCloudShape.cxx \
|
||||||
@ -111,6 +113,7 @@
|
|||||||
bulletConeShape.h bulletConeShape.I \
|
bulletConeShape.h bulletConeShape.I \
|
||||||
bulletConeTwistConstraint.h bulletConeTwistConstraint.I \
|
bulletConeTwistConstraint.h bulletConeTwistConstraint.I \
|
||||||
bulletConstraint.h bulletConstraint.I \
|
bulletConstraint.h bulletConstraint.I \
|
||||||
|
bulletContactCallbackData.h bulletContactCallbackData.I \
|
||||||
bulletContactCallbacks.h \
|
bulletContactCallbacks.h \
|
||||||
bulletContactResult.h bulletContactResult.I \
|
bulletContactResult.h bulletContactResult.I \
|
||||||
bulletConvexHullShape.h bulletConvexHullShape.I \
|
bulletConvexHullShape.h bulletConvexHullShape.I \
|
||||||
|
60
panda/src/bullet/bulletContactCallbackData.I
Normal file
60
panda/src/bullet/bulletContactCallbackData.I
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
// Filename: bulletContactCallbackData.I
|
||||||
|
// Created by: enn0x (22Nov12)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the revised BSD
|
||||||
|
// license. You should have received a copy of this license along
|
||||||
|
// with this source code in a file named "LICENSE."
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: BulletContactCallbackData::Constructor
|
||||||
|
// Access: Published
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE BulletContactCallbackData::
|
||||||
|
BulletContactCallbackData(BulletManifoldPoint &mp, PandaNode *node0, PandaNode *node1) :
|
||||||
|
_node0(node0),
|
||||||
|
_node1(node1),
|
||||||
|
_mp(mp) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: BulletContactCallbackData::get_node_0
|
||||||
|
// Access: Published
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE PandaNode *BulletContactCallbackData::
|
||||||
|
get_node_0() const {
|
||||||
|
|
||||||
|
return _node0;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: BulletContactCallbackData::get_node_1
|
||||||
|
// Access: Published
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE PandaNode *BulletContactCallbackData::
|
||||||
|
get_node_1() const {
|
||||||
|
|
||||||
|
return _node1;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: BulletContactCallbackData::get_manifold
|
||||||
|
// Access: Published
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE BulletManifoldPoint &BulletContactCallbackData::
|
||||||
|
get_manifold() const {
|
||||||
|
|
||||||
|
return _mp;
|
||||||
|
}
|
||||||
|
|
31
panda/src/bullet/bulletContactCallbackData.cxx
Normal file
31
panda/src/bullet/bulletContactCallbackData.cxx
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Filename: bulletContactCallbackData.cxx
|
||||||
|
// Created by: enn0x (22Nov12)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the revised BSD
|
||||||
|
// license. You should have received a copy of this license along
|
||||||
|
// with this source code in a file named "LICENSE."
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "bulletContactCallbackData.h"
|
||||||
|
|
||||||
|
TypeHandle BulletContactCallbackData::_type_handle;
|
||||||
|
|
||||||
|
/*
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: BulletContactCallbackData::enable_feedback
|
||||||
|
// Access: Published
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void BulletContactCallbackData::
|
||||||
|
enable_feedback(bool value) {
|
||||||
|
|
||||||
|
ptr()->enableFeedback(value);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
70
panda/src/bullet/bulletContactCallbackData.h
Normal file
70
panda/src/bullet/bulletContactCallbackData.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
// Filename: bulletContactCallbackData.h
|
||||||
|
// Created by: enn0x (22Nov12)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the revised BSD
|
||||||
|
// license. You should have received a copy of this license along
|
||||||
|
// with this source code in a file named "LICENSE."
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef __BULLET_CONTACT_CALLBACK_DATA_H__
|
||||||
|
#define __BULLET_CONTACT_CALLBACK_DATA_H__
|
||||||
|
|
||||||
|
#include "pandabase.h"
|
||||||
|
#include "callbackData.h"
|
||||||
|
#include "callbackObject.h"
|
||||||
|
|
||||||
|
#include "bullet_includes.h"
|
||||||
|
#include "bullet_utils.h"
|
||||||
|
#include "bulletManifoldPoint.h"
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Class : BulletContactCallbackData
|
||||||
|
// Description :
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
class EXPCL_PANDABULLET BulletContactCallbackData : public CallbackData {
|
||||||
|
|
||||||
|
PUBLISHED:
|
||||||
|
INLINE BulletContactCallbackData(BulletManifoldPoint &mp,
|
||||||
|
PandaNode *node0,
|
||||||
|
PandaNode *node1);
|
||||||
|
|
||||||
|
PandaNode *get_node_0() const;
|
||||||
|
PandaNode *get_node_1() const;
|
||||||
|
BulletManifoldPoint &get_manifold() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
PandaNode *_node0;
|
||||||
|
PandaNode *_node1;
|
||||||
|
BulletManifoldPoint &_mp;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
public:
|
||||||
|
static TypeHandle get_class_type() {
|
||||||
|
return _type_handle;
|
||||||
|
}
|
||||||
|
static void init_type() {
|
||||||
|
CallbackData::init_type();
|
||||||
|
register_type(_type_handle, "BulletContactCallbackData",
|
||||||
|
CallbackData::get_class_type());
|
||||||
|
}
|
||||||
|
virtual TypeHandle get_type() const {
|
||||||
|
return get_class_type();
|
||||||
|
}
|
||||||
|
virtual TypeHandle force_init_type() {
|
||||||
|
init_type();
|
||||||
|
return get_class_type();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static TypeHandle _type_handle;
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "bulletContactCallbackData.I"
|
||||||
|
|
||||||
|
#endif // __BULLET_CONTACT_CALLBACK_DATA_H__
|
@ -18,7 +18,8 @@
|
|||||||
#include "pandabase.h"
|
#include "pandabase.h"
|
||||||
|
|
||||||
#include "bullet_includes.h"
|
#include "bullet_includes.h"
|
||||||
|
#include "bulletWorld.h"
|
||||||
|
#include "bulletContactCallbackData.h"
|
||||||
#include "config_bullet.h" // required for: bullet_cat.debug()
|
#include "config_bullet.h" // required for: bullet_cat.debug()
|
||||||
|
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
@ -67,6 +68,15 @@ contact_added_callback(btManifoldPoint &cp,
|
|||||||
|
|
||||||
EventQueue::get_global_event_queue()->queue_event(event);
|
EventQueue::get_global_event_queue()->queue_event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Callback
|
||||||
|
if (bullet_contact_added_callback) {
|
||||||
|
|
||||||
|
BulletManifoldPoint mp(cp);
|
||||||
|
BulletContactCallbackData cbdata(mp, node0, node1);
|
||||||
|
|
||||||
|
bullet_contact_added_callback->do_callback(&cbdata);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -83,7 +93,7 @@ contact_processed_callback(btManifoldPoint &cp,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
btCollisionObject *obj0 = (btCollisionObject *)body0;
|
btCollisionObject *obj0 = (btCollisionObject *)body0;
|
||||||
btCollisionObject *colobj1Obj1 = (btCollisionObject *)body1;
|
btCollisionObject *obj1 = (btCollisionObject *)body1;
|
||||||
|
|
||||||
int flags0 = obj0->getCollisionFlags();
|
int flags0 = obj0->getCollisionFlags();
|
||||||
int flags1 = obj1->getCollisionFlags();
|
int flags1 = obj1->getCollisionFlags();
|
||||||
|
@ -43,7 +43,8 @@ get_node1() const {
|
|||||||
INLINE const BulletManifoldPoint *BulletContact::
|
INLINE const BulletManifoldPoint *BulletContact::
|
||||||
get_manifold_point() const {
|
get_manifold_point() const {
|
||||||
|
|
||||||
return new BulletManifoldPoint(_mp);
|
btManifoldPoint &mp = const_cast<btManifoldPoint &>(_mp);
|
||||||
|
return new BulletManifoldPoint(mp);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -22,18 +22,6 @@ INLINE BulletManifoldPoint::
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: BulletManifoldPoint::is_const
|
|
||||||
// Access: Published
|
|
||||||
// Description: Returns TRUE if this instance of BulletManifoldPoint
|
|
||||||
// can not be modified.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE bool BulletManifoldPoint::
|
|
||||||
is_const() const {
|
|
||||||
|
|
||||||
return _const;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: BulletManifoldPoint::set_lateral_friction_initialized
|
// Function: BulletManifoldPoint::set_lateral_friction_initialized
|
||||||
// Access: Published
|
// Access: Published
|
||||||
@ -42,7 +30,6 @@ is_const() const {
|
|||||||
INLINE void BulletManifoldPoint::
|
INLINE void BulletManifoldPoint::
|
||||||
set_lateral_friction_initialized(bool value) {
|
set_lateral_friction_initialized(bool value) {
|
||||||
|
|
||||||
nassertv(!_const);
|
|
||||||
_pt.m_lateralFrictionInitialized = value;
|
_pt.m_lateralFrictionInitialized = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +52,6 @@ get_lateral_friction_initialized() const {
|
|||||||
INLINE void BulletManifoldPoint::
|
INLINE void BulletManifoldPoint::
|
||||||
set_lateral_friction_dir1(const LVecBase3 &dir) {
|
set_lateral_friction_dir1(const LVecBase3 &dir) {
|
||||||
|
|
||||||
nassertv(!_const);
|
|
||||||
_pt.m_lateralFrictionDir1 = LVecBase3_to_btVector3(dir);
|
_pt.m_lateralFrictionDir1 = LVecBase3_to_btVector3(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +74,6 @@ get_lateral_friction_dir1() const {
|
|||||||
INLINE void BulletManifoldPoint::
|
INLINE void BulletManifoldPoint::
|
||||||
set_lateral_friction_dir2(const LVecBase3 &dir) {
|
set_lateral_friction_dir2(const LVecBase3 &dir) {
|
||||||
|
|
||||||
nassertv(!_const);
|
|
||||||
_pt.m_lateralFrictionDir2 = LVecBase3_to_btVector3(dir);
|
_pt.m_lateralFrictionDir2 = LVecBase3_to_btVector3(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +96,6 @@ get_lateral_friction_dir2() const {
|
|||||||
INLINE void BulletManifoldPoint::
|
INLINE void BulletManifoldPoint::
|
||||||
set_contact_motion1(PN_stdfloat value) {
|
set_contact_motion1(PN_stdfloat value) {
|
||||||
|
|
||||||
nassertv(!_const);
|
|
||||||
_pt.m_contactMotion1 = (btScalar)value;
|
_pt.m_contactMotion1 = (btScalar)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +118,6 @@ get_contact_motion1() const {
|
|||||||
INLINE void BulletManifoldPoint::
|
INLINE void BulletManifoldPoint::
|
||||||
set_contact_motion2(PN_stdfloat value) {
|
set_contact_motion2(PN_stdfloat value) {
|
||||||
|
|
||||||
nassertv(!_const);
|
|
||||||
_pt.m_contactMotion2 = (btScalar)value;
|
_pt.m_contactMotion2 = (btScalar)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +140,6 @@ get_contact_motion2() const {
|
|||||||
INLINE void BulletManifoldPoint::
|
INLINE void BulletManifoldPoint::
|
||||||
set_combined_friction(PN_stdfloat value) {
|
set_combined_friction(PN_stdfloat value) {
|
||||||
|
|
||||||
nassertv(!_const);
|
|
||||||
_pt.m_combinedFriction = (btScalar)value;
|
_pt.m_combinedFriction = (btScalar)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +162,6 @@ get_combined_friction() const {
|
|||||||
INLINE void BulletManifoldPoint::
|
INLINE void BulletManifoldPoint::
|
||||||
set_combined_restitution(PN_stdfloat value) {
|
set_combined_restitution(PN_stdfloat value) {
|
||||||
|
|
||||||
nassertv(!_const);
|
|
||||||
_pt.m_combinedRestitution = (btScalar)value;
|
_pt.m_combinedRestitution = (btScalar)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +184,6 @@ get_combined_restitution() const {
|
|||||||
INLINE void BulletManifoldPoint::
|
INLINE void BulletManifoldPoint::
|
||||||
set_applied_impulse(PN_stdfloat value) {
|
set_applied_impulse(PN_stdfloat value) {
|
||||||
|
|
||||||
nassertv(!_const);
|
|
||||||
_pt.m_appliedImpulse = (btScalar)value;
|
_pt.m_appliedImpulse = (btScalar)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +195,6 @@ set_applied_impulse(PN_stdfloat value) {
|
|||||||
INLINE void BulletManifoldPoint::
|
INLINE void BulletManifoldPoint::
|
||||||
set_applied_impulse_lateral1(PN_stdfloat value) {
|
set_applied_impulse_lateral1(PN_stdfloat value) {
|
||||||
|
|
||||||
nassertv(!_const);
|
|
||||||
_pt.m_appliedImpulseLateral1 = (btScalar)value;
|
_pt.m_appliedImpulseLateral1 = (btScalar)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +217,6 @@ get_applied_impulse_lateral1() const {
|
|||||||
INLINE void BulletManifoldPoint::
|
INLINE void BulletManifoldPoint::
|
||||||
set_applied_impulse_lateral2(PN_stdfloat value) {
|
set_applied_impulse_lateral2(PN_stdfloat value) {
|
||||||
|
|
||||||
nassertv(!_const);
|
|
||||||
_pt.m_appliedImpulseLateral2 = (btScalar)value;
|
_pt.m_appliedImpulseLateral2 = (btScalar)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,7 +239,6 @@ get_applied_impulse_lateral2() const {
|
|||||||
INLINE void BulletManifoldPoint::
|
INLINE void BulletManifoldPoint::
|
||||||
set_contact_cfm1(PN_stdfloat value) {
|
set_contact_cfm1(PN_stdfloat value) {
|
||||||
|
|
||||||
nassertv(!_const);
|
|
||||||
_pt.m_contactCFM1 = (btScalar)value;
|
_pt.m_contactCFM1 = (btScalar)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,7 +261,6 @@ get_contact_cfm1() const {
|
|||||||
INLINE void BulletManifoldPoint::
|
INLINE void BulletManifoldPoint::
|
||||||
set_contact_cfm2(PN_stdfloat value) {
|
set_contact_cfm2(PN_stdfloat value) {
|
||||||
|
|
||||||
nassertv(!_const);
|
|
||||||
_pt.m_contactCFM2 = (btScalar)value;
|
_pt.m_contactCFM2 = (btScalar)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,22 +21,10 @@
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
BulletManifoldPoint::
|
BulletManifoldPoint::
|
||||||
BulletManifoldPoint(btManifoldPoint &pt)
|
BulletManifoldPoint(btManifoldPoint &pt)
|
||||||
: _pt(pt), _const(false) {
|
: _pt(pt) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: BulletManifoldPoint::Constructor
|
|
||||||
// Access: Public
|
|
||||||
// Description:
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
BulletManifoldPoint::
|
|
||||||
BulletManifoldPoint(const btManifoldPoint &pt) {
|
|
||||||
|
|
||||||
_pt = (btManifoldPoint &)pt;
|
|
||||||
_const = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: BulletManifoldPoint::get_lift_time
|
// Function: BulletManifoldPoint::get_lift_time
|
||||||
// Access: Published
|
// Access: Published
|
||||||
|
@ -45,8 +45,6 @@ PUBLISHED:
|
|||||||
int get_index0() const;
|
int get_index0() const;
|
||||||
int get_index1() const;
|
int get_index1() const;
|
||||||
|
|
||||||
INLINE bool is_const() const;
|
|
||||||
|
|
||||||
INLINE void set_lateral_friction_initialized(bool value);
|
INLINE void set_lateral_friction_initialized(bool value);
|
||||||
INLINE void set_lateral_friction_dir1(const LVecBase3 &dir);
|
INLINE void set_lateral_friction_dir1(const LVecBase3 &dir);
|
||||||
INLINE void set_lateral_friction_dir2(const LVecBase3 &dir);
|
INLINE void set_lateral_friction_dir2(const LVecBase3 &dir);
|
||||||
@ -73,12 +71,10 @@ PUBLISHED:
|
|||||||
INLINE PN_stdfloat get_contact_cfm2() const;
|
INLINE PN_stdfloat get_contact_cfm2() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BulletManifoldPoint(const btManifoldPoint &pt);
|
|
||||||
BulletManifoldPoint(btManifoldPoint &pt);
|
BulletManifoldPoint(btManifoldPoint &pt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
btManifoldPoint _pt;
|
btManifoldPoint &_pt;
|
||||||
bool _const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "bulletManifoldPoint.I"
|
#include "bulletManifoldPoint.I"
|
||||||
|
@ -37,6 +37,8 @@ PStatCollector BulletWorld::_pstat_debug("App:Bullet:DoPhysics:Debug");
|
|||||||
PStatCollector BulletWorld::_pstat_p2b("App:Bullet:DoPhysics:SyncP2B");
|
PStatCollector BulletWorld::_pstat_p2b("App:Bullet:DoPhysics:SyncP2B");
|
||||||
PStatCollector BulletWorld::_pstat_b2p("App:Bullet:DoPhysics:SyncB2P");
|
PStatCollector BulletWorld::_pstat_b2p("App:Bullet:DoPhysics:SyncB2P");
|
||||||
|
|
||||||
|
PT(CallbackObject) bullet_contact_added_callback;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: BulletWorld::Constructor
|
// Function: BulletWorld::Constructor
|
||||||
// Access: Published
|
// Access: Published
|
||||||
@ -867,6 +869,36 @@ get_group_collision_flag(unsigned int group1, unsigned int group2) const {
|
|||||||
return _filter_cb2._collide[group1].get_bit(group2);
|
return _filter_cb2._collide[group1].get_bit(group2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: BulletWorld::set_contact_added_callback
|
||||||
|
// Access: Published
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void BulletWorld::
|
||||||
|
set_contact_added_callback(CallbackObject *obj) {
|
||||||
|
|
||||||
|
_world->getSolverInfo().m_solverMode |= SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION;
|
||||||
|
_world->getSolverInfo().m_solverMode |= SOLVER_USE_2_FRICTION_DIRECTIONS;
|
||||||
|
_world->getSolverInfo().m_solverMode |= SOLVER_ENABLE_FRICTION_DIRECTION_CACHING;
|
||||||
|
|
||||||
|
bullet_contact_added_callback = obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: BulletWorld::clear_contact_added_callback
|
||||||
|
// Access: Published
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void BulletWorld::
|
||||||
|
clear_contact_added_callback() {
|
||||||
|
|
||||||
|
_world->getSolverInfo().m_solverMode &= ~SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION;
|
||||||
|
_world->getSolverInfo().m_solverMode &= ~SOLVER_USE_2_FRICTION_DIRECTIONS;
|
||||||
|
_world->getSolverInfo().m_solverMode &= ~SOLVER_ENABLE_FRICTION_DIRECTION_CACHING;
|
||||||
|
|
||||||
|
bullet_contact_added_callback = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_PYTHON
|
#ifdef HAVE_PYTHON
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: BulletWorld::set_python_filter_callback
|
// Function: BulletWorld::set_python_filter_callback
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include "typedReferenceCount.h"
|
#include "typedReferenceCount.h"
|
||||||
#include "transformState.h"
|
#include "transformState.h"
|
||||||
#include "pandaNode.h"
|
#include "pandaNode.h"
|
||||||
|
#include "callbackObject.h"
|
||||||
#include "collideMask.h"
|
#include "collideMask.h"
|
||||||
#include "luse.h"
|
#include "luse.h"
|
||||||
|
|
||||||
@ -47,6 +48,8 @@ class BulletPersistentManifold;
|
|||||||
class BulletShape;
|
class BulletShape;
|
||||||
class BulletSoftBodyWorldInfo;
|
class BulletSoftBodyWorldInfo;
|
||||||
|
|
||||||
|
extern PT(CallbackObject) bullet_contact_added_callback;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Class : BulletWorld
|
// Class : BulletWorld
|
||||||
// Description :
|
// Description :
|
||||||
@ -135,6 +138,10 @@ PUBLISHED:
|
|||||||
void set_group_collision_flag(unsigned int group1, unsigned int group2, bool enable);
|
void set_group_collision_flag(unsigned int group1, unsigned int group2, bool enable);
|
||||||
bool get_group_collision_flag(unsigned int group1, unsigned int group2) const;
|
bool get_group_collision_flag(unsigned int group1, unsigned int group2) const;
|
||||||
|
|
||||||
|
// Callbacks
|
||||||
|
void set_contact_added_callback(CallbackObject *obj);
|
||||||
|
void clear_contact_added_callback();
|
||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
enum BroadphaseAlgorithm {
|
enum BroadphaseAlgorithm {
|
||||||
BA_sweep_and_prune,
|
BA_sweep_and_prune,
|
||||||
|
@ -55,6 +55,7 @@ enum BulletUpAxis {
|
|||||||
};
|
};
|
||||||
|
|
||||||
EXPCL_PANDABULLET BulletUpAxis get_default_up_axis();
|
EXPCL_PANDABULLET BulletUpAxis get_default_up_axis();
|
||||||
|
|
||||||
END_PUBLISH
|
END_PUBLISH
|
||||||
|
|
||||||
#include "bullet_utils.I"
|
#include "bullet_utils.I"
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "bulletCharacterControllerNode.h"
|
#include "bulletCharacterControllerNode.h"
|
||||||
#include "bulletConeShape.h"
|
#include "bulletConeShape.h"
|
||||||
#include "bulletConeTwistConstraint.h"
|
#include "bulletConeTwistConstraint.h"
|
||||||
|
#include "bulletContactCallbackData.h"
|
||||||
#include "bulletConstraint.h"
|
#include "bulletConstraint.h"
|
||||||
#include "bulletConvexHullShape.h"
|
#include "bulletConvexHullShape.h"
|
||||||
#include "bulletConvexPointCloudShape.h"
|
#include "bulletConvexPointCloudShape.h"
|
||||||
@ -144,7 +145,6 @@ init_libbullet() {
|
|||||||
initialized = true;
|
initialized = true;
|
||||||
|
|
||||||
// Initialize types
|
// Initialize types
|
||||||
//
|
|
||||||
BulletBaseCharacterControllerNode::init_type();
|
BulletBaseCharacterControllerNode::init_type();
|
||||||
BulletBodyNode::init_type();
|
BulletBodyNode::init_type();
|
||||||
BulletBoxShape::init_type();
|
BulletBoxShape::init_type();
|
||||||
@ -152,6 +152,7 @@ init_libbullet() {
|
|||||||
BulletCharacterControllerNode::init_type();
|
BulletCharacterControllerNode::init_type();
|
||||||
BulletConeShape::init_type();
|
BulletConeShape::init_type();
|
||||||
BulletConeTwistConstraint::init_type();
|
BulletConeTwistConstraint::init_type();
|
||||||
|
BulletContactCallbackData::init_type();
|
||||||
BulletConstraint::init_type();
|
BulletConstraint::init_type();
|
||||||
BulletConvexHullShape::init_type();
|
BulletConvexHullShape::init_type();
|
||||||
BulletConvexPointCloudShape::init_type();
|
BulletConvexPointCloudShape::init_type();
|
||||||
@ -176,18 +177,15 @@ init_libbullet() {
|
|||||||
BulletWorld::init_type();
|
BulletWorld::init_type();
|
||||||
|
|
||||||
// Custom contact callbacks
|
// Custom contact callbacks
|
||||||
//
|
|
||||||
gContactAddedCallback = contact_added_callback;
|
gContactAddedCallback = contact_added_callback;
|
||||||
gContactProcessedCallback = contact_processed_callback;
|
gContactProcessedCallback = contact_processed_callback;
|
||||||
gContactDestroyedCallback = contact_destroyed_callback;
|
gContactDestroyedCallback = contact_destroyed_callback;
|
||||||
|
|
||||||
// Initialize notification category
|
// Initialize notification category
|
||||||
//
|
|
||||||
bullet_cat.init();
|
bullet_cat.init();
|
||||||
bullet_cat.debug() << "initialize module" << endl;
|
bullet_cat.debug() << "initialize module" << endl;
|
||||||
|
|
||||||
// Register the Bullet system
|
// Register the Bullet system
|
||||||
//
|
|
||||||
PandaSystem *ps = PandaSystem::get_global_ptr();
|
PandaSystem *ps = PandaSystem::get_global_ptr();
|
||||||
ps->add_system("Bullet");
|
ps->add_system("Bullet");
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "bulletConeShape.cxx"
|
#include "bulletConeShape.cxx"
|
||||||
#include "bulletConeTwistConstraint.cxx"
|
#include "bulletConeTwistConstraint.cxx"
|
||||||
#include "bulletConstraint.cxx"
|
#include "bulletConstraint.cxx"
|
||||||
|
#include "bulletContactCallbackData.cxx"
|
||||||
#include "bulletContactResult.cxx"
|
#include "bulletContactResult.cxx"
|
||||||
#include "bulletConvexHullShape.cxx"
|
#include "bulletConvexHullShape.cxx"
|
||||||
#include "bulletConvexPointCloudShape.cxx"
|
#include "bulletConvexPointCloudShape.cxx"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user