Merge branch 'master' into cmake

This commit is contained in:
Sam Edwards 2018-02-23 17:49:32 -07:00
commit dfed8d2100
148 changed files with 4035 additions and 3536 deletions

View File

@ -514,15 +514,9 @@ receive_update_broadcast_required_owner(PyObject *distobj,
for (int i = 0; i < num_fields && !PyErr_Occurred(); ++i) {
DCField *field = get_inherited_field(i);
if (field->as_molecular_field() == (DCMolecularField *)NULL &&
field->is_required()) {
field->is_required() && (field->is_ownrecv() || field->is_broadcast())) {
packer.begin_unpack(field);
if (field->is_ownrecv()) {
field->receive_update(packer, distobj);
} else {
// It's not an ownrecv field; skip over it. It's difficult to filter
// this on the server, ask Roger for the reason.
packer.unpack_skip();
}
field->receive_update(packer, distobj);
if (!packer.end_unpack()) {
break;
}
@ -946,19 +940,17 @@ ai_format_generate(PyObject *distobj, DOID_TYPE do_id,
bool has_optional_fields = (PyObject_IsTrue(optional_fields) != 0);
if (has_optional_fields) {
packer.raw_pack_uint16(STATESERVER_OBJECT_GENERATE_WITH_REQUIRED_OTHER);
packer.raw_pack_uint16(STATESERVER_CREATE_OBJECT_WITH_REQUIRED_OTHER);
} else {
packer.raw_pack_uint16(STATESERVER_OBJECT_GENERATE_WITH_REQUIRED);
packer.raw_pack_uint16(STATESERVER_CREATE_OBJECT_WITH_REQUIRED);
}
packer.raw_pack_uint32(do_id);
// Parent is a bit overloaded; this parent is not about inheritance, this
// one is about the visibility container parent, i.e. the zone parent:
if (parent_id) {
packer.raw_pack_uint32(parent_id);
}
packer.raw_pack_uint32(parent_id);
packer.raw_pack_uint32(zone_id);
packer.raw_pack_uint16(_number);
packer.raw_pack_uint32(do_id);
// Specify all of the required fields.
int num_fields = get_num_inherited_fields();
@ -1009,77 +1001,6 @@ ai_format_generate(PyObject *distobj, DOID_TYPE do_id,
return Datagram(packer.get_data(), packer.get_length());
}
#endif // HAVE_PYTHON
#ifdef HAVE_PYTHON
/**
* Generates a datagram containing the message necessary to create a new
* database distributed object from the AI.
*
* First Pass is to only include required values (with Defaults).
*/
Datagram DCClass::
ai_database_generate_context(
unsigned int context_id, DOID_TYPE parent_id, ZONEID_TYPE zone_id,
CHANNEL_TYPE owner_channel,
CHANNEL_TYPE database_server_id, CHANNEL_TYPE from_channel_id) const
{
DCPacker packer;
packer.raw_pack_uint8(1);
packer.RAW_PACK_CHANNEL(database_server_id);
packer.RAW_PACK_CHANNEL(from_channel_id);
// packer.raw_pack_uint8('A');
packer.raw_pack_uint16(STATESERVER_OBJECT_CREATE_WITH_REQUIRED_CONTEXT);
packer.raw_pack_uint32(parent_id);
packer.raw_pack_uint32(zone_id);
packer.RAW_PACK_CHANNEL(owner_channel);
packer.raw_pack_uint16(_number); // DCD class ID
packer.raw_pack_uint32(context_id);
// Specify all of the required fields.
int num_fields = get_num_inherited_fields();
for (int i = 0; i < num_fields; ++i) {
DCField *field = get_inherited_field(i);
if (field->is_required() && field->as_molecular_field() == NULL) {
packer.begin_pack(field);
packer.pack_default_value();
packer.end_pack();
}
}
return Datagram(packer.get_data(), packer.get_length());
}
#endif // HAVE_PYTHON
#ifdef HAVE_PYTHON
Datagram DCClass::
ai_database_generate_context_old(
unsigned int context_id, DOID_TYPE parent_id, ZONEID_TYPE zone_id,
CHANNEL_TYPE database_server_id, CHANNEL_TYPE from_channel_id) const
{
DCPacker packer;
packer.raw_pack_uint8(1);
packer.RAW_PACK_CHANNEL(database_server_id);
packer.RAW_PACK_CHANNEL(from_channel_id);
// packer.raw_pack_uint8('A');
packer.raw_pack_uint16(STATESERVER_OBJECT_CREATE_WITH_REQUIRED_CONTEXT);
packer.raw_pack_uint32(parent_id);
packer.raw_pack_uint32(zone_id);
packer.raw_pack_uint16(_number); // DCD class ID
packer.raw_pack_uint32(context_id);
// Specify all of the required fields.
int num_fields = get_num_inherited_fields();
for (int i = 0; i < num_fields; ++i) {
DCField *field = get_inherited_field(i);
if (field->is_required() && field->as_molecular_field() == NULL) {
packer.begin_pack(field);
packer.pack_default_value();
packer.end_pack();
}
}
return Datagram(packer.get_data(), packer.get_length());
}
#endif // HAVE_PYTHON
/**
* Write a string representation of this instance to <out>.

View File

@ -117,11 +117,6 @@ PUBLISHED:
Datagram client_format_generate_CMU(PyObject *distobj, DOID_TYPE do_id,
ZONEID_TYPE zone_id, PyObject *optional_fields) const;
Datagram ai_database_generate_context(unsigned int context_id, DOID_TYPE parent_id, ZONEID_TYPE zone_id, CHANNEL_TYPE owner_channel,
CHANNEL_TYPE database_server_id, CHANNEL_TYPE from_channel_id) const;
Datagram ai_database_generate_context_old(unsigned int context_id, DOID_TYPE parent_id, ZONEID_TYPE zone_id,
CHANNEL_TYPE database_server_id, CHANNEL_TYPE from_channel_id) const;
#endif
public:

View File

@ -391,7 +391,7 @@ Datagram DCField::
client_format_update(DOID_TYPE do_id, PyObject *args) const {
DCPacker packer;
packer.raw_pack_uint16(CLIENT_OBJECT_UPDATE_FIELD);
packer.raw_pack_uint16(CLIENT_OBJECT_SET_FIELD);
packer.raw_pack_uint32(do_id);
packer.raw_pack_uint16(_number);
@ -417,7 +417,7 @@ ai_format_update(DOID_TYPE do_id, CHANNEL_TYPE to_id, CHANNEL_TYPE from_id, PyOb
packer.raw_pack_uint8(1);
packer.RAW_PACK_CHANNEL(to_id);
packer.RAW_PACK_CHANNEL(from_id);
packer.raw_pack_uint16(STATESERVER_OBJECT_UPDATE_FIELD);
packer.raw_pack_uint16(STATESERVER_OBJECT_SET_FIELD);
packer.raw_pack_uint32(do_id);
packer.raw_pack_uint16(_number);

View File

@ -17,16 +17,13 @@
// This file defines the server message types used within this module. It
// duplicates some symbols defined in MsgTypes.py and AIMsgTypes.py.
#define CLIENT_OBJECT_UPDATE_FIELD 24
#define CLIENT_CREATE_OBJECT_REQUIRED 34
#define CLIENT_CREATE_OBJECT_REQUIRED_OTHER 35
#define CLIENT_OBJECT_SET_FIELD 120
#define CLIENT_ENTER_OBJECT_REQUIRED 142
#define CLIENT_ENTER_OBJECT_REQUIRED_OTHER 143
#define STATESERVER_OBJECT_GENERATE_WITH_REQUIRED 2001
#define STATESERVER_OBJECT_GENERATE_WITH_REQUIRED_OTHER 2003
#define STATESERVER_OBJECT_UPDATE_FIELD 2004
#define STATESERVER_OBJECT_CREATE_WITH_REQUIRED_CONTEXT 2050
#define STATESERVER_OBJECT_CREATE_WITH_REQUIR_OTHER_CONTEXT 2051
#define STATESERVER_BOUNCE_MESSAGE 2086
#define STATESERVER_CREATE_OBJECT_WITH_REQUIRED 2000
#define STATESERVER_CREATE_OBJECT_WITH_REQUIRED_OTHER 2001
#define STATESERVER_OBJECT_SET_FIELD 2020
#define CLIENT_OBJECT_GENERATE_CMU 9002

View File

@ -623,8 +623,8 @@ class SelectionRay(SelectionQueue):
def pickBitMask(self, bitMask = BitMask32.allOff(),
targetNodePath = None,
skipFlags = SKIP_ALL):
if parentNodePath is None:
parentNodePath = render
if targetNodePath is None:
targetNodePath = render
self.collideWithBitMask(bitMask)
self.pick(targetNodePath)
# Determine collision entry

View File

@ -2,6 +2,8 @@ from direct.distributed.CachedDOData import CachedDOData
from panda3d.core import ConfigVariableInt
__all__ = ["CRDataCache"]
class CRDataCache:
# Stores cached data for DistributedObjects between instantiations on the client

View File

@ -175,7 +175,7 @@ class ClientRepositoryBase(ConnectionRepository):
"generate" messages when they are replayed().
"""
if msgType == CLIENT_CREATE_OBJECT_REQUIRED_OTHER:
if msgType == CLIENT_ENTER_OBJECT_REQUIRED_OTHER:
# It's a generate message.
doId = extra
if doId in self.deferredDoIds:
@ -263,7 +263,7 @@ class ClientRepositoryBase(ConnectionRepository):
distObj.setLocation(parentId, zoneId)
distObj.updateRequiredFields(dclass, di)
# updateRequiredFields calls announceGenerate
print("New DO:%s, dclass:%s"%(doId, dclass.getName()))
self.notify.debug("New DO:%s, dclass:%s" % (doId, dclass.getName()))
return distObj
def generateWithRequiredOtherFields(self, dclass, doId, di,
@ -381,7 +381,7 @@ class ClientRepositoryBase(ConnectionRepository):
# The object had been deferred. Great; we don't even have
# to generate it now.
del self.deferredDoIds[doId]
i = self.deferredGenerates.index((CLIENT_CREATE_OBJECT_REQUIRED_OTHER, doId))
i = self.deferredGenerates.index((CLIENT_ENTER_OBJECT_REQUIRED_OTHER, doId))
del self.deferredGenerates[i]
if len(self.deferredGenerates) == 0:
taskMgr.remove('deferredGenerate')

View File

@ -10,6 +10,7 @@ from .PyDatagramIterator import PyDatagramIterator
import types
import gc
__all__ = ["ConnectionRepository", "GCTrigger"]
class ConnectionRepository(
DoInterestManager, DoCollectionManager, CConnectionRepository):

View File

@ -15,6 +15,8 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath):
self.DistributedNode_initialized = 1
self.gotStringParentToken = 0
DistributedObject.DistributedObject.__init__(self, cr)
if not self.this:
NodePath.__init__(self, "DistributedNode")
# initialize gridParent
self.gridParent = None

View File

@ -1,4 +1,3 @@
#from otp.ai.AIBaseGlobal import *
from .DistributedObjectUD import DistributedObjectUD
class DistributedNodeUD(DistributedObjectUD):

View File

@ -146,8 +146,6 @@ class DistributedObjectAI(DistributedObjectBase):
barrier.cleanup()
self.__barriers = {}
self.air.stopTrackRequestDeletedDO(self)
# DCR: I've re-enabled this block of code so that Toontown's
# AI won't leak channels.
# Let me know if it causes trouble.
@ -155,10 +153,9 @@ class DistributedObjectAI(DistributedObjectBase):
### block until a solution is thought out of how to prevent
### this delete message or to handle this message better
# TODO: do we still need this check?
if not hasattr(self, "doNotDeallocateChannel"):
if self.air and not hasattr(self.air, "doNotDeallocateChannel"):
if self.air.minChannel <= self.doId <= self.air.maxChannel:
self.air.deallocateChannel(self.doId)
if not getattr(self, "doNotDeallocateChannel", False):
if self.air:
self.air.deallocateChannel(self.doId)
self.air = None
self.parentId = None
@ -200,9 +197,6 @@ class DistributedObjectAI(DistributedObjectBase):
"""
pass
def addInterest(self, zoneId, note="", event=None):
self.air.addInterest(self.doId, zoneId, note, event)
def b_setLocation(self, parentId, zoneId):
self.d_setLocation(parentId, zoneId)
self.setLocation(parentId, zoneId)
@ -274,9 +268,6 @@ class DistributedObjectAI(DistributedObjectBase):
dclass.receiveUpdateOther(self, di)
def sendSetZone(self, zoneId):
self.air.sendSetZone(self, zoneId)
def startMessageBundle(self, name):
self.air.startMessageBundle(name)
def sendMessageBundle(self):
@ -349,10 +340,10 @@ class DistributedObjectAI(DistributedObjectBase):
self.air.sendUpdate(self, fieldName, args)
def GetPuppetConnectionChannel(self, doId):
return doId + (1 << 32)
return doId + (1001L << 32)
def GetAccountConnectionChannel(self, doId):
return doId + (3 << 32)
return doId + (1003L << 32)
def GetAccountIDFromChannelCode(self, channel):
return channel >> 32
@ -482,7 +473,6 @@ class DistributedObjectAI(DistributedObjectBase):
(self.__class__, doId))
return
self.air.requestDelete(self)
self.air.startTrackRequestDeletedDO(self)
self._DOAI_requestedDelete = True
def taskName(self, taskString):
@ -581,3 +571,5 @@ class DistributedObjectAI(DistributedObjectBase):
""" This is a no-op on the AI. """
pass
def setAI(self, aiChannel):
self.air.setAI(self.doId, aiChannel)

View File

@ -1,4 +1,3 @@
from direct.showbase.DirectObject import DirectObject
from direct.directnotify.DirectNotifyGlobal import directNotify
@ -93,3 +92,11 @@ class DistributedObjectBase(DirectObject):
def hasParentingRules(self):
return self.dclass.getFieldByName('setParentingRules') != None
def delete(self):
"""
Override this to handle cleanup right before this object
gets deleted.
"""
pass

View File

@ -270,10 +270,10 @@ class DistributedObjectUD(DistributedObjectBase):
self.air.sendUpdate(self, fieldName, args)
def GetPuppetConnectionChannel(self, doId):
return doId + (1 << 32)
return doId + (1001L << 32)
def GetAccountConnectionChannel(self, doId):
return doId + (3 << 32)
return doId + (1003L << 32)
def GetAccountIDFromChannelCode(self, channel):
return channel >> 32

View File

@ -111,7 +111,7 @@ class DoInterestManager(DirectObject.DirectObject):
self._allInterestsCompleteCallbacks = []
def __verbose(self):
return self.InterestDebug or self.getVerbose()
return self.InterestDebug.getValue() or self.getVerbose()
def _getAnonymousEvent(self, desc):
return 'anonymous-%s-%s' % (desc, DoInterestManager._SerialGen.next())
@ -504,18 +504,23 @@ class DoInterestManager(DirectObject.DirectObject):
'trying to set interest to invalid parent: %s' % parentId)
datagram = PyDatagram()
# Add message type
datagram.addUint16(CLIENT_ADD_INTEREST)
datagram.addUint16(handle)
datagram.addUint32(contextId)
datagram.addUint32(parentId)
if isinstance(zoneIdList, list):
vzl = list(zoneIdList)
vzl.sort()
uniqueElements(vzl)
datagram.addUint16(CLIENT_ADD_INTEREST_MULTIPLE)
datagram.addUint32(contextId)
datagram.addUint16(handle)
datagram.addUint32(parentId)
datagram.addUint16(len(vzl))
for zone in vzl:
datagram.addUint32(zone)
else:
datagram.addUint32(zoneIdList)
datagram.addUint16(CLIENT_ADD_INTEREST)
datagram.addUint32(contextId)
datagram.addUint16(handle)
datagram.addUint32(parentId)
datagram.addUint32(zoneIdList)
self.send(datagram)
def _sendRemoveInterest(self, handle, contextId):
@ -530,9 +535,8 @@ class DoInterestManager(DirectObject.DirectObject):
datagram = PyDatagram()
# Add message type
datagram.addUint16(CLIENT_REMOVE_INTEREST)
datagram.addUint32(contextId)
datagram.addUint16(handle)
if contextId != 0:
datagram.addUint32(contextId)
self.send(datagram)
if __debug__:
state = DoInterestManager._interests[handle]
@ -583,8 +587,8 @@ class DoInterestManager(DirectObject.DirectObject):
This handles the interest done messages and may dispatch an event
"""
assert DoInterestManager.notify.debugCall()
handle = di.getUint16()
contextId = di.getUint32()
handle = di.getUint16()
if self.__verbose():
print('CR::INTEREST.interestDone(handle=%s)' % handle)
DoInterestManager.notify.debug(

View File

@ -3,104 +3,140 @@
from direct.showbase.PythonUtil import invertDictLossless
MsgName2Id = {
# 2 new params: passwd, char bool 0/1 1 = new account
# 2 new return values: 129 = not found, 12 = bad passwd,
'CLIENT_LOGIN': 1,
'CLIENT_LOGIN_RESP': 2,
'CLIENT_GET_AVATARS': 3,
'CLIENT_HELLO': 1,
'CLIENT_HELLO_RESP': 2,
# Sent by the client when it's leaving.
'CLIENT_DISCONNECT': 3,
# Sent by the server when it is dropping the connection deliberately.
'CLIENT_GO_GET_LOST': 4,
'CLIENT_GET_AVATARS_RESP': 5,
'CLIENT_CREATE_AVATAR': 6,
'CLIENT_CREATE_AVATAR_RESP': 7,
'CLIENT_GET_FRIEND_LIST': 10,
'CLIENT_GET_FRIEND_LIST_RESP': 11,
'CLIENT_GET_AVATAR_DETAILS': 14,
'CLIENT_GET_AVATAR_DETAILS_RESP': 15,
'CLIENT_LOGIN_2': 16,
'CLIENT_LOGIN_2_RESP': 17,
'CLIENT_EJECT': 4,
'CLIENT_OBJECT_UPDATE_FIELD': 24,
'CLIENT_OBJECT_UPDATE_FIELD_RESP': 24,
'CLIENT_OBJECT_DISABLE': 25,
'CLIENT_OBJECT_DISABLE_RESP': 25,
'CLIENT_OBJECT_DISABLE_OWNER': 26,
'CLIENT_OBJECT_DISABLE_OWNER_RESP': 26,
'CLIENT_OBJECT_DELETE': 27,
'CLIENT_OBJECT_DELETE_RESP': 27,
'CLIENT_SET_ZONE_CMU': 29,
'CLIENT_REMOVE_ZONE': 30,
'CLIENT_SET_AVATAR': 32,
'CLIENT_CREATE_OBJECT_REQUIRED': 34,
'CLIENT_CREATE_OBJECT_REQUIRED_RESP': 34,
'CLIENT_CREATE_OBJECT_REQUIRED_OTHER': 35,
'CLIENT_CREATE_OBJECT_REQUIRED_OTHER_RESP': 35,
'CLIENT_CREATE_OBJECT_REQUIRED_OTHER_OWNER': 36,
'CLIENT_CREATE_OBJECT_REQUIRED_OTHER_OWNER_RESP':36,
'CLIENT_HEARTBEAT': 5,
'CLIENT_REQUEST_GENERATES': 36,
'CLIENT_OBJECT_SET_FIELD': 120,
'CLIENT_OBJECT_SET_FIELDS': 121,
'CLIENT_OBJECT_LEAVING': 132,
'CLIENT_OBJECT_LEAVING_OWNER': 161,
'CLIENT_ENTER_OBJECT_REQUIRED': 142,
'CLIENT_ENTER_OBJECT_REQUIRED_OTHER': 143,
'CLIENT_ENTER_OBJECT_REQUIRED_OWNER': 172,
'CLIENT_ENTER_OBJECT_REQUIRED_OTHER_OWNER': 173,
'CLIENT_DISCONNECT': 37,
'CLIENT_DONE_INTEREST_RESP': 204,
'CLIENT_GET_STATE_RESP': 47,
'CLIENT_DONE_INTEREST_RESP': 48,
'CLIENT_DELETE_AVATAR': 49,
'CLIENT_DELETE_AVATAR_RESP': 5,
'CLIENT_HEARTBEAT': 52,
'CLIENT_FRIEND_ONLINE': 53,
'CLIENT_FRIEND_OFFLINE': 54,
'CLIENT_REMOVE_FRIEND': 56,
'CLIENT_CHANGE_PASSWORD': 65,
'CLIENT_SET_NAME_PATTERN': 67,
'CLIENT_SET_NAME_PATTERN_ANSWER': 68,
'CLIENT_SET_WISHNAME': 70,
'CLIENT_SET_WISHNAME_RESP': 71,
'CLIENT_SET_WISHNAME_CLEAR': 72,
'CLIENT_SET_SECURITY': 73,
'CLIENT_SET_DOID_RANGE': 74,
'CLIENT_GET_AVATARS_RESP2': 75,
'CLIENT_CREATE_AVATAR2': 76,
'CLIENT_SYSTEM_MESSAGE': 78,
'CLIENT_SET_AVTYPE': 80,
'CLIENT_GET_PET_DETAILS': 81,
'CLIENT_GET_PET_DETAILS_RESP': 82,
'CLIENT_ADD_INTEREST': 97,
'CLIENT_REMOVE_INTEREST': 99,
'CLIENT_OBJECT_LOCATION': 102,
'CLIENT_LOGIN_3': 111,
'CLIENT_LOGIN_3_RESP': 110,
'CLIENT_GET_FRIEND_LIST_EXTENDED': 115,
'CLIENT_GET_FRIEND_LIST_EXTENDED_RESP': 116,
'CLIENT_SET_FIELD_SENDABLE': 120,
'CLIENT_SYSTEMMESSAGE_AKNOWLEDGE': 123,
'CLIENT_CHANGE_GENERATE_ORDER': 124,
# new toontown specific login message, adds last logged in, and if child account has parent acount
'CLIENT_LOGIN_TOONTOWN': 125,
'CLIENT_LOGIN_TOONTOWN_RESP': 126,
'CLIENT_ADD_INTEREST': 200,
'CLIENT_ADD_INTEREST_MULTIPLE': 201,
'CLIENT_REMOVE_INTEREST': 203,
'CLIENT_OBJECT_LOCATION': 140,
# These are sent internally inside the Astron cluster.
'STATESERVER_OBJECT_GENERATE_WITH_REQUIRED': 2001,
'STATESERVER_OBJECT_GENERATE_WITH_REQUIRED_OTHER': 2003,
'STATESERVER_OBJECT_UPDATE_FIELD': 2004,
'STATESERVER_OBJECT_CREATE_WITH_REQUIRED_CONTEXT': 2050,
'STATESERVER_OBJECT_CREATE_WITH_REQUIR_OTHER_CONTEXT': 2051,
'STATESERVER_BOUNCE_MESSAGE': 2086,
# Message Director control messages:
'CONTROL_CHANNEL': 1,
'CONTROL_ADD_CHANNEL': 9000,
'CONTROL_REMOVE_CHANNEL': 9001,
'CONTROL_ADD_RANGE': 9002,
'CONTROL_REMOVE_RANGE': 9003,
'CONTROL_ADD_POST_REMOVE': 9010,
'CONTROL_CLEAR_POST_REMOVES': 9011,
# State Server control messages:
'STATESERVER_CREATE_OBJECT_WITH_REQUIRED': 2000,
'STATESERVER_CREATE_OBJECT_WITH_REQUIRED_OTHER': 2001,
'STATESERVER_DELETE_AI_OBJECTS': 2009,
'STATESERVER_OBJECT_GET_FIELD': 2010,
'STATESERVER_OBJECT_GET_FIELD_RESP': 2011,
'STATESERVER_OBJECT_GET_FIELDS': 2012,
'STATESERVER_OBJECT_GET_FIELDS_RESP': 2013,
'STATESERVER_OBJECT_GET_ALL': 2014,
'STATESERVER_OBJECT_GET_ALL_RESP': 2015,
'STATESERVER_OBJECT_SET_FIELD': 2020,
'STATESERVER_OBJECT_SET_FIELDS': 2021,
'STATESERVER_OBJECT_DELETE_FIELD_RAM': 2030,
'STATESERVER_OBJECT_DELETE_FIELDS_RAM': 2031,
'STATESERVER_OBJECT_DELETE_RAM': 2032,
'STATESERVER_OBJECT_SET_LOCATION': 2040,
'STATESERVER_OBJECT_CHANGING_LOCATION': 2041,
'STATESERVER_OBJECT_ENTER_LOCATION_WITH_REQUIRED': 2042,
'STATESERVER_OBJECT_ENTER_LOCATION_WITH_REQUIRED_OTHER': 2043,
'STATESERVER_OBJECT_GET_LOCATION': 2044,
'STATESERVER_OBJECT_GET_LOCATION_RESP': 2045,
'STATESERVER_OBJECT_SET_AI': 2050,
'STATESERVER_OBJECT_CHANGING_AI': 2051,
'STATESERVER_OBJECT_ENTER_AI_WITH_REQUIRED': 2052,
'STATESERVER_OBJECT_ENTER_AI_WITH_REQUIRED_OTHER': 2053,
'STATESERVER_OBJECT_GET_AI': 2054,
'STATESERVER_OBJECT_GET_AI_RESP': 2055,
'STATESERVER_OBJECT_SET_OWNER': 2060,
'STATESERVER_OBJECT_CHANGING_OWNER': 2061,
'STATESERVER_OBJECT_ENTER_OWNER_WITH_REQUIRED': 2062,
'STATESERVER_OBJECT_ENTER_OWNER_WITH_REQUIRED_OTHER': 2063,
'STATESERVER_OBJECT_GET_OWNER': 2064,
'STATESERVER_OBJECT_GET_OWNER_RESP': 2065,
'STATESERVER_OBJECT_GET_ZONE_OBJECTS': 2100,
'STATESERVER_OBJECT_GET_ZONES_OBJECTS': 2102,
'STATESERVER_OBJECT_GET_CHILDREN': 2104,
'STATESERVER_OBJECT_GET_ZONE_COUNT': 2110,
'STATESERVER_OBJECT_GET_ZONE_COUNT_RESP': 2111,
'STATESERVER_OBJECT_GET_ZONES_COUNT': 2112,
'STATESERVER_OBJECT_GET_ZONES_COUNT_RESP': 2113,
'STATESERVER_OBJECT_GET_CHILD_COUNT': 2114,
'STATESERVER_OBJECT_GET_CHILD_COUNT_RESP': 2115,
'STATESERVER_OBJECT_DELETE_ZONE': 2120,
'STATESERVER_OBJECT_DELETE_ZONES': 2122,
'STATESERVER_OBJECT_DELETE_CHILDREN': 2124,
# DBSS-backed-object messages:
'DBSS_OBJECT_ACTIVATE_WITH_DEFAULTS': 2200,
'DBSS_OBJECT_ACTIVATE_WITH_DEFAULTS_OTHER': 2201,
'DBSS_OBJECT_GET_ACTIVATED': 2207,
'DBSS_OBJECT_GET_ACTIVATED_RESP': 2208,
'DBSS_OBJECT_DELETE_FIELD_DISK': 2230,
'DBSS_OBJECT_DELETE_FIELDS_DISK': 2231,
'DBSS_OBJECT_DELETE_DISK': 2232,
# Database Server control messages:
'DBSERVER_CREATE_OBJECT': 3000,
'DBSERVER_CREATE_OBJECT_RESP': 3001,
'DBSERVER_OBJECT_GET_FIELD': 3010,
'DBSERVER_OBJECT_GET_FIELD_RESP': 3011,
'DBSERVER_OBJECT_GET_FIELDS': 3012,
'DBSERVER_OBJECT_GET_FIELDS_RESP': 3013,
'DBSERVER_OBJECT_GET_ALL': 3014,
'DBSERVER_OBJECT_GET_ALL_RESP': 3015,
'DBSERVER_OBJECT_SET_FIELD': 3020,
'DBSERVER_OBJECT_SET_FIELDS': 3021,
'DBSERVER_OBJECT_SET_FIELD_IF_EQUALS': 3022,
'DBSERVER_OBJECT_SET_FIELD_IF_EQUALS_RESP': 3023,
'DBSERVER_OBJECT_SET_FIELDS_IF_EQUALS': 3024,
'DBSERVER_OBJECT_SET_FIELDS_IF_EQUALS_RESP': 3025,
'DBSERVER_OBJECT_SET_FIELD_IF_EMPTY': 3026,
'DBSERVER_OBJECT_SET_FIELD_IF_EMPTY_RESP': 3027,
'DBSERVER_OBJECT_DELETE_FIELD': 3030,
'DBSERVER_OBJECT_DELETE_FIELDS': 3031,
'DBSERVER_OBJECT_DELETE': 3032,
# Client Agent control messages:
'CLIENTAGENT_SET_STATE': 1000,
'CLIENTAGENT_SET_CLIENT_ID': 1001,
'CLIENTAGENT_SEND_DATAGRAM': 1002,
'CLIENTAGENT_EJECT': 1004,
'CLIENTAGENT_DROP': 1005,
'CLIENTAGENT_GET_NETWORK_ADDRESS': 1006,
'CLIENTAGENT_GET_NETWORK_ADDRESS_RESP': 1007,
'CLIENTAGENT_DECLARE_OBJECT': 1010,
'CLIENTAGENT_UNDECLARE_OBJECT': 1011,
'CLIENTAGENT_ADD_SESSION_OBJECT': 1012,
'CLIENTAGENT_REMOVE_SESSION_OBJECT': 1013,
'CLIENTAGENT_SET_FIELDS_SENDABLE': 1014,
'CLIENTAGENT_OPEN_CHANNEL': 1100,
'CLIENTAGENT_CLOSE_CHANNEL': 1101,
'CLIENTAGENT_ADD_POST_REMOVE': 1110,
'CLIENTAGENT_CLEAR_POST_REMOVES': 1111,
'CLIENTAGENT_ADD_INTEREST': 1200,
'CLIENTAGENT_ADD_INTEREST_MULTIPLE': 1201,
'CLIENTAGENT_REMOVE_INTEREST': 1203,
}
# create id->name table for debugging

View File

@ -19,7 +19,7 @@ MsgName2Id = {
'CLIENT_HEARTBEAT_CMU' : 9011,
'CLIENT_OBJECT_UPDATE_FIELD_TARGETED_CMU' : 9011,
'CLIENT_OBJECT_UPDATE_FIELD' : 24, # Matches MsgTypes.CLIENT_OBJECT_UPDATE_FIELD
'CLIENT_OBJECT_UPDATE_FIELD' : 120, # Matches MsgTypes.CLIENT_OBJECT_SET_FIELD
}
# create id->name table for debugging

View File

@ -1,208 +0,0 @@
"""OldClientRepository module: contains the OldClientRepository class"""
from .ClientRepositoryBase import *
class OldClientRepository(ClientRepositoryBase):
"""
This is the open-source ClientRepository as provided by CMU. It
communicates with the ServerRepository in this same directory.
If you are looking for the VR Studio's implementation of the
client repository, look to OTPClientRepository (elsewhere).
"""
notify = DirectNotifyGlobal.directNotify.newCategory("ClientRepository")
def __init__(self, dcFileNames = None):
ClientRepositoryBase.__init__(self, dcFileNames = dcFileNames)
# The DOID allocator. The CMU LAN server may choose to
# send us a block of DOIDs. If it chooses to do so, then we
# may create objects, using those DOIDs.
self.DOIDbase = 0
self.DOIDnext = 0
self.DOIDlast = 0
def handleSetDOIDrange(self, di):
self.DOIDbase = di.getUint32()
self.DOIDlast = self.DOIDbase + di.getUint32()
self.DOIDnext = self.DOIDbase
def handleRequestGenerates(self, di):
# When new clients join the zone of an object, they need to hear
# about it, so we send out all of our information about objects in
# that particular zone.
assert self.DOIDnext < self.DOIDlast
zone = di.getUint32()
for obj in self.doId2do.values():
if obj.zone == zone:
id = obj.doId
if (self.isLocalId(id)):
self.send(obj.dclass.clientFormatGenerate(obj, id, zone, []))
def createWithRequired(self, className, zoneId = 0, optionalFields=None):
if self.DOIDnext >= self.DOIDlast:
self.notify.error(
"Cannot allocate a distributed object ID: all IDs used up.")
return None
id = self.DOIDnext
self.DOIDnext = self.DOIDnext + 1
dclass = self.dclassesByName[className]
classDef = dclass.getClassDef()
if classDef == None:
self.notify.error("Could not create an undefined %s object." % (
dclass.getName()))
obj = classDef(self)
obj.dclass = dclass
obj.zone = zoneId
obj.doId = id
self.doId2do[id] = obj
obj.generateInit()
obj._retrieveCachedData()
obj.generate()
obj.announceGenerate()
datagram = dclass.clientFormatGenerate(obj, id, zoneId, optionalFields)
self.send(datagram)
return obj
def sendDisableMsg(self, doId):
datagram = PyDatagram()
datagram.addUint16(CLIENT_OBJECT_DISABLE)
datagram.addUint32(doId)
self.send(datagram)
def sendDeleteMsg(self, doId):
datagram = PyDatagram()
datagram.addUint16(CLIENT_OBJECT_DELETE)
datagram.addUint32(doId)
self.send(datagram)
def sendRemoveZoneMsg(self, zoneId, visibleZoneList=None):
datagram = PyDatagram()
datagram.addUint16(CLIENT_REMOVE_ZONE)
datagram.addUint32(zoneId)
# if we have an explicit list of visible zones, add them
if visibleZoneList is not None:
vzl = list(visibleZoneList)
vzl.sort()
assert PythonUtil.uniqueElements(vzl)
for zone in vzl:
datagram.addUint32(zone)
# send the message
self.send(datagram)
def sendUpdateZone(self, obj, zoneId):
id = obj.doId
assert self.isLocalId(id)
self.sendDeleteMsg(id, 1)
obj.zone = zoneId
self.send(obj.dclass.clientFormatGenerate(obj, id, zoneId, []))
def sendSetZoneMsg(self, zoneId, visibleZoneList=None):
datagram = PyDatagram()
# Add message type
datagram.addUint16(CLIENT_SET_ZONE_CMU)
# Add zone id
datagram.addUint32(zoneId)
# if we have an explicit list of visible zones, add them
if visibleZoneList is not None:
vzl = list(visibleZoneList)
vzl.sort()
assert PythonUtil.uniqueElements(vzl)
for zone in vzl:
datagram.addUint32(zone)
# send the message
self.send(datagram)
def isLocalId(self, id):
return ((id >= self.DOIDbase) and (id < self.DOIDlast))
def haveCreateAuthority(self):
return (self.DOIDlast > self.DOIDnext)
def handleDatagram(self, di):
if self.notify.getDebug():
print("ClientRepository received datagram:")
di.getDatagram().dumpHex(ostream)
msgType = self.getMsgType()
# These are the sort of messages we may expect from the public
# Panda server.
if msgType == CLIENT_SET_DOID_RANGE:
self.handleSetDOIDrange(di)
elif msgType == CLIENT_CREATE_OBJECT_REQUIRED_RESP:
self.handleGenerateWithRequired(di)
elif msgType == CLIENT_CREATE_OBJECT_REQUIRED_OTHER_RESP:
self.handleGenerateWithRequiredOther(di)
elif msgType == CLIENT_OBJECT_UPDATE_FIELD_RESP:
self.handleUpdateField(di)
elif msgType == CLIENT_OBJECT_DELETE_RESP:
self.handleDelete(di)
elif msgType == CLIENT_OBJECT_DISABLE_RESP:
self.handleDisable(di)
elif msgType == CLIENT_REQUEST_GENERATES:
self.handleRequestGenerates(di)
else:
self.handleMessageType(msgType, di)
# If we're processing a lot of datagrams within one frame, we
# may forget to send heartbeats. Keep them coming!
self.considerHeartbeat()
def handleGenerateWithRequired(self, di):
# Get the class Id
classId = di.getUint16()
# Get the DO Id
doId = di.getUint32()
# Look up the dclass
dclass = self.dclassesByNumber[classId]
dclass.startGenerate()
# Create a new distributed object, and put it in the dictionary
distObj = self.generateWithRequiredFields(dclass, doId, di)
dclass.stopGenerate()
def generateWithRequiredFields(self, dclass, doId, di):
if doId in self.doId2do:
# ...it is in our dictionary.
# Just update it.
distObj = self.doId2do[doId]
assert distObj.dclass == dclass
distObj.generate()
distObj.updateRequiredFields(dclass, di)
# updateRequiredFields calls announceGenerate
elif self.cache.contains(doId):
# ...it is in the cache.
# Pull it out of the cache:
distObj = self.cache.retrieve(doId)
assert distObj.dclass == dclass
# put it in the dictionary:
self.doId2do[doId] = distObj
# and update it.
distObj.generate()
distObj.updateRequiredFields(dclass, di)
# updateRequiredFields calls announceGenerate
else:
# ...it is not in the dictionary or the cache.
# Construct a new one
classDef = dclass.getClassDef()
if classDef == None:
self.notify.error("Could not create an undefined %s object." % (
dclass.getName()))
distObj = classDef(self)
distObj.dclass = dclass
# Assign it an Id
distObj.doId = doId
# Put the new do in the dictionary
self.doId2do[doId] = distObj
# Update the required fields
distObj.generateInit() # Only called when constructed
distObj.generate()
distObj.updateRequiredFields(dclass, di)
# updateRequiredFields calls announceGenerate
return distObj

View File

@ -7,7 +7,7 @@ from panda3d.core import Datagram
from panda3d.direct import *
# Import the type numbers
#from otp.ai.AIMsgTypes import *
from direct.distributed.MsgTypes import *
class PyDatagram(Datagram):
@ -47,13 +47,10 @@ class PyDatagram(Datagram):
self.addUint16(code)
# def addServerControlHeader(self, code):
# self.addInt8(1)
# self.addChannel(CONTROL_MESSAGE)
# self.addUint16(code)
# def addOldServerControlHeader(self, code):
# self.addChannel(CONTROL_MESSAGE)
# self.addUint16(code)
def addServerControlHeader(self, code):
self.addInt8(1)
self.addChannel(CONTROL_CHANNEL)
self.addUint16(code)
def putArg(self, arg, subatomicType, divisor=1):
if (divisor == 1):

View File

@ -301,8 +301,8 @@ check_datagram() {
switch (_msg_type) {
#ifdef HAVE_PYTHON
case CLIENT_OBJECT_UPDATE_FIELD:
case STATESERVER_OBJECT_UPDATE_FIELD:
case CLIENT_OBJECT_SET_FIELD:
case STATESERVER_OBJECT_SET_FIELD:
if (_handle_c_updates) {
if (_has_owner_view) {
if (!handle_update_field_owner()) {
@ -494,7 +494,7 @@ send_message_bundle(unsigned int channel, unsigned int sender_channel) {
dg.add_int8(1);
dg.add_uint64(channel);
dg.add_uint64(sender_channel);
dg.add_uint16(STATESERVER_BOUNCE_MESSAGE);
//dg.add_uint16(STATESERVER_BOUNCE_MESSAGE);
// add each bundled message
BundledMsgVector::const_iterator bmi;
for (bmi = _bundle_msgs.begin(); bmi != _bundle_msgs.end(); bmi++) {
@ -899,11 +899,11 @@ describe_message(ostream &out, const string &prefix,
packer.RAW_UNPACK_CHANNEL(); // msg_sender
msg_type = packer.raw_unpack_uint16();
is_update = (msg_type == STATESERVER_OBJECT_UPDATE_FIELD);
is_update = (msg_type == STATESERVER_OBJECT_SET_FIELD);
} else {
msg_type = packer.raw_unpack_uint16();
is_update = (msg_type == CLIENT_OBJECT_UPDATE_FIELD);
is_update = (msg_type == CLIENT_OBJECT_SET_FIELD);
}
if (!is_update) {

View File

@ -278,12 +278,12 @@ begin_send_update(DCPacker &packer, const string &field_name) {
packer.RAW_PACK_CHANNEL(_do_id);
packer.RAW_PACK_CHANNEL(_ai_id);
// packer.raw_pack_uint8('A');
packer.raw_pack_uint16(STATESERVER_OBJECT_UPDATE_FIELD);
packer.raw_pack_uint16(STATESERVER_OBJECT_SET_FIELD);
packer.raw_pack_uint32(_do_id);
packer.raw_pack_uint16(field->get_number());
} else {
packer.raw_pack_uint16(CLIENT_OBJECT_UPDATE_FIELD);
packer.raw_pack_uint16(CLIENT_OBJECT_SET_FIELD);
packer.raw_pack_uint32(_do_id);
packer.raw_pack_uint16(field->get_number());
}

View File

@ -80,7 +80,8 @@ __all__ = ['DirectGuiBase', 'DirectGuiWidget']
from panda3d.core import *
from panda3d.direct import get_config_showbase
from direct.showbase import ShowBaseGlobal
from direct.showbase.ShowBase import ShowBase
from . import DirectGuiGlobals as DGG
from .OnscreenText import *
from .OnscreenGeom import *
@ -633,7 +634,7 @@ class DirectGuiBase(DirectObject.DirectObject):
"""
# Need to tack on gui item specific id
gEvent = event + self.guiId
if get_config_showbase().GetBool('debug-directgui-msgs', False):
if ShowBase.config.GetBool('debug-directgui-msgs', False):
from direct.showbase.PythonUtil import StackTrace
print(gEvent)
print(StackTrace())
@ -662,7 +663,7 @@ class DirectGuiWidget(DirectGuiBase, NodePath):
# Determine the default initial state for inactive (or
# unclickable) components. If we are in edit mode, these are
# actually clickable by default.
guiEdit = get_config_showbase().GetBool('direct-gui-edit', 0)
guiEdit = ShowBase.config.GetBool('direct-gui-edit', False)
if guiEdit:
inactiveInitState = DGG.NORMAL
else:
@ -723,21 +724,24 @@ class DirectGuiWidget(DirectGuiBase, NodePath):
if self['guiId']:
self.guiItem.setId(self['guiId'])
self.guiId = self.guiItem.getId()
if __dev__:
if ShowBaseGlobal.__dev__:
guiObjectCollector.addLevel(1)
guiObjectCollector.flushLevel()
# track gui items by guiId for tracking down leaks
if hasattr(base, 'guiItems'):
if self.guiId in base.guiItems:
base.notify.warning('duplicate guiId: %s (%s stomping %s)' %
(self.guiId, self,
base.guiItems[self.guiId]))
base.guiItems[self.guiId] = self
if hasattr(base, 'printGuiCreates'):
printStack()
if ShowBase.config.GetBool('track-gui-items', False):
if not hasattr(ShowBase, 'guiItems'):
ShowBase.guiItems = {}
if self.guiId in ShowBase.guiItems:
ShowBase.notify.warning('duplicate guiId: %s (%s stomping %s)' %
(self.guiId, self,
ShowBase.guiItems[self.guiId]))
ShowBase.guiItems[self.guiId] = self
# Attach button to parent and make that self
if (parent == None):
parent = aspect2d
if parent is None:
parent = ShowBaseGlobal.aspect2d
self.assign(parent.attachNewNode(self.guiItem, self['sortOrder']))
# Update pose to initial values
if self['pos']:
@ -1024,17 +1028,12 @@ class DirectGuiWidget(DirectGuiBase, NodePath):
def destroy(self):
if hasattr(self, "frameStyle"):
if __dev__:
if ShowBaseGlobal.__dev__:
guiObjectCollector.subLevel(1)
guiObjectCollector.flushLevel()
if hasattr(base, 'guiItems'):
if self.guiId in base.guiItems:
del base.guiItems[self.guiId]
else:
base.notify.warning(
'DirectGuiWidget.destroy(): '
'gui item %s not in base.guiItems' %
self.guiId)
if hasattr(ShowBase, 'guiItems'):
ShowBase.guiItems.pop(self.guiId, None)
# Destroy children
for child in self.getChildren():
childGui = self.guiDict.get(child.getName())

View File

@ -47,10 +47,6 @@ if __debug__:
from . import OnScreenDebug
from . import AppRunnerGlobal
def legacyRun():
assert builtins.base.notify.warning("run() is deprecated, use base.run() instead")
builtins.base.run()
@atexit.register
def exitfunc():
if getattr(builtins, 'base', None) is not None:
@ -369,7 +365,6 @@ class ShowBase(DirectObject.DirectObject):
builtins.bboard = self.bboard
# Config needs to be defined before ShowBase is constructed
#builtins.config = self.config
builtins.run = legacyRun
builtins.ostream = Notify.out()
builtins.directNotify = directNotify
builtins.giveNotify = giveNotify
@ -391,7 +386,9 @@ class ShowBase(DirectObject.DirectObject):
# Now add this instance to the ShowBaseGlobal module scope.
from . import ShowBaseGlobal
builtins.run = ShowBaseGlobal.run
ShowBaseGlobal.base = self
ShowBaseGlobal.__dev__ = self.__dev__
if self.__dev__:
ShowBase.notify.debug('__dev__ == %s' % self.__dev__)
@ -400,10 +397,10 @@ class ShowBase(DirectObject.DirectObject):
self.createBaseAudioManagers()
if self.__dev__ or self.config.GetBool('want-e3-hacks', False):
if self.config.GetBool('track-gui-items', True):
# dict of guiId to gui item, for tracking down leaks
self.guiItems = {}
if self.__dev__ and self.config.GetBool('track-gui-items', False):
# dict of guiId to gui item, for tracking down leaks
if not hasattr(ShowBase, 'guiItems'):
ShowBase.guiItems = {}
# optionally restore the default gui sounds from 1.7.2 and earlier
if ConfigVariableBool('orig-gui-sounds', False).getValue():
@ -515,6 +512,7 @@ class ShowBase(DirectObject.DirectObject):
# Remove the built-in base reference
if getattr(builtins, 'base', None) is self:
del builtins.run
del builtins.base
del builtins.loader
del builtins.taskMgr
@ -522,6 +520,8 @@ class ShowBase(DirectObject.DirectObject):
if ShowBaseGlobal:
del ShowBaseGlobal.base
self.aspect2d.node().removeAllChildren()
# [gjeon] restore sticky key settings
if self.config.GetBool('disable-sticky-keys', 0):
allowAccessibilityShortcutKeys(True)
@ -1104,13 +1104,18 @@ class ShowBase(DirectObject.DirectObject):
self.render2d.setMaterialOff(1)
self.render2d.setTwoSided(1)
# We've already created aspect2d in ShowBaseGlobal, for the
# benefit of creating DirectGui elements before ShowBase.
from . import ShowBaseGlobal
## The normal 2-d DisplayRegion has an aspect ratio that
## matches the window, but its coordinate system is square.
## This means anything we parent to render2d gets stretched.
## For things where that makes a difference, we set up
## aspect2d, which scales things back to the right aspect
## ratio along the X axis (Z is still from -1 to 1)
self.aspect2d = self.render2d.attachNewNode(PGTop("aspect2d"))
self.aspect2d = ShowBaseGlobal.aspect2d
self.aspect2d.reparentTo(self.render2d)
aspectRatio = self.getAspectRatio()
self.aspect2d.setScale(1.0 / aspectRatio, 1.0, 1.0)

View File

@ -11,9 +11,11 @@ from .ShowBase import ShowBase, WindowControls
from direct.directnotify.DirectNotifyGlobal import directNotify, giveNotify
from panda3d.core import VirtualFileSystem, Notify, ClockObject, PandaSystem
from panda3d.core import ConfigPageManager, ConfigVariableManager
from panda3d.core import NodePath, PGTop
from panda3d.direct import get_config_showbase
config = get_config_showbase()
__dev__ = config.GetBool('want-dev', __debug__)
vfs = VirtualFileSystem.getGlobalPtr()
ostream = Notify.out()
@ -22,9 +24,16 @@ cpMgr = ConfigPageManager.getGlobalPtr()
cvMgr = ConfigVariableManager.getGlobalPtr()
pandaSystem = PandaSystem.getGlobalPtr()
# This is defined here so GUI elements can be instantiated before ShowBase.
aspect2d = NodePath(PGTop("aspect2d"))
# Set direct notify categories now that we have config
directNotify.setDconfigLevels()
def run():
assert ShowBase.notify.warning("run() is deprecated, use base.run() instead")
base.run()
def inspect(anObject):
# Don't use a regular import, to prevent ModuleFinder from picking
# it up as a dependency when building a .p3d package.
@ -41,6 +50,4 @@ builtins.inspect = inspect
# this also appears in AIBaseGlobal
if (not __debug__) and __dev__:
notify = directNotify.newCategory('ShowBaseGlobal')
notify.error("You must set 'want-dev' to false in non-debug mode.")
del notify
ShowBase.notify.error("You must set 'want-dev' to false in non-debug mode.")

View File

@ -3736,18 +3736,6 @@
<File RelativePath="..\panda\src\cull\cullBinFrontToBack.cxx"></File>
<File RelativePath="..\panda\src\cull\config_cull.h"></File>
</Filter>
<Filter Name="cftalk">
<File RelativePath="..\panda\src\cftalk\cfChannel.I"></File>
<File RelativePath="..\panda\src\cftalk\cfCommand.h"></File>
<File RelativePath="..\panda\src\cftalk\config_cftalk.h"></File>
<File RelativePath="..\panda\src\cftalk\cfCommand.cxx"></File>
<File RelativePath="..\panda\src\cftalk\config_cftalk.cxx"></File>
<File RelativePath="..\panda\src\cftalk\cfChannel.h"></File>
<File RelativePath="..\panda\src\cftalk\cfCommand.I"></File>
<File RelativePath="..\panda\src\cftalk\cfChannel.cxx"></File>
<File RelativePath="..\panda\src\cftalk\cftalk_composite2.cxx"></File>
<File RelativePath="..\panda\src\cftalk\cftalk_composite1.cxx"></File>
</Filter>
<Filter Name="audiotraits">
<File RelativePath="..\panda\src\audiotraits\milesAudioSequence.cxx"></File>
<File RelativePath="..\panda\src\audiotraits\milesAudioStream.I"></File>

View File

@ -471,6 +471,12 @@ get_sound(MovieAudio *sound, bool positional, int mode) {
PT(OpenALAudioSound) oas =
new OpenALAudioSound(this, sound, positional, mode);
if(!oas->_manager) {
// The sound cleaned itself up immediately. It pretty clearly didn't like
// something, so we should just return a null sound instead.
return get_null_sound();
}
_all_sounds.insert(oas);
PT(AudioSound) res = (AudioSound*)(OpenALAudioSound*)oas;
return res;
@ -500,6 +506,12 @@ get_sound(const string &file_name, bool positional, int mode) {
PT(OpenALAudioSound) oas =
new OpenALAudioSound(this, mva, positional, mode);
if(!oas->_manager) {
// The sound cleaned itself up immediately. It pretty clearly didn't like
// something, so we should just return a null sound instead.
return get_null_sound();
}
_all_sounds.insert(oas);
PT(AudioSound) res = (AudioSound*)(OpenALAudioSound*)oas;
return res;

View File

@ -37,16 +37,19 @@ get_calibrated_clock(double rtc) const {
/**
* Makes sure the sound data record is present, and if not, obtains it.
*
* Returns true on success, false on failure.
*/
void OpenALAudioSound::
bool OpenALAudioSound::
require_sound_data() {
if (_sd==0) {
_sd = _manager->get_sound_data(_movie, _desired_mode);
if (_sd==0) {
audio_error("Could not open audio " << _movie->get_filename());
cleanup();
return false;
}
}
return true;
}
/**

View File

@ -69,8 +69,8 @@ OpenALAudioSound(OpenALAudioManager* manager,
ReMutexHolder holder(OpenALAudioManager::_lock);
require_sound_data();
if (_manager == NULL) {
if (!require_sound_data()) {
cleanup();
return;
}
@ -130,10 +130,12 @@ play() {
stop();
require_sound_data();
if (_manager == 0) return;
_manager->starting_sound(this);
if (!require_sound_data()) {
cleanup();
return;
}
_manager->starting_sound(this);
if (!_source) {
return;
}

View File

@ -116,7 +116,7 @@ private:
int read_stream_data(int bytelen, unsigned char *data);
void pull_used_buffers();
void push_fresh_buffers();
INLINE void require_sound_data();
INLINE bool require_sound_data();
INLINE void release_sound_data();
private:

View File

@ -43,8 +43,8 @@ public:
virtual btPairCachingGhostObject *get_ghost() const = 0;
virtual btCharacterControllerInterface *get_character() const = 0;
virtual void sync_p2b(PN_stdfloat dt, int num_substeps) = 0;
virtual void sync_b2p() = 0;
virtual void do_sync_p2b(PN_stdfloat dt, int num_substeps) = 0;
virtual void do_sync_b2p() = 0;
public:
static TypeHandle get_class_type() {

View File

@ -84,51 +84,6 @@ get_collision_response() const {
return !get_collision_flag(btCollisionObject::CF_NO_CONTACT_RESPONSE);
}
/**
*
*/
INLINE void BulletBodyNode::
set_collision_flag(int flag, bool value) {
int flags = get_object()->getCollisionFlags();
if (value == true) {
flags |= flag;
}
else {
flags &= ~(flag);
}
get_object()->setCollisionFlags(flags);
}
/**
*
*/
INLINE bool BulletBodyNode::
get_collision_flag(int flag) const {
return (get_object()->getCollisionFlags() & flag) ? true : false;
}
/**
*
*/
INLINE bool BulletBodyNode::
is_static() const {
return get_object()->isStaticObject();
}
/**
*
*/
INLINE bool BulletBodyNode::
is_kinematic() const {
return get_object()->isKinematicObject();
}
/**
*
*/
@ -147,90 +102,6 @@ set_kinematic(bool value) {
set_collision_flag(btCollisionObject::CF_KINEMATIC_OBJECT, value);
}
/**
*
*/
INLINE PN_stdfloat BulletBodyNode::
get_restitution() const {
return get_object()->getRestitution();
}
/**
*
*/
INLINE void BulletBodyNode::
set_restitution(PN_stdfloat restitution) {
return get_object()->setRestitution(restitution);
}
/**
*
*/
INLINE PN_stdfloat BulletBodyNode::
get_friction() const {
return get_object()->getFriction();
}
/**
*
*/
INLINE void BulletBodyNode::
set_friction(PN_stdfloat friction) {
return get_object()->setFriction(friction);
}
#if BT_BULLET_VERSION >= 281
/**
*
*/
INLINE PN_stdfloat BulletBodyNode::
get_rolling_friction() const {
return get_object()->getRollingFriction();
}
/**
*
*/
INLINE void BulletBodyNode::
set_rolling_friction(PN_stdfloat friction) {
return get_object()->setRollingFriction(friction);
}
#endif
/**
*
*/
INLINE bool BulletBodyNode::
has_anisotropic_friction() const {
return get_object()->hasAnisotropicFriction();
}
/**
*
*/
INLINE int BulletBodyNode::
get_num_shapes() const {
return _shapes.size();
}
/**
*
*/
INLINE BulletShape *BulletBodyNode::
get_shape(int idx) const {
nassertr(idx >= 0 && idx < (int)_shapes.size(), NULL);
return _shapes[idx];
}
/**
* Enables or disables the debug visualisation for this collision object. By
* default the debug visualisation is enabled.

View File

@ -41,9 +41,11 @@ BulletBodyNode(const char *name) : PandaNode(name) {
*/
BulletBodyNode::
BulletBodyNode(const BulletBodyNode &copy) :
PandaNode(copy),
_shapes(copy._shapes)
PandaNode(copy)
{
LightMutexHolder holder(BulletWorld::get_global_lock());
_shapes = copy._shapes;
if (copy._shape && copy._shape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE) {
// btCompoundShape does not define a copy constructor. Manually copy.
btCompoundShape *shape = new btCompoundShape;
@ -148,16 +150,168 @@ safe_to_flatten_below() const {
*
*/
void BulletBodyNode::
output(ostream &out) const {
do_output(ostream &out) const {
PandaNode::output(out);
out << " (" << get_num_shapes() << " shapes)";
out << " (" << _shapes.size() << " shapes)";
out << (is_active() ? " active" : " inactive");
out << (get_object()->isActive() ? " active" : " inactive");
if (is_static()) out << " static";
if (is_kinematic()) out << " kinematic";
if (get_object()->isStaticObject()) out << " static";
if (get_object()->isKinematicObject()) out << " kinematic";
}
/**
*
*/
void BulletBodyNode::
output(ostream &out) const {
LightMutexHolder holder(BulletWorld::get_global_lock());
do_output(out);
}
/**
*
*/
void BulletBodyNode::
set_collision_flag(int flag, bool value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
int flags = get_object()->getCollisionFlags();
if (value == true) {
flags |= flag;
}
else {
flags &= ~(flag);
}
get_object()->setCollisionFlags(flags);
}
/**
*
*/
bool BulletBodyNode::
get_collision_flag(int flag) const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (get_object()->getCollisionFlags() & flag) ? true : false;
}
/**
*
*/
bool BulletBodyNode::
is_static() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return get_object()->isStaticObject();
}
/**
*
*/
bool BulletBodyNode::
is_kinematic() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return get_object()->isKinematicObject();
}
/**
*
*/
PN_stdfloat BulletBodyNode::
get_restitution() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return get_object()->getRestitution();
}
/**
*
*/
void BulletBodyNode::
set_restitution(PN_stdfloat restitution) {
LightMutexHolder holder(BulletWorld::get_global_lock());
return get_object()->setRestitution(restitution);
}
/**
*
*/
PN_stdfloat BulletBodyNode::
get_friction() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return get_object()->getFriction();
}
/**
*
*/
void BulletBodyNode::
set_friction(PN_stdfloat friction) {
LightMutexHolder holder(BulletWorld::get_global_lock());
return get_object()->setFriction(friction);
}
#if BT_BULLET_VERSION >= 281
/**
*
*/
PN_stdfloat BulletBodyNode::
get_rolling_friction() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return get_object()->getRollingFriction();
}
/**
*
*/
void BulletBodyNode::
set_rolling_friction(PN_stdfloat friction) {
LightMutexHolder holder(BulletWorld::get_global_lock());
return get_object()->setRollingFriction(friction);
}
#endif
/**
*
*/
bool BulletBodyNode::
has_anisotropic_friction() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return get_object()->hasAnisotropicFriction();
}
/**
*
*/
int BulletBodyNode::
get_num_shapes() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _shapes.size();
}
/**
*
*/
BulletShape *BulletBodyNode::
get_shape(int idx) const {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertr(idx >= 0 && idx < (int)_shapes.size(), NULL);
return _shapes[idx];
}
/**
@ -165,6 +319,16 @@ output(ostream &out) const {
*/
void BulletBodyNode::
add_shape(BulletShape *bullet_shape, const TransformState *ts) {
LightMutexHolder holder(BulletWorld::get_global_lock());
do_add_shape(bullet_shape, ts);
}
/**
* Assumes the lock(bullet global lock) is held by the caller
*/
void BulletBodyNode::
do_add_shape(BulletShape *bullet_shape, const TransformState *ts) {
nassertv(get_object());
nassertv(ts);
@ -246,7 +410,7 @@ add_shape(BulletShape *bullet_shape, const TransformState *ts) {
// Restore the local scaling again
np.set_scale(scale);
shape_changed();
do_shape_changed();
}
/**
@ -254,6 +418,7 @@ add_shape(BulletShape *bullet_shape, const TransformState *ts) {
*/
void BulletBodyNode::
remove_shape(BulletShape *shape) {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertv(get_object());
@ -312,7 +477,7 @@ remove_shape(BulletShape *shape) {
compound->removeChildShape(shape->ptr());
}
shape_changed();
do_shape_changed();
}
}
@ -333,6 +498,7 @@ is_identity(btTransform &trans) {
*/
LPoint3 BulletBodyNode::
get_shape_pos(int idx) const {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertr(idx >= 0 && idx < (int)_shapes.size(), LPoint3::zero());
@ -352,14 +518,17 @@ get_shape_pos(int idx) const {
*/
LMatrix4 BulletBodyNode::
get_shape_mat(int idx) const {
return get_shape_transform(idx)->get_mat();
LightMutexHolder holder(BulletWorld::get_global_lock());
return do_get_shape_transform(idx)->get_mat();
}
/**
*
*/
CPT(TransformState) BulletBodyNode::
get_shape_transform(int idx) const {
do_get_shape_transform(int idx) const {
nassertr(idx >= 0 && idx < (int)_shapes.size(), TransformState::make_identity());
btCollisionShape *root = get_object()->getCollisionShape();
@ -386,13 +555,25 @@ get_shape_transform(int idx) const {
return TransformState::make_identity();
}
/**
*
*/
CPT(TransformState) BulletBodyNode::
get_shape_transform(int idx) const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return do_get_shape_transform(idx);
}
/**
* Hook which will be called whenever the total shape of a body changed. Used
* for example to update the mass properties (inertia) of a rigid body. The
* default implementation does nothing.
* Assumes the lock(bullet global lock) is held
*/
void BulletBodyNode::
shape_changed() {
do_shape_changed() {
}
@ -401,6 +582,7 @@ shape_changed() {
*/
void BulletBodyNode::
set_deactivation_time(PN_stdfloat dt) {
LightMutexHolder holder(BulletWorld::get_global_lock());
get_object()->setDeactivationTime(dt);
}
@ -410,6 +592,7 @@ set_deactivation_time(PN_stdfloat dt) {
*/
PN_stdfloat BulletBodyNode::
get_deactivation_time() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return get_object()->getDeactivationTime();
}
@ -419,6 +602,7 @@ get_deactivation_time() const {
*/
bool BulletBodyNode::
is_active() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return get_object()->isActive();
}
@ -428,6 +612,7 @@ is_active() const {
*/
void BulletBodyNode::
set_active(bool active, bool force) {
LightMutexHolder holder(BulletWorld::get_global_lock());
if (active) {
get_object()->activate(force);
@ -457,10 +642,12 @@ force_active(bool active) {
*/
void BulletBodyNode::
set_deactivation_enabled(bool enabled) {
LightMutexHolder holder(BulletWorld::get_global_lock());
// Don't change the state if it's currently active and we enable
// deactivation.
if (enabled != is_deactivation_enabled()) {
bool is_enabled = get_object()->getActivationState() != DISABLE_DEACTIVATION;
if (enabled != is_enabled) {
// It's OK to set to ACTIVE_TAG even if we don't mean to activate it; it
// will be disabled right away if the deactivation timer has run out.
@ -474,6 +661,7 @@ set_deactivation_enabled(bool enabled) {
*/
bool BulletBodyNode::
is_deactivation_enabled() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (get_object()->getActivationState() != DISABLE_DEACTIVATION);
}
@ -483,6 +671,7 @@ is_deactivation_enabled() const {
*/
bool BulletBodyNode::
check_collision_with(PandaNode *node) {
LightMutexHolder holder(BulletWorld::get_global_lock());
btCollisionObject *obj = BulletWorld::get_collision_object(node);
@ -499,6 +688,7 @@ check_collision_with(PandaNode *node) {
*/
LVecBase3 BulletBodyNode::
get_anisotropic_friction() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btVector3_to_LVecBase3(get_object()->getAnisotropicFriction());
}
@ -508,6 +698,7 @@ get_anisotropic_friction() const {
*/
void BulletBodyNode::
set_anisotropic_friction(const LVecBase3 &friction) {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertv(!friction.is_nan());
get_object()->setAnisotropicFriction(LVecBase3_to_btVector3(friction));
@ -518,6 +709,7 @@ set_anisotropic_friction(const LVecBase3 &friction) {
*/
bool BulletBodyNode::
has_contact_response() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return get_object()->hasContactResponse();
}
@ -527,7 +719,8 @@ has_contact_response() const {
*/
PN_stdfloat BulletBodyNode::
get_contact_processing_threshold() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return get_object()->getContactProcessingThreshold();
}
@ -537,6 +730,7 @@ get_contact_processing_threshold() const {
*/
void BulletBodyNode::
set_contact_processing_threshold(PN_stdfloat threshold) {
LightMutexHolder holder(BulletWorld::get_global_lock());
get_object()->setContactProcessingThreshold(threshold);
}
@ -546,6 +740,7 @@ set_contact_processing_threshold(PN_stdfloat threshold) {
*/
PN_stdfloat BulletBodyNode::
get_ccd_swept_sphere_radius() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return get_object()->getCcdSweptSphereRadius();
}
@ -555,6 +750,7 @@ get_ccd_swept_sphere_radius() const {
*/
void BulletBodyNode::
set_ccd_swept_sphere_radius(PN_stdfloat radius) {
LightMutexHolder holder(BulletWorld::get_global_lock());
return get_object()->setCcdSweptSphereRadius(radius);
}
@ -564,6 +760,7 @@ set_ccd_swept_sphere_radius(PN_stdfloat radius) {
*/
PN_stdfloat BulletBodyNode::
get_ccd_motion_threshold() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return get_object()->getCcdMotionThreshold();
}
@ -573,6 +770,7 @@ get_ccd_motion_threshold() const {
*/
void BulletBodyNode::
set_ccd_motion_threshold(PN_stdfloat threshold) {
LightMutexHolder holder(BulletWorld::get_global_lock());
return get_object()->setCcdMotionThreshold(threshold);
}
@ -582,6 +780,7 @@ set_ccd_motion_threshold(PN_stdfloat threshold) {
*/
void BulletBodyNode::
add_shapes_from_collision_solids(CollisionNode *cnode) {
LightMutexHolder holder(BulletWorld::get_global_lock());
PT(BulletTriangleMesh) mesh = NULL;
@ -594,7 +793,7 @@ add_shapes_from_collision_solids(CollisionNode *cnode) {
CPT(CollisionSphere) sphere = DCAST(CollisionSphere, solid);
CPT(TransformState) ts = TransformState::make_pos(sphere->get_center());
add_shape(BulletSphereShape::make_from_solid(sphere), ts);
do_add_shape(BulletSphereShape::make_from_solid(sphere), ts);
}
// CollisionBox
@ -602,14 +801,14 @@ add_shapes_from_collision_solids(CollisionNode *cnode) {
CPT(CollisionBox) box = DCAST(CollisionBox, solid);
CPT(TransformState) ts = TransformState::make_pos(box->get_center());
add_shape(BulletBoxShape::make_from_solid(box), ts);
do_add_shape(BulletBoxShape::make_from_solid(box), ts);
}
// CollisionPlane
else if (CollisionPlane::get_class_type() == type) {
CPT(CollisionPlane) plane = DCAST(CollisionPlane, solid);
add_shape(BulletPlaneShape::make_from_solid(plane));
do_add_shape(BulletPlaneShape::make_from_solid(plane));
}
// CollisionGeom
@ -625,13 +824,13 @@ add_shapes_from_collision_solids(CollisionNode *cnode) {
LPoint3 p2 = polygon->get_point(i-1);
LPoint3 p3 = polygon->get_point(i);
mesh->add_triangle(p1, p2, p3, true);
mesh->do_add_triangle(p1, p2, p3, true);
}
}
}
if (mesh && mesh->get_num_triangles() > 0) {
add_shape(new BulletTriangleMeshShape(mesh, true));
if (mesh && mesh->do_get_num_triangles() > 0) {
do_add_shape(new BulletTriangleMeshShape(mesh, true));
}
}
@ -651,6 +850,7 @@ set_transform_dirty() {
*/
BoundingSphere BulletBodyNode::
get_shape_bounds() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
/*
btTransform tr;

View File

@ -42,8 +42,8 @@ PUBLISHED:
void add_shape(BulletShape *shape, const TransformState *xform=TransformState::make_identity());
void remove_shape(BulletShape *shape);
INLINE int get_num_shapes() const;
INLINE BulletShape *get_shape(int idx) const;
int get_num_shapes() const;
BulletShape *get_shape(int idx) const;
MAKE_SEQ(get_shapes, get_num_shapes, get_shape);
LPoint3 get_shape_pos(int idx) const;
@ -54,8 +54,8 @@ PUBLISHED:
void add_shapes_from_collision_solids(CollisionNode *cnode);
// Static and kinematic
INLINE bool is_static() const;
INLINE bool is_kinematic() const;
bool is_static() const;
bool is_kinematic() const;
INLINE void set_static(bool value);
INLINE void set_kinematic(bool value);
@ -92,19 +92,19 @@ PUBLISHED:
INLINE bool is_debug_enabled() const;
// Friction and Restitution
INLINE PN_stdfloat get_restitution() const;
INLINE void set_restitution(PN_stdfloat restitution);
PN_stdfloat get_restitution() const;
void set_restitution(PN_stdfloat restitution);
INLINE PN_stdfloat get_friction() const;
INLINE void set_friction(PN_stdfloat friction);
PN_stdfloat get_friction() const;
void set_friction(PN_stdfloat friction);
#if BT_BULLET_VERSION >= 281
INLINE PN_stdfloat get_rolling_friction() const;
INLINE void set_rolling_friction(PN_stdfloat friction);
PN_stdfloat get_rolling_friction() const;
void set_rolling_friction(PN_stdfloat friction);
MAKE_PROPERTY(rolling_friction, get_rolling_friction, set_rolling_friction);
#endif
INLINE bool has_anisotropic_friction() const;
bool has_anisotropic_friction() const;
void set_anisotropic_friction(const LVecBase3 &friction);
LVecBase3 get_anisotropic_friction() const;
@ -151,10 +151,11 @@ public:
virtual bool safe_to_flatten_below() const;
virtual void output(ostream &out) const;
virtual void do_output(ostream &out) const;
protected:
INLINE void set_collision_flag(int flag, bool value);
INLINE bool get_collision_flag(int flag) const;
void set_collision_flag(int flag, bool value);
bool get_collision_flag(int flag) const;
btCollisionShape *_shape;
@ -162,7 +163,9 @@ protected:
BulletShapes _shapes;
private:
virtual void shape_changed();
virtual void do_shape_changed();
void do_add_shape(BulletShape *shape, const TransformState *xform=TransformState::make_identity());
CPT(TransformState) do_get_shape_transform(int idx) const;
static bool is_identity(btTransform &trans);

View File

@ -28,20 +28,3 @@ INLINE BulletBoxShape::
delete _shape;
}
/**
*
*/
INLINE BulletBoxShape::
BulletBoxShape(const BulletBoxShape &copy) :
_shape(copy._shape), _half_extents(copy._half_extents) {
}
/**
*
*/
INLINE void BulletBoxShape::
operator = (const BulletBoxShape &copy) {
_shape = copy._shape;
_half_extents = copy._half_extents;
}

View File

@ -28,6 +28,28 @@ BulletBoxShape(const LVecBase3 &halfExtents) : _half_extents(halfExtents) {
_shape->setUserPointer(this);
}
/**
*
*/
BulletBoxShape::
BulletBoxShape(const BulletBoxShape &copy) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_shape = copy._shape;
_half_extents = copy._half_extents;
}
/**
*
*/
void BulletBoxShape::
operator = (const BulletBoxShape &copy) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_shape = copy._shape;
_half_extents = copy._half_extents;
}
/**
*
*/
@ -42,6 +64,7 @@ ptr() const {
*/
LVecBase3 BulletBoxShape::
get_half_extents_without_margin() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btVector3_to_LVecBase3(_shape->getHalfExtentsWithoutMargin());
}
@ -51,6 +74,7 @@ get_half_extents_without_margin() const {
*/
LVecBase3 BulletBoxShape::
get_half_extents_with_margin() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btVector3_to_LVecBase3(_shape->getHalfExtentsWithMargin());
}

View File

@ -33,8 +33,8 @@ private:
PUBLISHED:
explicit BulletBoxShape(const LVecBase3 &halfExtents);
INLINE BulletBoxShape(const BulletBoxShape &copy);
INLINE void operator = (const BulletBoxShape &copy);
BulletBoxShape(const BulletBoxShape &copy);
void operator = (const BulletBoxShape &copy);
INLINE ~BulletBoxShape();
LVecBase3 get_half_extents_without_margin() const;

View File

@ -30,26 +30,6 @@ INLINE BulletCapsuleShape::
delete _shape;
}
/**
*
*/
INLINE BulletCapsuleShape::
BulletCapsuleShape(const BulletCapsuleShape &copy) :
_shape(copy._shape),
_radius(copy._radius),
_height(copy._height) {
}
/**
*
*/
INLINE void BulletCapsuleShape::
operator = (const BulletCapsuleShape &copy) {
_shape = copy._shape;
_radius = copy._radius;
_height = copy._height;
}
/**
* Returns the radius that was used to construct this capsule.
*/

View File

@ -38,9 +38,35 @@ BulletCapsuleShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) :
break;
}
nassertv(_shape);
_shape->setUserPointer(this);
}
/**
*
*/
BulletCapsuleShape::
BulletCapsuleShape(const BulletCapsuleShape &copy) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_shape = copy._shape;
_radius = copy._radius;
_height = copy._height;
}
/**
*
*/
void BulletCapsuleShape::
operator = (const BulletCapsuleShape &copy) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_shape = copy._shape;
_radius = copy._radius;
_height = copy._height;
}
/**
*
*/
@ -122,6 +148,7 @@ fillin(DatagramIterator &scan, BamReader *manager) {
break;
}
nassertv(_shape);
_shape->setUserPointer(this);
_shape->setMargin(margin);
}

View File

@ -30,8 +30,8 @@ private:
PUBLISHED:
explicit BulletCapsuleShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up=Z_up);
INLINE BulletCapsuleShape(const BulletCapsuleShape &copy);
INLINE void operator = (const BulletCapsuleShape &copy);
BulletCapsuleShape(const BulletCapsuleShape &copy);
void operator = (const BulletCapsuleShape &copy);
INLINE ~BulletCapsuleShape();
INLINE PN_stdfloat get_radius() const;

View File

@ -17,6 +17,8 @@
INLINE BulletCharacterControllerNode::
~BulletCharacterControllerNode() {
delete _character;
delete _ghost;
}
/**

View File

@ -77,6 +77,7 @@ BulletCharacterControllerNode(BulletShape *shape, PN_stdfloat step_height, const
*/
void BulletCharacterControllerNode::
set_linear_movement(const LVector3 &movement, bool is_local) {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertv(!movement.is_nan());
@ -89,18 +90,19 @@ set_linear_movement(const LVector3 &movement, bool is_local) {
*/
void BulletCharacterControllerNode::
set_angular_movement(PN_stdfloat omega) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_angular_movement = omega;
}
/**
*
* Assumes the lock(bullet global lock) is held by the caller
*/
void BulletCharacterControllerNode::
sync_p2b(PN_stdfloat dt, int num_substeps) {
do_sync_p2b(PN_stdfloat dt, int num_substeps) {
// Synchronise global transform
transform_changed();
do_transform_changed();
// Angular rotation
btScalar angle = dt * deg_2_rad(_angular_movement);
@ -131,10 +133,10 @@ sync_p2b(PN_stdfloat dt, int num_substeps) {
}
/**
*
* Assumes the lock(bullet global lock) is held by the caller
*/
void BulletCharacterControllerNode::
sync_b2p() {
do_sync_b2p() {
NodePath np = NodePath::any_path((PandaNode *)this);
LVecBase3 scale = np.get_net_transform()->get_scale();
@ -154,10 +156,10 @@ sync_b2p() {
}
/**
*
* Assumes the lock(bullet global lock) is held by the caller
*/
void BulletCharacterControllerNode::
transform_changed() {
do_transform_changed() {
if (_sync_disable) return;
@ -187,10 +189,23 @@ transform_changed() {
_ghost->getWorldTransform().setBasis(m);
// Set scale
_shape->set_local_scale(scale);
_shape->do_set_local_scale(scale);
}
}
/**
*
*/
void BulletCharacterControllerNode::
transform_changed() {
if (_sync_disable) return;
LightMutexHolder holder(BulletWorld::get_global_lock());
do_transform_changed();
}
/**
*
*/
@ -205,6 +220,7 @@ get_shape() const {
*/
bool BulletCharacterControllerNode::
is_on_ground() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _character->onGround();
}
@ -214,6 +230,7 @@ is_on_ground() const {
*/
bool BulletCharacterControllerNode::
can_jump() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _character->canJump();
}
@ -223,6 +240,7 @@ can_jump() const {
*/
void BulletCharacterControllerNode::
do_jump() {
LightMutexHolder holder(BulletWorld::get_global_lock());
_character->jump();
}
@ -232,6 +250,7 @@ do_jump() {
*/
void BulletCharacterControllerNode::
set_fall_speed(PN_stdfloat fall_speed) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_character->setFallSpeed((btScalar)fall_speed);
}
@ -241,6 +260,7 @@ set_fall_speed(PN_stdfloat fall_speed) {
*/
void BulletCharacterControllerNode::
set_jump_speed(PN_stdfloat jump_speed) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_character->setJumpSpeed((btScalar)jump_speed);
}
@ -250,6 +270,7 @@ set_jump_speed(PN_stdfloat jump_speed) {
*/
void BulletCharacterControllerNode::
set_max_jump_height(PN_stdfloat max_jump_height) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_character->setMaxJumpHeight((btScalar)max_jump_height);
}
@ -259,6 +280,7 @@ set_max_jump_height(PN_stdfloat max_jump_height) {
*/
void BulletCharacterControllerNode::
set_max_slope(PN_stdfloat max_slope) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_character->setMaxSlope((btScalar)max_slope);
}
@ -268,6 +290,7 @@ set_max_slope(PN_stdfloat max_slope) {
*/
PN_stdfloat BulletCharacterControllerNode::
get_max_slope() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_character->getMaxSlope();
}
@ -277,6 +300,8 @@ get_max_slope() const {
*/
PN_stdfloat BulletCharacterControllerNode::
get_gravity() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
#if BT_BULLET_VERSION >= 285
return -(PN_stdfloat)_character->getGravity()[_up];
#else
@ -289,6 +314,8 @@ get_gravity() const {
*/
void BulletCharacterControllerNode::
set_gravity(PN_stdfloat gravity) {
LightMutexHolder holder(BulletWorld::get_global_lock());
#if BT_BULLET_VERSION >= 285
_character->setGravity(up_vectors[_up] * -(btScalar)gravity);
#else
@ -301,6 +328,7 @@ set_gravity(PN_stdfloat gravity) {
*/
void BulletCharacterControllerNode::
set_use_ghost_sweep_test(bool value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _character->setUseGhostSweepTest(value);
}
}

View File

@ -64,8 +64,8 @@ public:
INLINE virtual btPairCachingGhostObject *get_ghost() const;
INLINE virtual btCharacterControllerInterface *get_character() const;
virtual void sync_p2b(PN_stdfloat dt, int num_substeps);
virtual void sync_b2p();
virtual void do_sync_p2b(PN_stdfloat dt, int num_substeps);
virtual void do_sync_b2p();
protected:
virtual void transform_changed();
@ -85,6 +85,8 @@ private:
bool _linear_movement_is_local;
PN_stdfloat _angular_movement;
void do_transform_changed();
public:
static TypeHandle get_class_type() {
return _type_handle;

View File

@ -30,26 +30,6 @@ INLINE BulletConeShape::
delete _shape;
}
/**
*
*/
INLINE BulletConeShape::
BulletConeShape(const BulletConeShape &copy) :
_shape(copy._shape),
_radius(copy._radius),
_height(copy._height) {
}
/**
*
*/
INLINE void BulletConeShape::
operator = (const BulletConeShape &copy) {
_shape = copy._shape;
_radius = copy._radius;
_height = copy._height;
}
/**
* Returns the radius that was passed into the constructor.
*/

View File

@ -38,9 +38,34 @@ BulletConeShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) :
break;
}
nassertv(_shape);
_shape->setUserPointer(this);
}
/**
*
*/
BulletConeShape::
BulletConeShape(const BulletConeShape &copy) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_shape = copy._shape;
_radius = copy._radius;
_height = copy._height;
}
/**
*
*/
void BulletConeShape::
operator = (const BulletConeShape &copy) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_shape = copy._shape;
_radius = copy._radius;
_height = copy._height;
}
/**
*
*/
@ -122,6 +147,7 @@ fillin(DatagramIterator &scan, BamReader *manager) {
break;
}
nassertv(_shape);
_shape->setUserPointer(this);
_shape->setMargin(margin);
}

View File

@ -30,8 +30,8 @@ private:
PUBLISHED:
explicit BulletConeShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up=Z_up);
INLINE BulletConeShape(const BulletConeShape &copy);
INLINE void operator = (const BulletConeShape &copy);
BulletConeShape(const BulletConeShape &copy);
void operator = (const BulletConeShape &copy);
INLINE ~BulletConeShape();
INLINE PN_stdfloat get_radius() const;

View File

@ -19,21 +19,3 @@ INLINE BulletConeTwistConstraint::
delete _constraint;
}
/**
*
*/
INLINE CPT(TransformState) BulletConeTwistConstraint::
get_frame_a() const {
return btTrans_to_TransformState(_constraint->getAFrame());
}
/**
*
*/
INLINE CPT(TransformState) BulletConeTwistConstraint::
get_frame_b() const {
return btTrans_to_TransformState(_constraint->getBFrame());
}

View File

@ -63,6 +63,7 @@ ptr() const {
*/
void BulletConeTwistConstraint::
set_limit(int index, PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
value = deg_2_rad(value);
@ -74,6 +75,7 @@ set_limit(int index, PN_stdfloat value) {
*/
void BulletConeTwistConstraint::
set_limit(PN_stdfloat swing1, PN_stdfloat swing2, PN_stdfloat twist, PN_stdfloat softness, PN_stdfloat bias, PN_stdfloat relaxation) {
LightMutexHolder holder(BulletWorld::get_global_lock());
swing1 = deg_2_rad(swing1);
swing2 = deg_2_rad(swing2);
@ -87,6 +89,7 @@ set_limit(PN_stdfloat swing1, PN_stdfloat swing2, PN_stdfloat twist, PN_stdfloat
*/
void BulletConeTwistConstraint::
set_damping(PN_stdfloat damping) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_constraint->setDamping(damping);
}
@ -96,6 +99,7 @@ set_damping(PN_stdfloat damping) {
*/
PN_stdfloat BulletConeTwistConstraint::
get_fix_threshold() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _constraint->getFixThresh();
}
@ -105,6 +109,7 @@ get_fix_threshold() const {
*/
void BulletConeTwistConstraint::
set_fix_threshold(PN_stdfloat threshold) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_constraint->setFixThresh(threshold);
}
@ -114,6 +119,7 @@ set_fix_threshold(PN_stdfloat threshold) {
*/
void BulletConeTwistConstraint::
enable_motor(bool enable) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_constraint->enableMotor(enable);
}
@ -123,6 +129,7 @@ enable_motor(bool enable) {
*/
void BulletConeTwistConstraint::
set_max_motor_impulse(PN_stdfloat max_impulse) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_constraint->setMaxMotorImpulse(max_impulse);
}
@ -132,6 +139,7 @@ set_max_motor_impulse(PN_stdfloat max_impulse) {
*/
void BulletConeTwistConstraint::
set_max_motor_impulse_normalized(PN_stdfloat max_impulse) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_constraint->setMaxMotorImpulseNormalized(max_impulse);
}
@ -141,6 +149,7 @@ set_max_motor_impulse_normalized(PN_stdfloat max_impulse) {
*/
void BulletConeTwistConstraint::
set_motor_target(const LQuaternion &quat) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_constraint->setMotorTarget(LQuaternion_to_btQuat(quat));
}
@ -150,6 +159,7 @@ set_motor_target(const LQuaternion &quat) {
*/
void BulletConeTwistConstraint::
set_motor_target_in_constraint_space(const LQuaternion &quat) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_constraint->setMotorTargetInConstraintSpace(LQuaternion_to_btQuat(quat));
}
@ -159,9 +169,30 @@ set_motor_target_in_constraint_space(const LQuaternion &quat) {
*/
void BulletConeTwistConstraint::
set_frames(const TransformState *ts_a, const TransformState *ts_b) {
LightMutexHolder holder(BulletWorld::get_global_lock());
btTransform frame_a = TransformState_to_btTrans(ts_a);
btTransform frame_b = TransformState_to_btTrans(ts_b);
_constraint->setFrames(frame_a, frame_b);
}
/**
*
*/
CPT(TransformState) BulletConeTwistConstraint::
get_frame_a() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btTrans_to_TransformState(_constraint->getAFrame());
}
/**
*
*/
CPT(TransformState) BulletConeTwistConstraint::
get_frame_b() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btTrans_to_TransformState(_constraint->getBFrame());
}

View File

@ -53,8 +53,8 @@ PUBLISHED:
void set_motor_target_in_constraint_space(const LQuaternion &quat);
void set_frames(const TransformState *ts_a, const TransformState *ts_b);
INLINE CPT(TransformState) get_frame_a() const;
INLINE CPT(TransformState) get_frame_b() const;
CPT(TransformState) get_frame_a() const;
CPT(TransformState) get_frame_b() const;
MAKE_PROPERTY(fix_threshold, get_fix_threshold, set_fix_threshold);
MAKE_PROPERTY(frame_a, get_frame_a);

View File

@ -19,19 +19,3 @@ INLINE BulletConvexHullShape::
delete _shape;
}
/**
*
*/
INLINE BulletConvexHullShape::
BulletConvexHullShape(const BulletConvexHullShape &copy) :
_shape(copy._shape) {
}
/**
*
*/
INLINE void BulletConvexHullShape::
operator = (const BulletConvexHullShape &copy) {
_shape = copy._shape;
}

View File

@ -29,6 +29,26 @@ BulletConvexHullShape() {
_shape->setUserPointer(this);
}
/**
*
*/
BulletConvexHullShape::
BulletConvexHullShape(const BulletConvexHullShape &copy) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_shape = copy._shape;
}
/**
*
*/
void BulletConvexHullShape::
operator = (const BulletConvexHullShape &copy) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_shape = copy._shape;
}
/**
*
*/
@ -43,6 +63,7 @@ ptr() const {
*/
void BulletConvexHullShape::
add_point(const LPoint3 &p) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_shape->addPoint(LVecBase3_to_btVector3(p));
}
@ -52,6 +73,10 @@ add_point(const LPoint3 &p) {
*/
void BulletConvexHullShape::
add_array(const PTA_LVecBase3 &points) {
LightMutexHolder holder(BulletWorld::get_global_lock());
if (_shape)
delete _shape;
_shape = new btConvexHullShape(NULL, 0);
_shape->setUserPointer(this);
@ -75,6 +100,7 @@ add_array(const PTA_LVecBase3 &points) {
*/
void BulletConvexHullShape::
add_geom(const Geom *geom, const TransformState *ts) {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertv(geom);
nassertv(ts);

View File

@ -29,8 +29,8 @@
class EXPCL_PANDABULLET BulletConvexHullShape : public BulletShape {
PUBLISHED:
BulletConvexHullShape();
INLINE BulletConvexHullShape(const BulletConvexHullShape &copy);
INLINE void operator = (const BulletConvexHullShape &copy);
BulletConvexHullShape(const BulletConvexHullShape &copy);
void operator = (const BulletConvexHullShape &copy);
INLINE ~BulletConvexHullShape();
void add_point(const LPoint3 &p);

View File

@ -28,30 +28,3 @@ INLINE BulletConvexPointCloudShape::
delete _shape;
}
/**
*
*/
INLINE BulletConvexPointCloudShape::
BulletConvexPointCloudShape(const BulletConvexPointCloudShape &copy) :
_scale(copy._scale),
_shape(copy._shape) {
}
/**
*
*/
INLINE void BulletConvexPointCloudShape::
operator = (const BulletConvexPointCloudShape &copy) {
_scale = copy._scale;
_shape = copy._shape;
}
/**
*
*/
INLINE int BulletConvexPointCloudShape::
get_num_points() const {
return _shape->getNumPoints();
}

View File

@ -84,6 +84,38 @@ BulletConvexPointCloudShape(const Geom *geom, LVecBase3 scale) {
_shape->setUserPointer(this);
}
/**
*
*/
BulletConvexPointCloudShape::
BulletConvexPointCloudShape(const BulletConvexPointCloudShape &copy) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_scale = copy._scale;
_shape = copy._shape;
}
/**
*
*/
void BulletConvexPointCloudShape::
operator = (const BulletConvexPointCloudShape &copy) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_scale = copy._scale;
_shape = copy._shape;
}
/**
*
*/
int BulletConvexPointCloudShape::
get_num_points() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _shape->getNumPoints();
}
/**
* Tells the BamReader how to create objects of type BulletShape.
*/

View File

@ -33,11 +33,11 @@ private:
PUBLISHED:
explicit BulletConvexPointCloudShape(const PTA_LVecBase3 &points, LVecBase3 scale=LVecBase3(1.));
explicit BulletConvexPointCloudShape(const Geom *geom, LVecBase3 scale=LVecBase3(1.));
INLINE BulletConvexPointCloudShape(const BulletConvexPointCloudShape &copy);
INLINE void operator = (const BulletConvexPointCloudShape &copy);
BulletConvexPointCloudShape(const BulletConvexPointCloudShape &copy);
void operator = (const BulletConvexPointCloudShape &copy);
INLINE ~BulletConvexPointCloudShape();
INLINE int get_num_points() const;
int get_num_points() const;
MAKE_PROPERTY(num_points, get_num_points);

View File

@ -28,47 +28,3 @@ INLINE BulletCylinderShape::
delete _shape;
}
/**
*
*/
INLINE BulletCylinderShape::
BulletCylinderShape(const BulletCylinderShape &copy) :
_shape(copy._shape), _half_extents(copy._half_extents) {
}
/**
*
*/
INLINE void BulletCylinderShape::
operator = (const BulletCylinderShape &copy) {
_shape = copy._shape;
_half_extents = copy._half_extents;
}
/**
*
*/
INLINE PN_stdfloat BulletCylinderShape::
get_radius() const {
return (PN_stdfloat)_shape->getRadius();
}
/**
*
*/
INLINE LVecBase3 BulletCylinderShape::
get_half_extents_without_margin() const {
return btVector3_to_LVecBase3(_shape->getHalfExtentsWithoutMargin());
}
/**
*
*/
INLINE LVecBase3 BulletCylinderShape::
get_half_extents_with_margin() const {
return btVector3_to_LVecBase3(_shape->getHalfExtentsWithMargin());
}

View File

@ -39,6 +39,7 @@ BulletCylinderShape(const LVector3 &half_extents, BulletUpAxis up) :
break;
}
nassertv(_shape);
_shape->setUserPointer(this);
}
@ -66,9 +67,32 @@ BulletCylinderShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) {
break;
}
nassertv(_shape);
_shape->setUserPointer(this);
}
/**
*
*/
BulletCylinderShape::
BulletCylinderShape(const BulletCylinderShape &copy) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_shape = copy._shape;
_half_extents = copy._half_extents;
}
/**
*
*/
void BulletCylinderShape::
operator = (const BulletCylinderShape &copy) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_shape = copy._shape;
_half_extents = copy._half_extents;
}
/**
*
*/
@ -78,6 +102,36 @@ ptr() const {
return _shape;
}
/**
*
*/
PN_stdfloat BulletCylinderShape::
get_radius() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_shape->getRadius();
}
/**
*
*/
LVecBase3 BulletCylinderShape::
get_half_extents_without_margin() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btVector3_to_LVecBase3(_shape->getHalfExtentsWithoutMargin());
}
/**
*
*/
LVecBase3 BulletCylinderShape::
get_half_extents_with_margin() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btVector3_to_LVecBase3(_shape->getHalfExtentsWithMargin());
}
/**
* Tells the BamReader how to create objects of type BulletShape.
*/
@ -150,6 +204,7 @@ fillin(DatagramIterator &scan, BamReader *manager) {
break;
}
nassertv(_shape);
_shape->setUserPointer(this);
_shape->setMargin(margin);
}

View File

@ -31,13 +31,13 @@ private:
PUBLISHED:
explicit BulletCylinderShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up=Z_up);
explicit BulletCylinderShape(const LVector3 &half_extents, BulletUpAxis up=Z_up);
INLINE BulletCylinderShape(const BulletCylinderShape &copy);
INLINE void operator = (const BulletCylinderShape &copy);
BulletCylinderShape(const BulletCylinderShape &copy);
void operator = (const BulletCylinderShape &copy);
INLINE ~BulletCylinderShape();
INLINE PN_stdfloat get_radius() const;
INLINE LVecBase3 get_half_extents_without_margin() const;
INLINE LVecBase3 get_half_extents_with_margin() const;
PN_stdfloat get_radius() const;
LVecBase3 get_half_extents_without_margin() const;
LVecBase3 get_half_extents_with_margin() const;
MAKE_PROPERTY(radius, get_radius);
MAKE_PROPERTY(half_extents_without_margin, get_half_extents_without_margin);

View File

@ -169,7 +169,7 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) {
PT(Geom) debug_triangles;
{
LightMutexHolder holder(_lock);
LightMutexHolder holder(BulletWorld::get_global_lock());
if (_debug_world == nullptr) {
return;
}
@ -270,8 +270,7 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) {
*
*/
void BulletDebugNode::
sync_b2p(btDynamicsWorld *world) {
LightMutexHolder holder(_lock);
do_sync_b2p(btDynamicsWorld *world) {
_debug_world = world;
_debug_stale = true;

View File

@ -17,7 +17,6 @@
#include "pandabase.h"
#include "bullet_includes.h"
#include "lightMutex.h"
/**
*
@ -55,7 +54,7 @@ public:
virtual void add_for_draw(CullTraverser *trav, CullTraverserData &data);
private:
void sync_b2p(btDynamicsWorld *world);
void do_sync_b2p(btDynamicsWorld *world);
struct Line {
LVecBase3 _p0;
@ -101,7 +100,6 @@ private:
int _mode;
};
LightMutex _lock;
DebugDraw _drawer;
bool _debug_stale;

View File

@ -19,21 +19,3 @@ INLINE BulletGenericConstraint::
delete _constraint;
}
/**
*
*/
INLINE CPT(TransformState) BulletGenericConstraint::
get_frame_a() const {
return btTrans_to_TransformState(_constraint->getFrameOffsetA());
}
/**
*
*/
INLINE CPT(TransformState) BulletGenericConstraint::
get_frame_b() const {
return btTrans_to_TransformState(_constraint->getFrameOffsetB());
}

View File

@ -63,6 +63,7 @@ ptr() const {
*/
LVector3 BulletGenericConstraint::
get_axis(int axis) const {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertr(axis >= 0, LVector3::zero());
nassertr(axis <= 3, LVector3::zero());
@ -76,6 +77,7 @@ get_axis(int axis) const {
*/
PN_stdfloat BulletGenericConstraint::
get_pivot(int axis) const {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertr(axis >= 0, 0.0f);
nassertr(axis <= 3, 0.0f);
@ -89,6 +91,7 @@ get_pivot(int axis) const {
*/
PN_stdfloat BulletGenericConstraint::
get_angle(int axis) const {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertr(axis >= 0, 0.0f);
nassertr(axis <= 3, 0.0f);
@ -102,6 +105,7 @@ get_angle(int axis) const {
*/
void BulletGenericConstraint::
set_linear_limit(int axis, PN_stdfloat low, PN_stdfloat high) {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertv(axis >= 0);
nassertv(axis <= 3);
@ -115,6 +119,7 @@ set_linear_limit(int axis, PN_stdfloat low, PN_stdfloat high) {
*/
void BulletGenericConstraint::
set_angular_limit(int axis, PN_stdfloat low, PN_stdfloat high) {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertv(axis >= 0);
nassertv(axis <= 3);
@ -126,11 +131,32 @@ set_angular_limit(int axis, PN_stdfloat low, PN_stdfloat high) {
_constraint->setLimit(axis + 3, low, high);
}
/**
*
*/
CPT(TransformState) BulletGenericConstraint::
get_frame_a() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btTrans_to_TransformState(_constraint->getFrameOffsetA());
}
/**
*
*/
CPT(TransformState) BulletGenericConstraint::
get_frame_b() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btTrans_to_TransformState(_constraint->getFrameOffsetB());
}
/**
*
*/
BulletRotationalLimitMotor BulletGenericConstraint::
get_rotational_limit_motor(int axis) {
LightMutexHolder holder(BulletWorld::get_global_lock());
return BulletRotationalLimitMotor(*_constraint->getRotationalLimitMotor(axis));
}
@ -140,6 +166,7 @@ get_rotational_limit_motor(int axis) {
*/
BulletTranslationalLimitMotor BulletGenericConstraint::
get_translational_limit_motor() {
LightMutexHolder holder(BulletWorld::get_global_lock());
return BulletTranslationalLimitMotor(*_constraint->getTranslationalLimitMotor());
}
@ -149,6 +176,7 @@ get_translational_limit_motor() {
*/
void BulletGenericConstraint::
set_frames(const TransformState *ts_a, const TransformState *ts_b) {
LightMutexHolder holder(BulletWorld::get_global_lock());
btTransform frame_a = TransformState_to_btTrans(ts_a);
btTransform frame_b = TransformState_to_btTrans(ts_b);

View File

@ -57,8 +57,8 @@ PUBLISHED:
// Frames
void set_frames(const TransformState *ts_a, const TransformState *ts_b);
INLINE CPT(TransformState) get_frame_a() const;
INLINE CPT(TransformState) get_frame_b() const;
CPT(TransformState) get_frame_a() const;
CPT(TransformState) get_frame_b() const;
MAKE_PROPERTY(translational_limit_motor, get_translational_limit_motor);
MAKE_PROPERTY(frame_a, get_frame_a);

View File

@ -20,23 +20,3 @@ INLINE BulletGhostNode::
delete _ghost;
}
/**
*
*/
INLINE int BulletGhostNode::
get_num_overlapping_nodes() const {
return _ghost->getNumOverlappingObjects();
}
/**
*
*/
INLINE PandaNode *BulletGhostNode::
get_overlapping_node(int idx) const {
nassertr(idx >=0 && idx < _ghost->getNumOverlappingObjects(), NULL);
btCollisionObject *object = _ghost->getOverlappingObject(idx);
return (object) ? (PandaNode *)object->getUserPointer() : NULL;
}

View File

@ -53,6 +53,7 @@ get_object() const {
*/
void BulletGhostNode::
parents_changed() {
LightMutexHolder holder(BulletWorld::get_global_lock());
Parents parents = get_parents();
for (size_t i = 0; i < parents.get_num_parents(); ++i) {
@ -73,10 +74,10 @@ parents_changed() {
}
/**
*
* Assumes the lock(bullet global lock) is held by the caller
*/
void BulletGhostNode::
transform_changed() {
do_transform_changed() {
if (_sync_disable) return;
@ -98,27 +99,60 @@ transform_changed() {
if (!scale.almost_equal(LVecBase3(1.0f, 1.0f, 1.0f))) {
for (int i=0; i<get_num_shapes(); i++) {
PT(BulletShape) shape = _shapes[i];
shape->set_local_scale(scale);
shape->do_set_local_scale(scale);
}
}
}
}
}
/**
*
*/
void BulletGhostNode::
sync_p2b() {
transform_changed() {
transform_changed();
if (_sync_disable) return;
LightMutexHolder holder(BulletWorld::get_global_lock());
do_transform_changed();
}
/**
*
*/
int BulletGhostNode::
get_num_overlapping_nodes() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _ghost->getNumOverlappingObjects();
}
/**
*
*/
PandaNode *BulletGhostNode::
get_overlapping_node(int idx) const {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertr(idx >=0 && idx < _ghost->getNumOverlappingObjects(), NULL);
btCollisionObject *object = _ghost->getOverlappingObject(idx);
return (object) ? (PandaNode *)object->getUserPointer() : NULL;
}
/**
* Assumes the lock(bullet global lock) is held by the caller
*/
void BulletGhostNode::
sync_b2p() {
do_sync_p2b() {
do_transform_changed();
}
/**
* Assumes the lock(bullet global lock) is held by the caller
*/
void BulletGhostNode::
do_sync_b2p() {
NodePath np = NodePath::any_path((PandaNode *)this);
LVecBase3 scale = np.get_net_transform()->get_scale();

View File

@ -34,8 +34,8 @@ PUBLISHED:
INLINE ~BulletGhostNode();
// Overlapping
INLINE int get_num_overlapping_nodes() const;
INLINE PandaNode *get_overlapping_node(int idx) const;
int get_num_overlapping_nodes() const;
PandaNode *get_overlapping_node(int idx) const;
MAKE_SEQ(get_overlapping_nodes, get_num_overlapping_nodes, get_overlapping_node);
MAKE_SEQ_PROPERTY(overlapping_nodes, get_num_overlapping_nodes, get_overlapping_node);
@ -43,8 +43,8 @@ PUBLISHED:
public:
virtual btCollisionObject *get_object() const;
void sync_p2b();
void sync_b2p();
void do_sync_p2b();
void do_sync_b2p();
protected:
virtual void parents_changed();
@ -57,6 +57,8 @@ private:
btPairCachingGhostObject *_ghost;
void do_transform_changed();
public:
static TypeHandle get_class_type() {
return _type_handle;

View File

@ -32,33 +32,3 @@ INLINE BulletHeightfieldShape::
delete _shape;
delete [] _data;
}
/**
*
*/
INLINE BulletHeightfieldShape::
BulletHeightfieldShape(const BulletHeightfieldShape &copy) :
_shape(copy._shape),
_num_rows(copy._num_rows),
_num_cols(copy._num_cols),
_max_height(copy._max_height),
_up(copy._up) {
size_t size = (size_t)_num_rows * (size_t)_num_cols;
_data = new btScalar[size];
memcpy(_data, copy._data, size * sizeof(btScalar));
}
/**
*
*/
INLINE void BulletHeightfieldShape::
operator = (const BulletHeightfieldShape &copy) {
_shape = copy._shape;
_num_rows = copy._num_rows;
_num_cols = copy._num_cols;
size_t size = (size_t)_num_rows * (size_t)_num_cols;
_data = new btScalar[size];
memcpy(_data, copy._data, size * sizeof(btScalar));
}

View File

@ -61,6 +61,7 @@ ptr() const {
*/
void BulletHeightfieldShape::
set_use_diamond_subdivision(bool flag) {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _shape->setUseDiamondSubdivision(flag);
}
@ -104,6 +105,42 @@ BulletHeightfieldShape(Texture *tex, PN_stdfloat max_height, BulletUpAxis up) :
_shape->setUserPointer(this);
}
/**
*
*/
BulletHeightfieldShape::
BulletHeightfieldShape(const BulletHeightfieldShape &copy) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_shape = copy._shape;
_num_rows = copy._num_rows;
_num_cols = copy._num_cols;
_max_height = copy._max_height;
_up = copy._up;
size_t size = (size_t)_num_rows * (size_t)_num_cols;
_data = new btScalar[size];
memcpy(_data, copy._data, size * sizeof(btScalar));
}
/**
*
*/
void BulletHeightfieldShape::
operator = (const BulletHeightfieldShape &copy) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_shape = copy._shape;
_num_rows = copy._num_rows;
_num_cols = copy._num_cols;
_max_height = copy._max_height;
_up = copy._up;
size_t size = (size_t)_num_rows * (size_t)_num_cols;
_data = new btScalar[size];
memcpy(_data, copy._data, size * sizeof(btScalar));
}
/**
* Tells the BamReader how to create objects of type BulletShape.
*/
@ -169,8 +206,9 @@ fillin(DatagramIterator &scan, BamReader *manager) {
_num_cols = scan.get_int32();
size_t size = (size_t)_num_rows * (size_t)_num_cols;
delete[] _data;
delete [] _data;
_data = new float[size];
for (size_t i = 0; i < size; ++i) {
_data[i] = scan.get_stdfloat();
}

View File

@ -34,8 +34,8 @@ private:
PUBLISHED:
explicit BulletHeightfieldShape(const PNMImage &image, PN_stdfloat max_height, BulletUpAxis up=Z_up);
explicit BulletHeightfieldShape(Texture *tex, PN_stdfloat max_height, BulletUpAxis up=Z_up);
INLINE BulletHeightfieldShape(const BulletHeightfieldShape &copy);
INLINE void operator = (const BulletHeightfieldShape &copy);
BulletHeightfieldShape(const BulletHeightfieldShape &copy);
void operator = (const BulletHeightfieldShape &copy);
INLINE ~BulletHeightfieldShape();
void set_use_diamond_subdivision(bool flag=true);

View File

@ -19,21 +19,3 @@ INLINE BulletHingeConstraint::
delete _constraint;
}
/**
*
*/
INLINE CPT(TransformState) BulletHingeConstraint::
get_frame_a() const {
return btTrans_to_TransformState(_constraint->getAFrame());
}
/**
*
*/
INLINE CPT(TransformState) BulletHingeConstraint::
get_frame_b() const {
return btTrans_to_TransformState(_constraint->getBFrame());
}

View File

@ -111,6 +111,7 @@ ptr() const {
*/
void BulletHingeConstraint::
set_angular_only(bool value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _constraint->setAngularOnly(value);
}
@ -120,6 +121,7 @@ set_angular_only(bool value) {
*/
bool BulletHingeConstraint::
get_angular_only() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _constraint->getAngularOnly();
}
@ -129,6 +131,7 @@ get_angular_only() const {
*/
void BulletHingeConstraint::
set_limit(PN_stdfloat low, PN_stdfloat high, PN_stdfloat softness, PN_stdfloat bias, PN_stdfloat relaxation) {
LightMutexHolder holder(BulletWorld::get_global_lock());
low = deg_2_rad(low);
high = deg_2_rad(high);
@ -141,6 +144,7 @@ set_limit(PN_stdfloat low, PN_stdfloat high, PN_stdfloat softness, PN_stdfloat b
*/
void BulletHingeConstraint::
set_axis(const LVector3 &axis) {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertv(!axis.is_nan());
@ -153,6 +157,7 @@ set_axis(const LVector3 &axis) {
*/
PN_stdfloat BulletHingeConstraint::
get_lower_limit() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return rad_2_deg(_constraint->getLowerLimit());
}
@ -162,6 +167,7 @@ get_lower_limit() const {
*/
PN_stdfloat BulletHingeConstraint::
get_upper_limit() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return rad_2_deg(_constraint->getUpperLimit());
}
@ -171,6 +177,7 @@ get_upper_limit() const {
*/
PN_stdfloat BulletHingeConstraint::
get_hinge_angle() {
LightMutexHolder holder(BulletWorld::get_global_lock());
return rad_2_deg(_constraint->getHingeAngle());
}
@ -184,6 +191,7 @@ get_hinge_angle() {
*/
void BulletHingeConstraint::
enable_angular_motor(bool enable, PN_stdfloat target_velocity, PN_stdfloat max_impulse) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_constraint->enableAngularMotor(enable, target_velocity, max_impulse);
}
@ -193,6 +201,7 @@ enable_angular_motor(bool enable, PN_stdfloat target_velocity, PN_stdfloat max_i
*/
void BulletHingeConstraint::
enable_motor(bool enable) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_constraint->enableMotor(enable);
}
@ -203,6 +212,7 @@ enable_motor(bool enable) {
*/
void BulletHingeConstraint::
set_max_motor_impulse(PN_stdfloat max_impulse) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_constraint->setMaxMotorImpulse(max_impulse);
}
@ -212,6 +222,7 @@ set_max_motor_impulse(PN_stdfloat max_impulse) {
*/
void BulletHingeConstraint::
set_motor_target(const LQuaternion &quat, PN_stdfloat dt) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_constraint->setMotorTarget(LQuaternion_to_btQuat(quat), dt);
}
@ -221,6 +232,7 @@ set_motor_target(const LQuaternion &quat, PN_stdfloat dt) {
*/
void BulletHingeConstraint::
set_motor_target(PN_stdfloat target_angle, PN_stdfloat dt) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_constraint->setMotorTarget(target_angle, dt);
}
@ -230,9 +242,30 @@ set_motor_target(PN_stdfloat target_angle, PN_stdfloat dt) {
*/
void BulletHingeConstraint::
set_frames(const TransformState *ts_a, const TransformState *ts_b) {
LightMutexHolder holder(BulletWorld::get_global_lock());
btTransform frame_a = TransformState_to_btTrans(ts_a);
btTransform frame_b = TransformState_to_btTrans(ts_b);
_constraint->setFrames(frame_a, frame_b);
}
/**
*
*/
CPT(TransformState) BulletHingeConstraint::
get_frame_a() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btTrans_to_TransformState(_constraint->getAFrame());
}
/**
*
*/
CPT(TransformState) BulletHingeConstraint::
get_frame_b() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btTrans_to_TransformState(_constraint->getBFrame());
}

View File

@ -69,8 +69,8 @@ PUBLISHED:
void set_motor_target(PN_stdfloat target_angle, PN_stdfloat dt);
void set_frames(const TransformState *ts_a, const TransformState *ts_b);
INLINE CPT(TransformState) get_frame_a() const;
INLINE CPT(TransformState) get_frame_b() const;
CPT(TransformState) get_frame_a() const;
CPT(TransformState) get_frame_b() const;
MAKE_PROPERTY(hinge_angle, get_hinge_angle);
MAKE_PROPERTY(lower_limit, get_lower_limit);

View File

@ -18,228 +18,3 @@ INLINE BulletManifoldPoint::
~BulletManifoldPoint() {
}
/**
*
*/
INLINE void BulletManifoldPoint::
set_lateral_friction_initialized(bool value) {
#if BT_BULLET_VERSION >= 285
if (value) {
_pt.m_contactPointFlags |= BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED;
} else {
_pt.m_contactPointFlags &= ~BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED;
}
#else
_pt.m_lateralFrictionInitialized = value;
#endif
}
/**
*
*/
INLINE bool BulletManifoldPoint::
get_lateral_friction_initialized() const {
#if BT_BULLET_VERSION >= 285
return (_pt.m_contactPointFlags & BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED) != 0;
#else
return _pt.m_lateralFrictionInitialized;
#endif
}
/**
*
*/
INLINE void BulletManifoldPoint::
set_lateral_friction_dir1(const LVecBase3 &dir) {
_pt.m_lateralFrictionDir1 = LVecBase3_to_btVector3(dir);
}
/**
*
*/
INLINE LVector3 BulletManifoldPoint::
get_lateral_friction_dir1() const {
return btVector3_to_LVector3(_pt.m_lateralFrictionDir1);
}
/**
*
*/
INLINE void BulletManifoldPoint::
set_lateral_friction_dir2(const LVecBase3 &dir) {
_pt.m_lateralFrictionDir2 = LVecBase3_to_btVector3(dir);
}
/**
*
*/
INLINE LVector3 BulletManifoldPoint::
get_lateral_friction_dir2() const {
return btVector3_to_LVector3(_pt.m_lateralFrictionDir2);
}
/**
*
*/
INLINE void BulletManifoldPoint::
set_contact_motion1(PN_stdfloat value) {
_pt.m_contactMotion1 = (btScalar)value;
}
/**
*
*/
INLINE PN_stdfloat BulletManifoldPoint::
get_contact_motion1() const {
return (PN_stdfloat)_pt.m_contactMotion1;
}
/**
*
*/
INLINE void BulletManifoldPoint::
set_contact_motion2(PN_stdfloat value) {
_pt.m_contactMotion2 = (btScalar)value;
}
/**
*
*/
INLINE PN_stdfloat BulletManifoldPoint::
get_contact_motion2() const {
return (PN_stdfloat)_pt.m_contactMotion2;
}
/**
*
*/
INLINE void BulletManifoldPoint::
set_combined_friction(PN_stdfloat value) {
_pt.m_combinedFriction = (btScalar)value;
}
/**
*
*/
INLINE PN_stdfloat BulletManifoldPoint::
get_combined_friction() const {
return (PN_stdfloat)_pt.m_combinedFriction;
}
/**
*
*/
INLINE void BulletManifoldPoint::
set_combined_restitution(PN_stdfloat value) {
_pt.m_combinedRestitution = (btScalar)value;
}
/**
*
*/
INLINE PN_stdfloat BulletManifoldPoint::
get_combined_restitution() const {
return (PN_stdfloat)_pt.m_combinedRestitution;
}
/**
*
*/
INLINE void BulletManifoldPoint::
set_applied_impulse(PN_stdfloat value) {
_pt.m_appliedImpulse = (btScalar)value;
}
/**
*
*/
INLINE void BulletManifoldPoint::
set_applied_impulse_lateral1(PN_stdfloat value) {
_pt.m_appliedImpulseLateral1 = (btScalar)value;
}
/**
*
*/
INLINE PN_stdfloat BulletManifoldPoint::
get_applied_impulse_lateral1() const {
return (PN_stdfloat)_pt.m_appliedImpulseLateral1;
}
/**
*
*/
INLINE void BulletManifoldPoint::
set_applied_impulse_lateral2(PN_stdfloat value) {
_pt.m_appliedImpulseLateral2 = (btScalar)value;
}
/**
*
*/
INLINE PN_stdfloat BulletManifoldPoint::
get_applied_impulse_lateral2() const {
return (PN_stdfloat)_pt.m_appliedImpulseLateral2;
}
/**
*
*/
INLINE void BulletManifoldPoint::
set_contact_cfm1(PN_stdfloat value) {
#if BT_BULLET_VERSION < 285
_pt.m_contactCFM1 = (btScalar)value;
#endif
}
/**
*
*/
INLINE PN_stdfloat BulletManifoldPoint::
get_contact_cfm1() const {
#if BT_BULLET_VERSION < 285
return (PN_stdfloat)_pt.m_contactCFM1;
#else
return 0;
#endif
}
/**
*
*/
INLINE void BulletManifoldPoint::
set_contact_cfm2(PN_stdfloat value) {
#if BT_BULLET_VERSION < 285
_pt.m_contactCFM2 = (btScalar)value;
#endif
}
/**
*
*/
INLINE PN_stdfloat BulletManifoldPoint::
get_contact_cfm2() const {
#if BT_BULLET_VERSION < 285
return (PN_stdfloat)_pt.m_contactCFM2;
#else
return 0;
#endif
}

View File

@ -46,6 +46,7 @@ operator=(const BulletManifoldPoint& other) {
*/
int BulletManifoldPoint::
get_life_time() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _pt.getLifeTime();
}
@ -55,6 +56,7 @@ get_life_time() const {
*/
PN_stdfloat BulletManifoldPoint::
get_distance() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_pt.getDistance();
}
@ -64,6 +66,7 @@ get_distance() const {
*/
PN_stdfloat BulletManifoldPoint::
get_applied_impulse() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_pt.getAppliedImpulse();
}
@ -73,6 +76,7 @@ get_applied_impulse() const {
*/
LPoint3 BulletManifoldPoint::
get_position_world_on_a() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btVector3_to_LPoint3(_pt.getPositionWorldOnA());
}
@ -82,6 +86,7 @@ get_position_world_on_a() const {
*/
LPoint3 BulletManifoldPoint::
get_position_world_on_b() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btVector3_to_LPoint3(_pt.getPositionWorldOnB());
}
@ -91,6 +96,7 @@ get_position_world_on_b() const {
*/
LVector3 BulletManifoldPoint::
get_normal_world_on_b() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btVector3_to_LVector3(_pt.m_normalWorldOnB);
}
@ -100,6 +106,7 @@ get_normal_world_on_b() const {
*/
LPoint3 BulletManifoldPoint::
get_local_point_a() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btVector3_to_LPoint3(_pt.m_localPointA);
}
@ -109,6 +116,7 @@ get_local_point_a() const {
*/
LPoint3 BulletManifoldPoint::
get_local_point_b() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btVector3_to_LPoint3(_pt.m_localPointB);
}
@ -118,6 +126,7 @@ get_local_point_b() const {
*/
int BulletManifoldPoint::
get_part_id0() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _pt.m_partId0;
}
@ -127,6 +136,7 @@ get_part_id0() const {
*/
int BulletManifoldPoint::
get_part_id1() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _pt.m_partId1;
}
@ -136,6 +146,7 @@ get_part_id1() const {
*/
int BulletManifoldPoint::
get_index0() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _pt.m_index0;
}
@ -145,6 +156,261 @@ get_index0() const {
*/
int BulletManifoldPoint::
get_index1() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _pt.m_index1;
}
/**
*
*/
void BulletManifoldPoint::
set_lateral_friction_initialized(bool value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
#if BT_BULLET_VERSION >= 285
if (value) {
_pt.m_contactPointFlags |= BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED;
} else {
_pt.m_contactPointFlags &= ~BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED;
}
#else
_pt.m_lateralFrictionInitialized = value;
#endif
}
/**
*
*/
bool BulletManifoldPoint::
get_lateral_friction_initialized() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
#if BT_BULLET_VERSION >= 285
return (_pt.m_contactPointFlags & BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED) != 0;
#else
return _pt.m_lateralFrictionInitialized;
#endif
}
/**
*
*/
void BulletManifoldPoint::
set_lateral_friction_dir1(const LVecBase3 &dir) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_pt.m_lateralFrictionDir1 = LVecBase3_to_btVector3(dir);
}
/**
*
*/
LVector3 BulletManifoldPoint::
get_lateral_friction_dir1() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btVector3_to_LVector3(_pt.m_lateralFrictionDir1);
}
/**
*
*/
void BulletManifoldPoint::
set_lateral_friction_dir2(const LVecBase3 &dir) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_pt.m_lateralFrictionDir2 = LVecBase3_to_btVector3(dir);
}
/**
*
*/
LVector3 BulletManifoldPoint::
get_lateral_friction_dir2() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btVector3_to_LVector3(_pt.m_lateralFrictionDir2);
}
/**
*
*/
void BulletManifoldPoint::
set_contact_motion1(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_pt.m_contactMotion1 = (btScalar)value;
}
/**
*
*/
PN_stdfloat BulletManifoldPoint::
get_contact_motion1() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_pt.m_contactMotion1;
}
/**
*
*/
void BulletManifoldPoint::
set_contact_motion2(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_pt.m_contactMotion2 = (btScalar)value;
}
/**
*
*/
PN_stdfloat BulletManifoldPoint::
get_contact_motion2() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_pt.m_contactMotion2;
}
/**
*
*/
void BulletManifoldPoint::
set_combined_friction(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_pt.m_combinedFriction = (btScalar)value;
}
/**
*
*/
PN_stdfloat BulletManifoldPoint::
get_combined_friction() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_pt.m_combinedFriction;
}
/**
*
*/
void BulletManifoldPoint::
set_combined_restitution(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_pt.m_combinedRestitution = (btScalar)value;
}
/**
*
*/
PN_stdfloat BulletManifoldPoint::
get_combined_restitution() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_pt.m_combinedRestitution;
}
/**
*
*/
void BulletManifoldPoint::
set_applied_impulse(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_pt.m_appliedImpulse = (btScalar)value;
}
/**
*
*/
void BulletManifoldPoint::
set_applied_impulse_lateral1(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_pt.m_appliedImpulseLateral1 = (btScalar)value;
}
/**
*
*/
PN_stdfloat BulletManifoldPoint::
get_applied_impulse_lateral1() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_pt.m_appliedImpulseLateral1;
}
/**
*
*/
void BulletManifoldPoint::
set_applied_impulse_lateral2(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_pt.m_appliedImpulseLateral2 = (btScalar)value;
}
/**
*
*/
PN_stdfloat BulletManifoldPoint::
get_applied_impulse_lateral2() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_pt.m_appliedImpulseLateral2;
}
/**
*
*/
void BulletManifoldPoint::
set_contact_cfm1(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
#if BT_BULLET_VERSION < 285
_pt.m_contactCFM1 = (btScalar)value;
#endif
}
/**
*
*/
PN_stdfloat BulletManifoldPoint::
get_contact_cfm1() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
#if BT_BULLET_VERSION < 285
return (PN_stdfloat)_pt.m_contactCFM1;
#else
return 0;
#endif
}
/**
*
*/
void BulletManifoldPoint::
set_contact_cfm2(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
#if BT_BULLET_VERSION < 285
_pt.m_contactCFM2 = (btScalar)value;
#endif
}
/**
*
*/
PN_stdfloat BulletManifoldPoint::
get_contact_cfm2() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
#if BT_BULLET_VERSION < 285
return (PN_stdfloat)_pt.m_contactCFM2;
#else
return 0;
#endif
}

View File

@ -43,30 +43,30 @@ PUBLISHED:
int get_index0() const;
int get_index1() const;
INLINE void set_lateral_friction_initialized(bool value);
INLINE void set_lateral_friction_dir1(const LVecBase3 &dir);
INLINE void set_lateral_friction_dir2(const LVecBase3 &dir);
INLINE void set_contact_motion1(PN_stdfloat value);
INLINE void set_contact_motion2(PN_stdfloat value);
INLINE void set_combined_friction(PN_stdfloat value);
INLINE void set_combined_restitution(PN_stdfloat value);
INLINE void set_applied_impulse(PN_stdfloat value);
INLINE void set_applied_impulse_lateral1(PN_stdfloat value);
INLINE void set_applied_impulse_lateral2(PN_stdfloat value);
INLINE void set_contact_cfm1(PN_stdfloat value);
INLINE void set_contact_cfm2(PN_stdfloat value);
void set_lateral_friction_initialized(bool value);
void set_lateral_friction_dir1(const LVecBase3 &dir);
void set_lateral_friction_dir2(const LVecBase3 &dir);
void set_contact_motion1(PN_stdfloat value);
void set_contact_motion2(PN_stdfloat value);
void set_combined_friction(PN_stdfloat value);
void set_combined_restitution(PN_stdfloat value);
void set_applied_impulse(PN_stdfloat value);
void set_applied_impulse_lateral1(PN_stdfloat value);
void set_applied_impulse_lateral2(PN_stdfloat value);
void set_contact_cfm1(PN_stdfloat value);
void set_contact_cfm2(PN_stdfloat value);
INLINE bool get_lateral_friction_initialized() const;
INLINE LVector3 get_lateral_friction_dir1() const;
INLINE LVector3 get_lateral_friction_dir2() const;
INLINE PN_stdfloat get_contact_motion1() const;
INLINE PN_stdfloat get_contact_motion2() const;
INLINE PN_stdfloat get_combined_friction() const;
INLINE PN_stdfloat get_combined_restitution() const;
INLINE PN_stdfloat get_applied_impulse_lateral1() const;
INLINE PN_stdfloat get_applied_impulse_lateral2() const;
INLINE PN_stdfloat get_contact_cfm1() const;
INLINE PN_stdfloat get_contact_cfm2() const;
bool get_lateral_friction_initialized() const;
LVector3 get_lateral_friction_dir1() const;
LVector3 get_lateral_friction_dir2() const;
PN_stdfloat get_contact_motion1() const;
PN_stdfloat get_contact_motion2() const;
PN_stdfloat get_combined_friction() const;
PN_stdfloat get_combined_restitution() const;
PN_stdfloat get_applied_impulse_lateral1() const;
PN_stdfloat get_applied_impulse_lateral2() const;
PN_stdfloat get_contact_cfm1() const;
PN_stdfloat get_contact_cfm2() const;
MAKE_PROPERTY(life_time, get_life_time);
MAKE_PROPERTY(distance, get_distance);

View File

@ -30,64 +30,6 @@ INLINE BulletMinkowskiSumShape::
delete _shape;
}
/**
*
*/
INLINE BulletMinkowskiSumShape::
BulletMinkowskiSumShape(const BulletMinkowskiSumShape &copy) :
_shape(copy._shape),
_shape_a(copy._shape_a),
_shape_b(copy._shape_b) {
}
/**
*
*/
INLINE void BulletMinkowskiSumShape::
operator = (const BulletMinkowskiSumShape &copy) {
_shape = copy._shape;
_shape_a = copy._shape_a;
_shape_b = copy._shape_b;
}
/**
*
*/
INLINE void BulletMinkowskiSumShape::
set_transform_a(const TransformState *ts) {
nassertv(ts);
_shape->setTransformA(TransformState_to_btTrans(ts));
}
/**
*
*/
INLINE void BulletMinkowskiSumShape::
set_transform_b(const TransformState *ts) {
nassertv(ts);
_shape->setTransformB(TransformState_to_btTrans(ts));
}
/**
*
*/
INLINE CPT(TransformState) BulletMinkowskiSumShape::
get_transform_a() const {
return btTrans_to_TransformState(_shape->getTransformA());
}
/**
*
*/
INLINE CPT(TransformState) BulletMinkowskiSumShape::
get_transform_b() const {
return btTrans_to_TransformState(_shape->GetTransformB());
}
/**
*
*/

View File

@ -33,6 +33,30 @@ BulletMinkowskiSumShape(const BulletShape *shape_a, const BulletShape *shape_b)
_shape->setUserPointer(this);
}
/**
*
*/
BulletMinkowskiSumShape::
BulletMinkowskiSumShape(const BulletMinkowskiSumShape &copy) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_shape = copy._shape;
_shape_a = copy._shape_a;
_shape_b = copy._shape_b;
}
/**
*
*/
void BulletMinkowskiSumShape::
operator = (const BulletMinkowskiSumShape &copy) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_shape = copy._shape;
_shape_a = copy._shape_a;
_shape_b = copy._shape_b;
}
/**
*
*/
@ -42,6 +66,48 @@ ptr() const {
return _shape;
}
/**
*
*/
void BulletMinkowskiSumShape::
set_transform_a(const TransformState *ts) {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertv(ts);
_shape->setTransformA(TransformState_to_btTrans(ts));
}
/**
*
*/
void BulletMinkowskiSumShape::
set_transform_b(const TransformState *ts) {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertv(ts);
_shape->setTransformB(TransformState_to_btTrans(ts));
}
/**
*
*/
CPT(TransformState) BulletMinkowskiSumShape::
get_transform_a() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btTrans_to_TransformState(_shape->getTransformA());
}
/**
*
*/
CPT(TransformState) BulletMinkowskiSumShape::
get_transform_b() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btTrans_to_TransformState(_shape->GetTransformB());
}
/**
* Tells the BamReader how to create objects of type BulletShape.
*/

View File

@ -32,14 +32,14 @@ private:
PUBLISHED:
explicit BulletMinkowskiSumShape(const BulletShape *shape_a, const BulletShape *shape_b);
INLINE BulletMinkowskiSumShape(const BulletMinkowskiSumShape &copy);
INLINE void operator = (const BulletMinkowskiSumShape &copy);
BulletMinkowskiSumShape(const BulletMinkowskiSumShape &copy);
void operator = (const BulletMinkowskiSumShape &copy);
INLINE ~BulletMinkowskiSumShape();
INLINE void set_transform_a(const TransformState *ts);
INLINE void set_transform_b(const TransformState *ts);
INLINE CPT(TransformState) get_transform_a() const;
INLINE CPT(TransformState) get_transform_b() const;
void set_transform_a(const TransformState *ts);
void set_transform_b(const TransformState *ts);
CPT(TransformState) get_transform_a() const;
CPT(TransformState) get_transform_b() const;
INLINE const BulletShape *get_shape_a() const;
INLINE const BulletShape *get_shape_b() const;

View File

@ -19,48 +19,3 @@ INLINE BulletMultiSphereShape::
delete _shape;
}
/**
*
*/
INLINE BulletMultiSphereShape::
BulletMultiSphereShape(const BulletMultiSphereShape &copy) :
_shape(copy._shape) {
}
/**
*
*/
INLINE void BulletMultiSphereShape::
operator = (const BulletMultiSphereShape &copy) {
_shape = copy._shape;
}
/**
*
*/
INLINE int BulletMultiSphereShape::
get_sphere_count() const {
return _shape->getSphereCount();
}
/**
*
*/
INLINE LPoint3 BulletMultiSphereShape::
get_sphere_pos(int index) const {
nassertr(index >=0 && index <_shape->getSphereCount(), LPoint3::zero());
return btVector3_to_LPoint3(_shape->getSpherePosition(index));
}
/**
*
*/
INLINE PN_stdfloat BulletMultiSphereShape::
get_sphere_radius(int index) const {
nassertr(index >=0 && index <_shape->getSphereCount(), 0.0);
return (PN_stdfloat)_shape->getSphereRadius(index);
}

View File

@ -42,6 +42,26 @@ BulletMultiSphereShape(const PTA_LVecBase3 &points, const PTA_stdfloat &radii) {
_shape->setUserPointer(this);
}
/**
*
*/
BulletMultiSphereShape::
BulletMultiSphereShape(const BulletMultiSphereShape &copy) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_shape = copy._shape;
}
/**
*
*/
void BulletMultiSphereShape::
operator = (const BulletMultiSphereShape &copy) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_shape = copy._shape;
}
/**
*
*/
@ -51,6 +71,38 @@ ptr() const {
return _shape;
}
/**
*
*/
int BulletMultiSphereShape::
get_sphere_count() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _shape->getSphereCount();
}
/**
*
*/
LPoint3 BulletMultiSphereShape::
get_sphere_pos(int index) const {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertr(index >=0 && index <_shape->getSphereCount(), LPoint3::zero());
return btVector3_to_LPoint3(_shape->getSpherePosition(index));
}
/**
*
*/
PN_stdfloat BulletMultiSphereShape::
get_sphere_radius(int index) const {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertr(index >=0 && index <_shape->getSphereCount(), 0.0);
return (PN_stdfloat)_shape->getSphereRadius(index);
}
/**
* Tells the BamReader how to create objects of type BulletShape.
*/

View File

@ -31,13 +31,13 @@ private:
PUBLISHED:
explicit BulletMultiSphereShape(const PTA_LVecBase3 &points, const PTA_stdfloat &radii);
INLINE BulletMultiSphereShape(const BulletMultiSphereShape &copy);
INLINE void operator = (const BulletMultiSphereShape &copy);
BulletMultiSphereShape(const BulletMultiSphereShape &copy);
void operator = (const BulletMultiSphereShape &copy);
INLINE ~BulletMultiSphereShape();
INLINE int get_sphere_count() const;
INLINE LPoint3 get_sphere_pos(int index) const;
INLINE PN_stdfloat get_sphere_radius(int index) const;
int get_sphere_count() const;
LPoint3 get_sphere_pos(int index) const;
PN_stdfloat get_sphere_radius(int index) const;
MAKE_PROPERTY(sphere_count, get_sphere_count);
MAKE_SEQ_PROPERTY(sphere_pos, get_sphere_count, get_sphere_pos);

View File

@ -27,6 +27,7 @@ BulletPersistentManifold(btPersistentManifold *manifold) : _manifold(manifold) {
*/
PN_stdfloat BulletPersistentManifold::
get_contact_breaking_threshold() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_manifold->getContactBreakingThreshold();
}
@ -36,6 +37,7 @@ get_contact_breaking_threshold() const {
*/
PN_stdfloat BulletPersistentManifold::
get_contact_processing_threshold() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_manifold->getContactProcessingThreshold();
}
@ -45,6 +47,7 @@ get_contact_processing_threshold() const {
*/
void BulletPersistentManifold::
clear_manifold() {
LightMutexHolder holder(BulletWorld::get_global_lock());
_manifold->clearManifold();
}
@ -54,6 +57,7 @@ clear_manifold() {
*/
PandaNode *BulletPersistentManifold::
get_node0() {
LightMutexHolder holder(BulletWorld::get_global_lock());
#if BT_BULLET_VERSION >= 281
const btCollisionObject *obj = _manifold->getBody0();
@ -69,6 +73,7 @@ get_node0() {
*/
PandaNode *BulletPersistentManifold::
get_node1() {
LightMutexHolder holder(BulletWorld::get_global_lock());
#if BT_BULLET_VERSION >= 281
const btCollisionObject *obj = _manifold->getBody1();
@ -84,6 +89,7 @@ get_node1() {
*/
int BulletPersistentManifold::
get_num_manifold_points() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _manifold->getNumContacts();
}
@ -93,6 +99,7 @@ get_num_manifold_points() const {
*/
BulletManifoldPoint *BulletPersistentManifold::
get_manifold_point(int idx) const {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertr(idx < _manifold->getNumContacts(), NULL)

View File

@ -19,37 +19,3 @@ INLINE BulletPlaneShape::
delete _shape;
}
/**
*
*/
INLINE BulletPlaneShape::
BulletPlaneShape(const BulletPlaneShape &copy) :
_shape(copy._shape) {
}
/**
*
*/
INLINE void BulletPlaneShape::
operator = (const BulletPlaneShape &copy) {
_shape = copy._shape;
}
/**
*
*/
INLINE PN_stdfloat BulletPlaneShape::
get_plane_constant() const {
return (PN_stdfloat)_shape->getPlaneConstant();
}
/**
*
*/
INLINE LVector3 BulletPlaneShape::
get_plane_normal() const {
return btVector3_to_LVector3(_shape->getPlaneNormal());
}

View File

@ -27,6 +27,26 @@ BulletPlaneShape(const LVector3 &normal, PN_stdfloat constant) {
_shape->setUserPointer(this);
}
/**
*
*/
BulletPlaneShape::
BulletPlaneShape(const BulletPlaneShape &copy) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_shape = copy._shape;
}
/**
*
*/
void BulletPlaneShape::
operator = (const BulletPlaneShape &copy) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_shape = copy._shape;
}
/**
*
*/
@ -36,6 +56,26 @@ ptr() const {
return _shape;
}
/**
*
*/
PN_stdfloat BulletPlaneShape::
get_plane_constant() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_shape->getPlaneConstant();
}
/**
*
*/
LVector3 BulletPlaneShape::
get_plane_normal() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btVector3_to_LVector3(_shape->getPlaneNormal());
}
/**
*
*/

View File

@ -33,12 +33,12 @@ private:
PUBLISHED:
explicit BulletPlaneShape(const LVector3 &normal, PN_stdfloat constant);
INLINE BulletPlaneShape(const BulletPlaneShape &copy);
INLINE void operator = (const BulletPlaneShape &copy);
BulletPlaneShape(const BulletPlaneShape &copy);
void operator = (const BulletPlaneShape &copy);
INLINE ~BulletPlaneShape();
INLINE LVector3 get_plane_normal() const;
INLINE PN_stdfloat get_plane_constant() const;
LVector3 get_plane_normal() const;
PN_stdfloat get_plane_constant() const;
static BulletPlaneShape *make_from_solid(const CollisionPlane *solid);

View File

@ -20,38 +20,3 @@ INLINE BulletRigidBodyNode::
delete _rigid;
}
/**
*
*/
INLINE void BulletRigidBodyNode::
set_linear_damping(PN_stdfloat value) {
_rigid->setDamping(value, _rigid->getAngularDamping());
}
/**
*
*/
INLINE void BulletRigidBodyNode::
set_angular_damping(PN_stdfloat value) {
_rigid->setDamping(_rigid->getLinearDamping(), value);
}
/**
*
*/
INLINE PN_stdfloat BulletRigidBodyNode::
get_linear_damping() const {
return (PN_stdfloat)_rigid->getLinearDamping();
}
/**
*
*/
INLINE PN_stdfloat BulletRigidBodyNode::
get_angular_damping() const {
return (PN_stdfloat)_rigid->getAngularDamping();
}

View File

@ -48,9 +48,11 @@ BulletRigidBodyNode(const char *name) : BulletBodyNode(name) {
*/
BulletRigidBodyNode::
BulletRigidBodyNode(const BulletRigidBodyNode &copy) :
BulletBodyNode(copy),
_motion(copy._motion)
BulletBodyNode(copy)
{
LightMutexHolder holder(BulletWorld::get_global_lock());
_motion = copy._motion;
_rigid = new btRigidBody(*copy._rigid);
_rigid->setUserPointer(this);
_rigid->setCollisionShape(_shape);
@ -64,6 +66,7 @@ BulletRigidBodyNode(const BulletRigidBodyNode &copy) :
*/
PandaNode *BulletRigidBodyNode::
make_copy() const {
return new BulletRigidBodyNode(*this);
}
@ -72,10 +75,11 @@ make_copy() const {
*/
void BulletRigidBodyNode::
output(ostream &out) const {
LightMutexHolder holder(BulletWorld::get_global_lock());
BulletBodyNode::output(out);
BulletBodyNode::do_output(out);
out << " mass=" << get_mass();
out << " mass=" << do_get_mass();
}
/**
@ -93,10 +97,10 @@ get_object() const {
* The default implementation does nothing.
*/
void BulletRigidBodyNode::
shape_changed() {
do_shape_changed() {
set_mass(get_mass());
transform_changed();
do_set_mass(do_get_mass());
do_transform_changed();
}
/**
@ -104,9 +108,10 @@ shape_changed() {
* automatically computed from the shape of the body. Setting a value of zero
* for mass will make the body static. A value of zero can be considered an
* infinite mass.
* Assumes the lock(bullet global lock) is held by the caller
*/
void BulletRigidBodyNode::
set_mass(PN_stdfloat mass) {
do_set_mass(PN_stdfloat mass) {
btScalar bt_mass = mass;
btVector3 bt_inertia(0.0, 0.0, 0.0);
@ -119,12 +124,26 @@ set_mass(PN_stdfloat mass) {
_rigid->updateInertiaTensor();
}
/**
* Sets the mass of a rigid body. This also modifies the inertia, which is
* automatically computed from the shape of the body. Setting a value of zero
* for mass will make the body static. A value of zero can be considered an
* infinite mass.
*/
void BulletRigidBodyNode::
set_mass(PN_stdfloat mass) {
LightMutexHolder holder(BulletWorld::get_global_lock());
do_set_mass(mass);
}
/**
* Returns the total mass of a rigid body. A value of zero means that the
* body is staic, i.e. has an infinite mass.
* Assumes the lock(bullet global lock) is held by the caller
*/
PN_stdfloat BulletRigidBodyNode::
get_mass() const {
do_get_mass() const {
btScalar inv_mass = _rigid->getInvMass();
btScalar mass = (inv_mass == btScalar(0.0)) ? btScalar(0.0) : btScalar(1.0) / inv_mass;
@ -132,11 +151,24 @@ get_mass() const {
return mass;
}
/**
* Returns the total mass of a rigid body. A value of zero means that the
* body is staic, i.e. has an infinite mass.
*/
PN_stdfloat BulletRigidBodyNode::
get_mass() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return do_get_mass();
}
/**
* Returns the inverse mass of a rigid body.
*/
PN_stdfloat BulletRigidBodyNode::
get_inv_mass() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_rigid->getInvMass();
}
@ -153,6 +185,7 @@ get_inv_mass() const {
*/
void BulletRigidBodyNode::
set_inertia(const LVecBase3 &inertia) {
LightMutexHolder holder(BulletWorld::get_global_lock());
btVector3 inv_inertia(
inertia.get_x() == 0.0 ? btScalar(0.0) : btScalar(1.0 / inertia.get_x()),
@ -171,6 +204,7 @@ set_inertia(const LVecBase3 &inertia) {
*/
LVector3 BulletRigidBodyNode::
get_inertia() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
btVector3 inv_inertia = _rigid->getInvInertiaDiagLocal();
LVector3 inertia(
@ -187,6 +221,7 @@ get_inertia() const {
*/
LVector3 BulletRigidBodyNode::
get_inv_inertia_diag_local() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btVector3_to_LVector3(_rigid->getInvInertiaDiagLocal());
}
@ -196,6 +231,7 @@ get_inv_inertia_diag_local() const {
*/
LMatrix3 BulletRigidBodyNode::
get_inv_inertia_tensor_world() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btMatrix3x3_to_LMatrix3(_rigid->getInvInertiaTensorWorld());
}
@ -205,6 +241,7 @@ get_inv_inertia_tensor_world() const {
*/
void BulletRigidBodyNode::
apply_force(const LVector3 &force, const LPoint3 &pos) {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertv_always(!force.is_nan());
nassertv_always(!pos.is_nan());
@ -218,6 +255,7 @@ apply_force(const LVector3 &force, const LPoint3 &pos) {
*/
void BulletRigidBodyNode::
apply_central_force(const LVector3 &force) {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertv_always(!force.is_nan());
@ -229,6 +267,7 @@ apply_central_force(const LVector3 &force) {
*/
void BulletRigidBodyNode::
apply_torque(const LVector3 &torque) {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertv_always(!torque.is_nan());
@ -240,6 +279,7 @@ apply_torque(const LVector3 &torque) {
*/
void BulletRigidBodyNode::
apply_torque_impulse(const LVector3 &torque) {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertv_always(!torque.is_nan());
@ -251,6 +291,7 @@ apply_torque_impulse(const LVector3 &torque) {
*/
void BulletRigidBodyNode::
apply_impulse(const LVector3 &impulse, const LPoint3 &pos) {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertv_always(!impulse.is_nan());
nassertv_always(!pos.is_nan());
@ -264,6 +305,7 @@ apply_impulse(const LVector3 &impulse, const LPoint3 &pos) {
*/
void BulletRigidBodyNode::
apply_central_impulse(const LVector3 &impulse) {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertv_always(!impulse.is_nan());
@ -271,10 +313,10 @@ apply_central_impulse(const LVector3 &impulse) {
}
/**
*
* Assumes the lock(bullet global lock) is held by the caller
*/
void BulletRigidBodyNode::
transform_changed() {
do_transform_changed() {
if (_motion.sync_disabled()) return;
@ -289,7 +331,7 @@ transform_changed() {
_motion.set_net_transform(ts);
// For dynamic or static bodies we directly apply the new transform.
if (!is_kinematic()) {
if (!(get_object()->isKinematicObject())) {
btTransform trans = TransformState_to_btTrans(ts);
_rigid->setCenterOfMassTransform(trans);
}
@ -317,18 +359,31 @@ transform_changed() {
*
*/
void BulletRigidBodyNode::
sync_p2b() {
transform_changed() {
if (is_kinematic()) {
transform_changed();
if (_motion.sync_disabled()) return;
LightMutexHolder holder(BulletWorld::get_global_lock());
do_transform_changed();
}
/**
* Assumes the lock(bullet global lock) is held by the caller
*/
void BulletRigidBodyNode::
do_sync_p2b() {
if (get_object()->isKinematicObject()) {
do_transform_changed();
}
}
/**
*
* Assumes the lock(bullet global lock) is held by the caller
*/
void BulletRigidBodyNode::
sync_b2p() {
do_sync_b2p() {
_motion.sync_b2p((PandaNode *)this);
}
@ -338,6 +393,7 @@ sync_b2p() {
*/
LVector3 BulletRigidBodyNode::
get_linear_velocity() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btVector3_to_LVector3(_rigid->getLinearVelocity());
}
@ -347,6 +403,7 @@ get_linear_velocity() const {
*/
LVector3 BulletRigidBodyNode::
get_angular_velocity() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btVector3_to_LVector3(_rigid->getAngularVelocity());
}
@ -356,6 +413,7 @@ get_angular_velocity() const {
*/
void BulletRigidBodyNode::
set_linear_velocity(const LVector3 &velocity) {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertv_always(!velocity.is_nan());
@ -367,17 +425,59 @@ set_linear_velocity(const LVector3 &velocity) {
*/
void BulletRigidBodyNode::
set_angular_velocity(const LVector3 &velocity) {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertv_always(!velocity.is_nan());
_rigid->setAngularVelocity(LVecBase3_to_btVector3(velocity));
}
/**
*
*/
void BulletRigidBodyNode::
set_linear_damping(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_rigid->setDamping(value, _rigid->getAngularDamping());
}
/**
*
*/
void BulletRigidBodyNode::
set_angular_damping(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_rigid->setDamping(_rigid->getLinearDamping(), value);
}
/**
*
*/
PN_stdfloat BulletRigidBodyNode::
get_linear_damping() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_rigid->getLinearDamping();
}
/**
*
*/
PN_stdfloat BulletRigidBodyNode::
get_angular_damping() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_rigid->getAngularDamping();
}
/**
*
*/
void BulletRigidBodyNode::
clear_forces() {
LightMutexHolder holder(BulletWorld::get_global_lock());
_rigid->clearForces();
}
@ -387,6 +487,7 @@ clear_forces() {
*/
PN_stdfloat BulletRigidBodyNode::
get_linear_sleep_threshold() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _rigid->getLinearSleepingThreshold();
}
@ -396,6 +497,7 @@ get_linear_sleep_threshold() const {
*/
PN_stdfloat BulletRigidBodyNode::
get_angular_sleep_threshold() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _rigid->getAngularSleepingThreshold();
}
@ -405,6 +507,7 @@ get_angular_sleep_threshold() const {
*/
void BulletRigidBodyNode::
set_linear_sleep_threshold(PN_stdfloat threshold) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_rigid->setSleepingThresholds(threshold, _rigid->getAngularSleepingThreshold());
}
@ -414,6 +517,7 @@ set_linear_sleep_threshold(PN_stdfloat threshold) {
*/
void BulletRigidBodyNode::
set_angular_sleep_threshold(PN_stdfloat threshold) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_rigid->setSleepingThresholds(_rigid->getLinearSleepingThreshold(), threshold);
}
@ -423,6 +527,7 @@ set_angular_sleep_threshold(PN_stdfloat threshold) {
*/
void BulletRigidBodyNode::
set_gravity(const LVector3 &gravity) {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertv_always(!gravity.is_nan());
@ -434,6 +539,7 @@ set_gravity(const LVector3 &gravity) {
*/
LVector3 BulletRigidBodyNode::
get_gravity() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btVector3_to_LVector3(_rigid->getGravity());
}
@ -443,6 +549,7 @@ get_gravity() const {
*/
LVector3 BulletRigidBodyNode::
get_linear_factor() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btVector3_to_LVector3(_rigid->getLinearFactor());
}
@ -452,6 +559,7 @@ get_linear_factor() const {
*/
LVector3 BulletRigidBodyNode::
get_angular_factor() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btVector3_to_LVector3(_rigid->getAngularFactor());
}
@ -461,6 +569,7 @@ get_angular_factor() const {
*/
void BulletRigidBodyNode::
set_linear_factor(const LVector3 &factor) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_rigid->setLinearFactor(LVecBase3_to_btVector3(factor));
}
@ -470,6 +579,7 @@ set_linear_factor(const LVector3 &factor) {
*/
void BulletRigidBodyNode::
set_angular_factor(const LVector3 &factor) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_rigid->setAngularFactor(LVecBase3_to_btVector3(factor));
}
@ -479,6 +589,7 @@ set_angular_factor(const LVector3 &factor) {
*/
LVector3 BulletRigidBodyNode::
get_total_force() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btVector3_to_LVector3(_rigid->getTotalForce());
}
@ -488,6 +599,7 @@ get_total_force() const {
*/
LVector3 BulletRigidBodyNode::
get_total_torque() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btVector3_to_LVector3(_rigid->getTotalTorque());
}

View File

@ -50,10 +50,10 @@ PUBLISHED:
void set_angular_velocity(const LVector3 &velocity);
// Damping
INLINE PN_stdfloat get_linear_damping() const;
INLINE PN_stdfloat get_angular_damping() const;
INLINE void set_linear_damping(PN_stdfloat value);
INLINE void set_angular_damping(PN_stdfloat value);
PN_stdfloat get_linear_damping() const;
PN_stdfloat get_angular_damping() const;
void set_linear_damping(PN_stdfloat value);
void set_angular_damping(PN_stdfloat value);
// Forces
void clear_forces();
@ -108,14 +108,18 @@ public:
virtual void output(ostream &out) const;
void sync_p2b();
void sync_b2p();
void do_sync_p2b();
void do_sync_b2p();
protected:
virtual void transform_changed();
private:
virtual void shape_changed();
virtual void do_shape_changed();
void do_transform_changed();
void do_set_mass(PN_stdfloat mass);
PN_stdfloat do_get_mass() const;
// The motion state is used for synchronisation between Bullet and the
// Panda3D scene graph.

View File

@ -14,162 +14,7 @@
/**
*
*/
INLINE bool BulletRotationalLimitMotor::
is_limited() const {
INLINE BulletRotationalLimitMotor::
~BulletRotationalLimitMotor() {
return _motor.isLimited();
}
/**
*
*/
INLINE void BulletRotationalLimitMotor::
set_motor_enabled(bool enabled) {
_motor.m_enableMotor = enabled;
}
/**
*
*/
INLINE bool BulletRotationalLimitMotor::
get_motor_enabled() const {
return _motor.m_enableMotor;
}
/**
*
*/
INLINE void BulletRotationalLimitMotor::
set_low_limit(PN_stdfloat limit) {
_motor.m_loLimit = (btScalar)limit;
}
/**
*
*/
INLINE void BulletRotationalLimitMotor::
set_high_limit(PN_stdfloat limit) {
_motor.m_hiLimit = (btScalar)limit;
}
/**
*
*/
INLINE void BulletRotationalLimitMotor::
set_target_velocity(PN_stdfloat velocity) {
_motor.m_targetVelocity = (btScalar)velocity;
}
/**
*
*/
INLINE void BulletRotationalLimitMotor::
set_max_motor_force(PN_stdfloat force) {
_motor.m_maxMotorForce = (btScalar)force;
}
/**
*
*/
INLINE void BulletRotationalLimitMotor::
set_max_limit_force(PN_stdfloat force) {
_motor.m_maxLimitForce = (btScalar)force;
}
/**
*
*/
INLINE void BulletRotationalLimitMotor::
set_damping(PN_stdfloat damping) {
_motor.m_damping = (btScalar)damping;
}
/**
*
*/
INLINE void BulletRotationalLimitMotor::
set_softness(PN_stdfloat softness) {
_motor.m_limitSoftness = (btScalar)softness;
}
/**
*
*/
INLINE void BulletRotationalLimitMotor::
set_bounce(PN_stdfloat bounce) {
_motor.m_bounce = (btScalar)bounce;
}
/**
*
*/
INLINE void BulletRotationalLimitMotor::
set_normal_cfm(PN_stdfloat cfm) {
_motor.m_normalCFM = (btScalar)cfm;
}
/**
*
*/
INLINE void BulletRotationalLimitMotor::
set_stop_cfm(PN_stdfloat cfm) {
_motor.m_stopCFM = (btScalar)cfm;
}
/**
*
*/
INLINE void BulletRotationalLimitMotor::
set_stop_erp(PN_stdfloat erp) {
_motor.m_stopERP = (btScalar)erp;
}
/**
* Retrieves the current value of angle: 0 = free, 1 = at low limit, 2 = at
* high limit.
*/
INLINE int BulletRotationalLimitMotor::
get_current_limit() const {
return _motor.m_currentLimit;
}
/**
*
*/
INLINE PN_stdfloat BulletRotationalLimitMotor::
get_current_error() const {
return (PN_stdfloat)_motor.m_currentLimitError;
}
/**
*
*/
INLINE PN_stdfloat BulletRotationalLimitMotor::
get_current_position() const {
return (PN_stdfloat)_motor.m_currentPosition;
}
/**
*
*/
INLINE PN_stdfloat BulletRotationalLimitMotor::
get_accumulated_impulse() const {
return (PN_stdfloat)_motor.m_accumulatedImpulse;
}

View File

@ -34,7 +34,179 @@ BulletRotationalLimitMotor(const BulletRotationalLimitMotor &copy)
/**
*
*/
BulletRotationalLimitMotor::
~BulletRotationalLimitMotor() {
bool BulletRotationalLimitMotor::
is_limited() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _motor.isLimited();
}
/**
*
*/
void BulletRotationalLimitMotor::
set_motor_enabled(bool enabled) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_motor.m_enableMotor = enabled;
}
/**
*
*/
bool BulletRotationalLimitMotor::
get_motor_enabled() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _motor.m_enableMotor;
}
/**
*
*/
void BulletRotationalLimitMotor::
set_low_limit(PN_stdfloat limit) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_motor.m_loLimit = (btScalar)limit;
}
/**
*
*/
void BulletRotationalLimitMotor::
set_high_limit(PN_stdfloat limit) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_motor.m_hiLimit = (btScalar)limit;
}
/**
*
*/
void BulletRotationalLimitMotor::
set_target_velocity(PN_stdfloat velocity) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_motor.m_targetVelocity = (btScalar)velocity;
}
/**
*
*/
void BulletRotationalLimitMotor::
set_max_motor_force(PN_stdfloat force) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_motor.m_maxMotorForce = (btScalar)force;
}
/**
*
*/
void BulletRotationalLimitMotor::
set_max_limit_force(PN_stdfloat force) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_motor.m_maxLimitForce = (btScalar)force;
}
/**
*
*/
void BulletRotationalLimitMotor::
set_damping(PN_stdfloat damping) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_motor.m_damping = (btScalar)damping;
}
/**
*
*/
void BulletRotationalLimitMotor::
set_softness(PN_stdfloat softness) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_motor.m_limitSoftness = (btScalar)softness;
}
/**
*
*/
void BulletRotationalLimitMotor::
set_bounce(PN_stdfloat bounce) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_motor.m_bounce = (btScalar)bounce;
}
/**
*
*/
void BulletRotationalLimitMotor::
set_normal_cfm(PN_stdfloat cfm) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_motor.m_normalCFM = (btScalar)cfm;
}
/**
*
*/
void BulletRotationalLimitMotor::
set_stop_cfm(PN_stdfloat cfm) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_motor.m_stopCFM = (btScalar)cfm;
}
/**
*
*/
void BulletRotationalLimitMotor::
set_stop_erp(PN_stdfloat erp) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_motor.m_stopERP = (btScalar)erp;
}
/**
* Retrieves the current value of angle: 0 = free, 1 = at low limit, 2 = at
* high limit.
*/
int BulletRotationalLimitMotor::
get_current_limit() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _motor.m_currentLimit;
}
/**
*
*/
PN_stdfloat BulletRotationalLimitMotor::
get_current_error() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_motor.m_currentLimitError;
}
/**
*
*/
PN_stdfloat BulletRotationalLimitMotor::
get_current_position() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_motor.m_currentPosition;
}
/**
*
*/
PN_stdfloat BulletRotationalLimitMotor::
get_accumulated_impulse() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_motor.m_accumulatedImpulse;
}

View File

@ -28,27 +28,27 @@ class EXPCL_PANDABULLET BulletRotationalLimitMotor {
PUBLISHED:
BulletRotationalLimitMotor(const BulletRotationalLimitMotor &copy);
~BulletRotationalLimitMotor();
INLINE ~BulletRotationalLimitMotor();
INLINE void set_motor_enabled(bool enable);
INLINE void set_low_limit(PN_stdfloat limit);
INLINE void set_high_limit(PN_stdfloat limit);
INLINE void set_target_velocity(PN_stdfloat velocity);
INLINE void set_max_motor_force(PN_stdfloat force);
INLINE void set_max_limit_force(PN_stdfloat force);
INLINE void set_damping(PN_stdfloat damping);
INLINE void set_softness(PN_stdfloat softness);
INLINE void set_bounce(PN_stdfloat bounce);
INLINE void set_normal_cfm(PN_stdfloat cfm);
INLINE void set_stop_cfm(PN_stdfloat cfm);
INLINE void set_stop_erp(PN_stdfloat erp);
void set_motor_enabled(bool enable);
void set_low_limit(PN_stdfloat limit);
void set_high_limit(PN_stdfloat limit);
void set_target_velocity(PN_stdfloat velocity);
void set_max_motor_force(PN_stdfloat force);
void set_max_limit_force(PN_stdfloat force);
void set_damping(PN_stdfloat damping);
void set_softness(PN_stdfloat softness);
void set_bounce(PN_stdfloat bounce);
void set_normal_cfm(PN_stdfloat cfm);
void set_stop_cfm(PN_stdfloat cfm);
void set_stop_erp(PN_stdfloat erp);
INLINE bool is_limited() const;
INLINE bool get_motor_enabled() const;
INLINE int get_current_limit() const;
INLINE PN_stdfloat get_current_error() const;
INLINE PN_stdfloat get_current_position() const;
INLINE PN_stdfloat get_accumulated_impulse() const;
bool is_limited() const;
bool get_motor_enabled() const;
int get_current_limit() const;
PN_stdfloat get_current_error() const;
PN_stdfloat get_current_position() const;
PN_stdfloat get_accumulated_impulse() const;
MAKE_PROPERTY(limited, is_limited);
MAKE_PROPERTY(motor_enabled, get_motor_enabled, set_motor_enabled);

View File

@ -18,66 +18,3 @@ INLINE BulletShape::
~BulletShape() {
}
/**
*
*/
INLINE bool BulletShape::
is_polyhedral() const {
return ptr()->isPolyhedral();
}
/**
*
*/
INLINE bool BulletShape::
is_convex() const {
return ptr()->isConvex();
}
/**
*
*/
INLINE bool BulletShape::
is_convex_2d() const {
return ptr()->isConvex2d();
}
/**
*
*/
INLINE bool BulletShape::
is_concave() const {
return ptr()->isConcave();
}
/**
*
*/
INLINE bool BulletShape::
is_infinite() const {
return ptr()->isInfinite();
}
/**
*
*/
INLINE bool BulletShape::
is_non_moving() const {
return ptr()->isNonMoving();
}
/**
*
*/
INLINE bool BulletShape::
is_soft_body() const {
return ptr()->isSoftBody();
}

View File

@ -21,6 +21,7 @@ TypeHandle BulletShape::_type_handle;
*/
const char *BulletShape::
get_name() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return ptr()->getName();
}
@ -30,6 +31,7 @@ get_name() const {
*/
PN_stdfloat BulletShape::
get_margin() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return ptr()->getMargin();
}
@ -39,6 +41,7 @@ get_margin() const {
*/
void BulletShape::
set_margin(PN_stdfloat margin) {
LightMutexHolder holder(BulletWorld::get_global_lock());
ptr()->setMargin(margin);
}
@ -48,18 +51,29 @@ set_margin(PN_stdfloat margin) {
*/
LVecBase3 BulletShape::
get_local_scale() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btVector3_to_LVecBase3(ptr()->getLocalScaling());
}
/**
* Assumes the lock(bullet global lock) is held by the caller
*/
void BulletShape::
do_set_local_scale(const LVecBase3 &scale) {
nassertv(!scale.is_nan());
ptr()->setLocalScaling(LVecBase3_to_btVector3(scale));
}
/**
*
*/
void BulletShape::
set_local_scale(const LVecBase3 &scale) {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertv(!scale.is_nan());
ptr()->setLocalScaling(LVecBase3_to_btVector3(scale));
do_set_local_scale(scale);
}
/**
@ -67,6 +81,7 @@ set_local_scale(const LVecBase3 &scale) {
*/
BoundingSphere BulletShape::
get_shape_bounds() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
/*
btTransform tr;
@ -87,3 +102,73 @@ cout << "origin " << aabbMin.x() << " " << aabbMin.y() << " " << aabbMin.z() <<
return bounds;
}
/**
*
*/
bool BulletShape::
is_polyhedral() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return ptr()->isPolyhedral();
}
/**
*
*/
bool BulletShape::
is_convex() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return ptr()->isConvex();
}
/**
*
*/
bool BulletShape::
is_convex_2d() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return ptr()->isConvex2d();
}
/**
*
*/
bool BulletShape::
is_concave() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return ptr()->isConcave();
}
/**
*
*/
bool BulletShape::
is_infinite() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return ptr()->isInfinite();
}
/**
*
*/
bool BulletShape::
is_non_moving() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return ptr()->isNonMoving();
}
/**
*
*/
bool BulletShape::
is_soft_body() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return ptr()->isSoftBody();
}

View File

@ -31,13 +31,13 @@ protected:
PUBLISHED:
INLINE virtual ~BulletShape();
INLINE bool is_polyhedral() const;
INLINE bool is_convex() const;
INLINE bool is_convex_2d() const;
INLINE bool is_concave() const;
INLINE bool is_infinite() const;
INLINE bool is_non_moving() const;
INLINE bool is_soft_body() const;
bool is_polyhedral() const;
bool is_convex() const;
bool is_convex_2d() const;
bool is_concave() const;
bool is_infinite() const;
bool is_non_moving() const;
bool is_soft_body() const;
void set_margin(PN_stdfloat margin);
const char *get_name() const;
@ -61,6 +61,7 @@ public:
virtual btCollisionShape *ptr() const = 0;
LVecBase3 get_local_scale() const;
void set_local_scale(const LVecBase3 &scale);
void do_set_local_scale(const LVecBase3 &scale);
public:
static TypeHandle get_class_type() {

View File

@ -19,21 +19,3 @@ INLINE BulletSliderConstraint::
delete _constraint;
}
/**
*
*/
INLINE CPT(TransformState) BulletSliderConstraint::
get_frame_a() const {
return btTrans_to_TransformState(_constraint->getFrameOffsetA());
}
/**
*
*/
INLINE CPT(TransformState) BulletSliderConstraint::
get_frame_b() const {
return btTrans_to_TransformState(_constraint->getFrameOffsetB());
}

View File

@ -65,6 +65,7 @@ ptr() const {
*/
PN_stdfloat BulletSliderConstraint::
get_lower_linear_limit() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_constraint->getLowerLinLimit();
}
@ -74,6 +75,7 @@ get_lower_linear_limit() const {
*/
PN_stdfloat BulletSliderConstraint::
get_upper_linear_limit() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_constraint->getUpperLinLimit();
}
@ -83,6 +85,7 @@ get_upper_linear_limit() const {
*/
PN_stdfloat BulletSliderConstraint::
get_lower_angular_limit() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return rad_2_deg(_constraint->getLowerAngLimit());
}
@ -92,6 +95,7 @@ get_lower_angular_limit() const {
*/
PN_stdfloat BulletSliderConstraint::
get_upper_angular_limit() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return rad_2_deg(_constraint->getUpperAngLimit());
}
@ -101,6 +105,7 @@ get_upper_angular_limit() const {
*/
void BulletSliderConstraint::
set_lower_linear_limit(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_constraint->setLowerLinLimit((btScalar)value);
}
@ -110,6 +115,7 @@ set_lower_linear_limit(PN_stdfloat value) {
*/
void BulletSliderConstraint::
set_upper_linear_limit(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_constraint->setUpperLinLimit((btScalar)value);
}
@ -119,6 +125,7 @@ set_upper_linear_limit(PN_stdfloat value) {
*/
void BulletSliderConstraint::
set_lower_angular_limit(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_constraint->setLowerAngLimit((btScalar)deg_2_rad(value));
}
@ -128,6 +135,7 @@ set_lower_angular_limit(PN_stdfloat value) {
*/
void BulletSliderConstraint::
set_upper_angular_limit(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_constraint->setUpperAngLimit((btScalar)deg_2_rad(value));
}
@ -137,6 +145,7 @@ set_upper_angular_limit(PN_stdfloat value) {
*/
PN_stdfloat BulletSliderConstraint::
get_linear_pos() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_constraint->getLinearPos();
}
@ -146,6 +155,7 @@ get_linear_pos() const {
*/
PN_stdfloat BulletSliderConstraint::
get_angular_pos() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_constraint->getAngularPos();
}
@ -155,6 +165,7 @@ get_angular_pos() const {
*/
void BulletSliderConstraint::
set_powered_linear_motor(bool on) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_constraint->setPoweredLinMotor(on);
}
@ -164,6 +175,7 @@ set_powered_linear_motor(bool on) {
*/
void BulletSliderConstraint::
set_target_linear_motor_velocity(PN_stdfloat target_velocity) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_constraint->setTargetLinMotorVelocity((btScalar)target_velocity);
}
@ -173,6 +185,7 @@ set_target_linear_motor_velocity(PN_stdfloat target_velocity) {
*/
void BulletSliderConstraint::
set_max_linear_motor_force(PN_stdfloat max_force) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_constraint->setMaxLinMotorForce((btScalar)max_force);
}
@ -182,6 +195,7 @@ set_max_linear_motor_force(PN_stdfloat max_force) {
*/
bool BulletSliderConstraint::
get_powered_linear_motor() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _constraint->getPoweredLinMotor();
}
@ -191,6 +205,7 @@ get_powered_linear_motor() const {
*/
PN_stdfloat BulletSliderConstraint::
get_target_linear_motor_velocity() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_constraint->getTargetLinMotorVelocity();
}
@ -200,6 +215,7 @@ get_target_linear_motor_velocity() const {
*/
PN_stdfloat BulletSliderConstraint::
get_max_linear_motor_force() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_constraint->getMaxLinMotorForce();
}
@ -209,6 +225,7 @@ get_max_linear_motor_force() const {
*/
void BulletSliderConstraint::
set_powered_angular_motor(bool on) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_constraint->setPoweredAngMotor(on);
}
@ -218,6 +235,7 @@ set_powered_angular_motor(bool on) {
*/
void BulletSliderConstraint::
set_target_angular_motor_velocity(PN_stdfloat target_velocity) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_constraint->setTargetAngMotorVelocity((btScalar)target_velocity);
}
@ -227,6 +245,7 @@ set_target_angular_motor_velocity(PN_stdfloat target_velocity) {
*/
void BulletSliderConstraint::
set_max_angular_motor_force(PN_stdfloat max_force) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_constraint->setMaxAngMotorForce((btScalar)max_force);
}
@ -236,6 +255,7 @@ set_max_angular_motor_force(PN_stdfloat max_force) {
*/
bool BulletSliderConstraint::
get_powered_angular_motor() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _constraint->getPoweredAngMotor();
}
@ -245,6 +265,7 @@ get_powered_angular_motor() const {
*/
PN_stdfloat BulletSliderConstraint::
get_target_angular_motor_velocity() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_constraint->getTargetAngMotorVelocity();
}
@ -254,6 +275,7 @@ get_target_angular_motor_velocity() const {
*/
PN_stdfloat BulletSliderConstraint::
get_max_angular_motor_force() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_constraint->getMaxAngMotorForce();
}
@ -263,9 +285,30 @@ get_max_angular_motor_force() const {
*/
void BulletSliderConstraint::
set_frames(const TransformState *ts_a, const TransformState *ts_b) {
LightMutexHolder holder(BulletWorld::get_global_lock());
btTransform frame_a = TransformState_to_btTrans(ts_a);
btTransform frame_b = TransformState_to_btTrans(ts_b);
_constraint->setFrames(frame_a, frame_b);
}
/**
*
*/
CPT(TransformState) BulletSliderConstraint::
get_frame_a() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btTrans_to_TransformState(_constraint->getFrameOffsetA());
}
/**
*
*/
CPT(TransformState) BulletSliderConstraint::
get_frame_b() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return btTrans_to_TransformState(_constraint->getFrameOffsetB());
}

View File

@ -70,8 +70,8 @@ PUBLISHED:
// Frames
void set_frames(const TransformState *ts_a, const TransformState *ts_b);
INLINE CPT(TransformState) get_frame_a() const;
INLINE CPT(TransformState) get_frame_b() const;
CPT(TransformState) get_frame_a() const;
CPT(TransformState) get_frame_b() const;
MAKE_PROPERTY(linear_pos, get_linear_pos);
MAKE_PROPERTY(angular_pos, get_angular_pos);

View File

@ -18,439 +18,3 @@ INLINE BulletSoftBodyConfig::
~BulletSoftBodyConfig() {
}
/**
* Getter for property kVCF.
*/
INLINE PN_stdfloat BulletSoftBodyConfig::
get_velocities_correction_factor() const {
return (PN_stdfloat)_cfg.kVCF;
}
/**
* Setter for property kVCF.
*/
INLINE void BulletSoftBodyConfig::
set_velocities_correction_factor(PN_stdfloat value) {
_cfg.kVCF = (btScalar)value;
}
/**
* Getter for property kDP.
*/
INLINE PN_stdfloat BulletSoftBodyConfig::
get_damping_coefficient() const {
return (PN_stdfloat)_cfg.kDP;
}
/**
* Setter for property kDP.
*/
INLINE void BulletSoftBodyConfig::
set_damping_coefficient(PN_stdfloat value) {
_cfg.kDP = (btScalar)value;
}
/**
* Getter for property kDG.
*/
INLINE PN_stdfloat BulletSoftBodyConfig::
get_drag_coefficient() const {
return (PN_stdfloat)_cfg.kDG;
}
/**
* Setter for property kDG.
*/
INLINE void BulletSoftBodyConfig::
set_drag_coefficient(PN_stdfloat value) {
_cfg.kDG = (btScalar)value;
}
/**
* Getter for property kLF.
*/
INLINE PN_stdfloat BulletSoftBodyConfig::
get_lift_coefficient() const {
return (PN_stdfloat)_cfg.kLF;
}
/**
* Setter for property kLF.
*/
INLINE void BulletSoftBodyConfig::
set_lift_coefficient(PN_stdfloat value) {
_cfg.kLF = (btScalar)value;
}
/**
* Getter for property kPR.
*/
INLINE PN_stdfloat BulletSoftBodyConfig::
get_pressure_coefficient() const {
return (PN_stdfloat)_cfg.kPR;
}
/**
* Setter for property kPR.
*/
INLINE void BulletSoftBodyConfig::
set_pressure_coefficient(PN_stdfloat value) {
_cfg.kPR = (btScalar)value;
}
/**
* Getter for property kVC.
*/
INLINE PN_stdfloat BulletSoftBodyConfig::
get_volume_conservation_coefficient() const {
return (PN_stdfloat)_cfg.kVC;
}
/**
* Setter for property kVC.
*/
INLINE void BulletSoftBodyConfig::
set_volume_conservation_coefficient(PN_stdfloat value) {
_cfg.kVC = (btScalar)value;
}
/**
* Getter for property kDF.
*/
INLINE PN_stdfloat BulletSoftBodyConfig::
get_dynamic_friction_coefficient() const {
return (PN_stdfloat)_cfg.kDF;
}
/**
* Setter for property kDF.
*/
INLINE void BulletSoftBodyConfig::
set_dynamic_friction_coefficient(PN_stdfloat value) {
_cfg.kDF = (btScalar)value;
}
/**
* Getter for property kMT.
*/
INLINE PN_stdfloat BulletSoftBodyConfig::
get_pose_matching_coefficient() const {
return (PN_stdfloat)_cfg.kMT;
}
/**
* Setter for property kMT.
*/
INLINE void BulletSoftBodyConfig::
set_pose_matching_coefficient(PN_stdfloat value) {
_cfg.kMT = (btScalar)value;
}
/**
* Getter for property kCHR.
*/
INLINE PN_stdfloat BulletSoftBodyConfig::
get_rigid_contacts_hardness() const {
return (PN_stdfloat)_cfg.kCHR;
}
/**
* Setter for property kCHR.
*/
INLINE void BulletSoftBodyConfig::
set_rigid_contacts_hardness(PN_stdfloat value) {
_cfg.kCHR = (btScalar)value;
}
/**
* Getter for property kKHR.
*/
INLINE PN_stdfloat BulletSoftBodyConfig::
get_kinetic_contacts_hardness() const {
return (PN_stdfloat)_cfg.kKHR;
}
/**
* Setter for property kKHR.
*/
INLINE void BulletSoftBodyConfig::
set_kinetic_contacts_hardness(PN_stdfloat value) {
_cfg.kKHR = (btScalar)value;
}
/**
* Getter for property kSHR.
*/
INLINE PN_stdfloat BulletSoftBodyConfig::
get_soft_contacts_hardness() const {
return (PN_stdfloat)_cfg.kSHR;
}
/**
* Setter for property kSHR.
*/
INLINE void BulletSoftBodyConfig::
set_soft_contacts_hardness(PN_stdfloat value) {
_cfg.kSHR = (btScalar)value;
}
/**
* Getter for property kAHR.
*/
INLINE PN_stdfloat BulletSoftBodyConfig::
get_anchors_hardness() const {
return (PN_stdfloat)_cfg.kAHR;
}
/**
* Setter for property kAHR.
*/
INLINE void BulletSoftBodyConfig::
set_anchors_hardness(PN_stdfloat value) {
_cfg.kAHR = (btScalar)value;
}
/**
* Getter for property kSRHR_CL.
*/
INLINE PN_stdfloat BulletSoftBodyConfig::
get_soft_vs_rigid_hardness() const {
return (PN_stdfloat)_cfg.kSRHR_CL;
}
/**
* Setter for property kSRHR_CL.
*/
INLINE void BulletSoftBodyConfig::
set_soft_vs_rigid_hardness(PN_stdfloat value) {
_cfg.kSRHR_CL = (btScalar)value;
}
/**
* Getter for property kSKHR_CL.
*/
INLINE PN_stdfloat BulletSoftBodyConfig::
get_soft_vs_kinetic_hardness() const {
return (PN_stdfloat)_cfg.kSKHR_CL;
}
/**
* Setter for property kSKHR_CL.
*/
INLINE void BulletSoftBodyConfig::
set_soft_vs_kinetic_hardness(PN_stdfloat value) {
_cfg.kSKHR_CL = (btScalar)value;
}
/**
* Getter for property kSSHR_CL.
*/
INLINE PN_stdfloat BulletSoftBodyConfig::
get_soft_vs_soft_hardness() const {
return (PN_stdfloat)_cfg.kSSHR_CL;
}
/**
* Setter for property kSSHR_CL.
*/
INLINE void BulletSoftBodyConfig::
set_soft_vs_soft_hardness(PN_stdfloat value) {
_cfg.kSSHR_CL = (btScalar)value;
}
/**
* Getter for property kSR_SPLT_CL.
*/
INLINE PN_stdfloat BulletSoftBodyConfig::
get_soft_vs_rigid_impulse_split() const {
return (PN_stdfloat)_cfg.kSR_SPLT_CL;
}
/**
* Setter for property kSR_SPLT_CL.
*/
INLINE void BulletSoftBodyConfig::
set_soft_vs_rigid_impulse_split(PN_stdfloat value) {
_cfg.kSR_SPLT_CL = (btScalar)value;
}
/**
* Getter for property kSK_SPLT_CL.
*/
INLINE PN_stdfloat BulletSoftBodyConfig::
get_soft_vs_kinetic_impulse_split() const {
return (PN_stdfloat)_cfg.kSK_SPLT_CL;
}
/**
* Setter for property kSK_SPLT_CL.
*/
INLINE void BulletSoftBodyConfig::
set_soft_vs_kinetic_impulse_split(PN_stdfloat value) {
_cfg.kSK_SPLT_CL = (btScalar)value;
}
/**
* Getter for property kSS_SPLT_CL.
*/
INLINE PN_stdfloat BulletSoftBodyConfig::
get_soft_vs_soft_impulse_split() const {
return (PN_stdfloat)_cfg.kSS_SPLT_CL;
}
/**
* Setter for property kSS_SPLT_CL.
*/
INLINE void BulletSoftBodyConfig::
set_soft_vs_soft_impulse_split(PN_stdfloat value) {
_cfg.kSS_SPLT_CL = (btScalar)value;
}
/**
* Getter for property maxvolume.
*/
INLINE PN_stdfloat BulletSoftBodyConfig::
get_maxvolume() const {
return (PN_stdfloat)_cfg.maxvolume;
}
/**
* Setter for property maxvolume.
*/
INLINE void BulletSoftBodyConfig::
set_maxvolume(PN_stdfloat value) {
_cfg.maxvolume = (btScalar)value;
}
/**
* Getter for property timescale.
*/
INLINE PN_stdfloat BulletSoftBodyConfig::
get_timescale() const {
return (PN_stdfloat)_cfg.timescale;
}
/**
* Setter for property timescale.
*/
INLINE void BulletSoftBodyConfig::
set_timescale(PN_stdfloat value) {
_cfg.timescale = (btScalar)value;
}
/**
* Getter for property piterations.
*/
INLINE int BulletSoftBodyConfig::
get_positions_solver_iterations() const {
return _cfg.piterations;
}
/**
* Setter for property piterations.
*/
INLINE void BulletSoftBodyConfig::
set_positions_solver_iterations(int value) {
nassertv(value > 0);
_cfg.piterations = value;
}
/**
* Getter for property viterations.
*/
INLINE int BulletSoftBodyConfig::
get_velocities_solver_iterations() const {
return _cfg.viterations;
}
/**
* Setter for property viterations.
*/
INLINE void BulletSoftBodyConfig::
set_velocities_solver_iterations(int value) {
nassertv(value > 0);
_cfg.viterations = value;
}
/**
* Getter for property diterations.
*/
INLINE int BulletSoftBodyConfig::
get_drift_solver_iterations() const {
return _cfg.diterations;
}
/**
* Setter for property diterations.
*/
INLINE void BulletSoftBodyConfig::
set_drift_solver_iterations(int value) {
nassertv(value > 0);
_cfg.diterations = value;
}
/**
* Getter for property citerations.
*/
INLINE int BulletSoftBodyConfig::
get_cluster_solver_iterations() const {
return _cfg.citerations;
}
/**
* Setter for property citerations.
*/
INLINE void BulletSoftBodyConfig::
set_cluster_solver_iterations(int value) {
nassertv(value > 0);
_cfg.citerations = value;
}

View File

@ -26,6 +26,7 @@ BulletSoftBodyConfig(btSoftBody::Config &cfg) : _cfg(cfg) {
*/
void BulletSoftBodyConfig::
clear_all_collision_flags() {
LightMutexHolder holder(BulletWorld::get_global_lock());
_cfg.collisions = 0;
}
@ -35,6 +36,7 @@ clear_all_collision_flags() {
*/
void BulletSoftBodyConfig::
set_collision_flag(CollisionFlag flag, bool value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
if (value == true) {
_cfg.collisions |= flag;
@ -49,6 +51,7 @@ set_collision_flag(CollisionFlag flag, bool value) {
*/
bool BulletSoftBodyConfig::
get_collision_flag(CollisionFlag flag) const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (_cfg.collisions & flag) ? true : false;
}
@ -58,6 +61,7 @@ get_collision_flag(CollisionFlag flag) const {
*/
void BulletSoftBodyConfig::
set_aero_model(AeroModel value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_cfg.aeromodel = (btSoftBody::eAeroModel::_)value;
}
@ -67,6 +71,491 @@ set_aero_model(AeroModel value) {
*/
BulletSoftBodyConfig::AeroModel BulletSoftBodyConfig::
get_aero_model() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (AeroModel)_cfg.aeromodel;
}
/**
* Getter for property kVCF.
*/
PN_stdfloat BulletSoftBodyConfig::
get_velocities_correction_factor() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_cfg.kVCF;
}
/**
* Setter for property kVCF.
*/
void BulletSoftBodyConfig::
set_velocities_correction_factor(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_cfg.kVCF = (btScalar)value;
}
/**
* Getter for property kDP.
*/
PN_stdfloat BulletSoftBodyConfig::
get_damping_coefficient() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_cfg.kDP;
}
/**
* Setter for property kDP.
*/
void BulletSoftBodyConfig::
set_damping_coefficient(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_cfg.kDP = (btScalar)value;
}
/**
* Getter for property kDG.
*/
PN_stdfloat BulletSoftBodyConfig::
get_drag_coefficient() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_cfg.kDG;
}
/**
* Setter for property kDG.
*/
void BulletSoftBodyConfig::
set_drag_coefficient(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_cfg.kDG = (btScalar)value;
}
/**
* Getter for property kLF.
*/
PN_stdfloat BulletSoftBodyConfig::
get_lift_coefficient() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_cfg.kLF;
}
/**
* Setter for property kLF.
*/
void BulletSoftBodyConfig::
set_lift_coefficient(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_cfg.kLF = (btScalar)value;
}
/**
* Getter for property kPR.
*/
PN_stdfloat BulletSoftBodyConfig::
get_pressure_coefficient() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_cfg.kPR;
}
/**
* Setter for property kPR.
*/
void BulletSoftBodyConfig::
set_pressure_coefficient(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_cfg.kPR = (btScalar)value;
}
/**
* Getter for property kVC.
*/
PN_stdfloat BulletSoftBodyConfig::
get_volume_conservation_coefficient() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_cfg.kVC;
}
/**
* Setter for property kVC.
*/
void BulletSoftBodyConfig::
set_volume_conservation_coefficient(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_cfg.kVC = (btScalar)value;
}
/**
* Getter for property kDF.
*/
PN_stdfloat BulletSoftBodyConfig::
get_dynamic_friction_coefficient() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_cfg.kDF;
}
/**
* Setter for property kDF.
*/
void BulletSoftBodyConfig::
set_dynamic_friction_coefficient(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_cfg.kDF = (btScalar)value;
}
/**
* Getter for property kMT.
*/
PN_stdfloat BulletSoftBodyConfig::
get_pose_matching_coefficient() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_cfg.kMT;
}
/**
* Setter for property kMT.
*/
void BulletSoftBodyConfig::
set_pose_matching_coefficient(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_cfg.kMT = (btScalar)value;
}
/**
* Getter for property kCHR.
*/
PN_stdfloat BulletSoftBodyConfig::
get_rigid_contacts_hardness() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_cfg.kCHR;
}
/**
* Setter for property kCHR.
*/
void BulletSoftBodyConfig::
set_rigid_contacts_hardness(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_cfg.kCHR = (btScalar)value;
}
/**
* Getter for property kKHR.
*/
PN_stdfloat BulletSoftBodyConfig::
get_kinetic_contacts_hardness() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_cfg.kKHR;
}
/**
* Setter for property kKHR.
*/
void BulletSoftBodyConfig::
set_kinetic_contacts_hardness(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_cfg.kKHR = (btScalar)value;
}
/**
* Getter for property kSHR.
*/
PN_stdfloat BulletSoftBodyConfig::
get_soft_contacts_hardness() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_cfg.kSHR;
}
/**
* Setter for property kSHR.
*/
void BulletSoftBodyConfig::
set_soft_contacts_hardness(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_cfg.kSHR = (btScalar)value;
}
/**
* Getter for property kAHR.
*/
PN_stdfloat BulletSoftBodyConfig::
get_anchors_hardness() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_cfg.kAHR;
}
/**
* Setter for property kAHR.
*/
void BulletSoftBodyConfig::
set_anchors_hardness(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_cfg.kAHR = (btScalar)value;
}
/**
* Getter for property kSRHR_CL.
*/
PN_stdfloat BulletSoftBodyConfig::
get_soft_vs_rigid_hardness() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_cfg.kSRHR_CL;
}
/**
* Setter for property kSRHR_CL.
*/
void BulletSoftBodyConfig::
set_soft_vs_rigid_hardness(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_cfg.kSRHR_CL = (btScalar)value;
}
/**
* Getter for property kSKHR_CL.
*/
PN_stdfloat BulletSoftBodyConfig::
get_soft_vs_kinetic_hardness() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_cfg.kSKHR_CL;
}
/**
* Setter for property kSKHR_CL.
*/
void BulletSoftBodyConfig::
set_soft_vs_kinetic_hardness(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_cfg.kSKHR_CL = (btScalar)value;
}
/**
* Getter for property kSSHR_CL.
*/
PN_stdfloat BulletSoftBodyConfig::
get_soft_vs_soft_hardness() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_cfg.kSSHR_CL;
}
/**
* Setter for property kSSHR_CL.
*/
void BulletSoftBodyConfig::
set_soft_vs_soft_hardness(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_cfg.kSSHR_CL = (btScalar)value;
}
/**
* Getter for property kSR_SPLT_CL.
*/
PN_stdfloat BulletSoftBodyConfig::
get_soft_vs_rigid_impulse_split() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_cfg.kSR_SPLT_CL;
}
/**
* Setter for property kSR_SPLT_CL.
*/
void BulletSoftBodyConfig::
set_soft_vs_rigid_impulse_split(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_cfg.kSR_SPLT_CL = (btScalar)value;
}
/**
* Getter for property kSK_SPLT_CL.
*/
PN_stdfloat BulletSoftBodyConfig::
get_soft_vs_kinetic_impulse_split() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_cfg.kSK_SPLT_CL;
}
/**
* Setter for property kSK_SPLT_CL.
*/
void BulletSoftBodyConfig::
set_soft_vs_kinetic_impulse_split(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_cfg.kSK_SPLT_CL = (btScalar)value;
}
/**
* Getter for property kSS_SPLT_CL.
*/
PN_stdfloat BulletSoftBodyConfig::
get_soft_vs_soft_impulse_split() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_cfg.kSS_SPLT_CL;
}
/**
* Setter for property kSS_SPLT_CL.
*/
void BulletSoftBodyConfig::
set_soft_vs_soft_impulse_split(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_cfg.kSS_SPLT_CL = (btScalar)value;
}
/**
* Getter for property maxvolume.
*/
PN_stdfloat BulletSoftBodyConfig::
get_maxvolume() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_cfg.maxvolume;
}
/**
* Setter for property maxvolume.
*/
void BulletSoftBodyConfig::
set_maxvolume(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_cfg.maxvolume = (btScalar)value;
}
/**
* Getter for property timescale.
*/
PN_stdfloat BulletSoftBodyConfig::
get_timescale() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_cfg.timescale;
}
/**
* Setter for property timescale.
*/
void BulletSoftBodyConfig::
set_timescale(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_cfg.timescale = (btScalar)value;
}
/**
* Getter for property piterations.
*/
int BulletSoftBodyConfig::
get_positions_solver_iterations() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _cfg.piterations;
}
/**
* Setter for property piterations.
*/
void BulletSoftBodyConfig::
set_positions_solver_iterations(int value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertv(value > 0);
_cfg.piterations = value;
}
/**
* Getter for property viterations.
*/
int BulletSoftBodyConfig::
get_velocities_solver_iterations() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _cfg.viterations;
}
/**
* Setter for property viterations.
*/
void BulletSoftBodyConfig::
set_velocities_solver_iterations(int value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertv(value > 0);
_cfg.viterations = value;
}
/**
* Getter for property diterations.
*/
int BulletSoftBodyConfig::
get_drift_solver_iterations() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _cfg.diterations;
}
/**
* Setter for property diterations.
*/
void BulletSoftBodyConfig::
set_drift_solver_iterations(int value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertv(value > 0);
_cfg.diterations = value;
}
/**
* Getter for property citerations.
*/
int BulletSoftBodyConfig::
get_cluster_solver_iterations() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return _cfg.citerations;
}
/**
* Setter for property citerations.
*/
void BulletSoftBodyConfig::
set_cluster_solver_iterations(int value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertv(value > 0);
_cfg.citerations = value;
}

View File

@ -51,55 +51,55 @@ PUBLISHED:
void set_aero_model(AeroModel value);
AeroModel get_aero_model() const;
INLINE void set_velocities_correction_factor(PN_stdfloat value);
INLINE void set_damping_coefficient(PN_stdfloat value);
INLINE void set_drag_coefficient(PN_stdfloat value);
INLINE void set_lift_coefficient(PN_stdfloat value);
INLINE void set_pressure_coefficient(PN_stdfloat value);
INLINE void set_volume_conservation_coefficient(PN_stdfloat value);
INLINE void set_dynamic_friction_coefficient(PN_stdfloat value);
INLINE void set_pose_matching_coefficient(PN_stdfloat value);
INLINE void set_rigid_contacts_hardness(PN_stdfloat value);
INLINE void set_kinetic_contacts_hardness(PN_stdfloat value);
INLINE void set_soft_contacts_hardness(PN_stdfloat value);
INLINE void set_anchors_hardness(PN_stdfloat value);
INLINE void set_soft_vs_rigid_hardness(PN_stdfloat value);
INLINE void set_soft_vs_kinetic_hardness(PN_stdfloat value);
INLINE void set_soft_vs_soft_hardness(PN_stdfloat value);
INLINE void set_soft_vs_rigid_impulse_split(PN_stdfloat value);
INLINE void set_soft_vs_kinetic_impulse_split(PN_stdfloat value);
INLINE void set_soft_vs_soft_impulse_split(PN_stdfloat value);
INLINE void set_maxvolume(PN_stdfloat value);
INLINE void set_timescale(PN_stdfloat value);
INLINE void set_positions_solver_iterations(int value);
INLINE void set_velocities_solver_iterations(int value);
INLINE void set_drift_solver_iterations( int value);
INLINE void set_cluster_solver_iterations(int value);
void set_velocities_correction_factor(PN_stdfloat value);
void set_damping_coefficient(PN_stdfloat value);
void set_drag_coefficient(PN_stdfloat value);
void set_lift_coefficient(PN_stdfloat value);
void set_pressure_coefficient(PN_stdfloat value);
void set_volume_conservation_coefficient(PN_stdfloat value);
void set_dynamic_friction_coefficient(PN_stdfloat value);
void set_pose_matching_coefficient(PN_stdfloat value);
void set_rigid_contacts_hardness(PN_stdfloat value);
void set_kinetic_contacts_hardness(PN_stdfloat value);
void set_soft_contacts_hardness(PN_stdfloat value);
void set_anchors_hardness(PN_stdfloat value);
void set_soft_vs_rigid_hardness(PN_stdfloat value);
void set_soft_vs_kinetic_hardness(PN_stdfloat value);
void set_soft_vs_soft_hardness(PN_stdfloat value);
void set_soft_vs_rigid_impulse_split(PN_stdfloat value);
void set_soft_vs_kinetic_impulse_split(PN_stdfloat value);
void set_soft_vs_soft_impulse_split(PN_stdfloat value);
void set_maxvolume(PN_stdfloat value);
void set_timescale(PN_stdfloat value);
void set_positions_solver_iterations(int value);
void set_velocities_solver_iterations(int value);
void set_drift_solver_iterations( int value);
void set_cluster_solver_iterations(int value);
INLINE PN_stdfloat get_velocities_correction_factor() const;
INLINE PN_stdfloat get_damping_coefficient() const;
INLINE PN_stdfloat get_drag_coefficient() const;
INLINE PN_stdfloat get_lift_coefficient() const;
INLINE PN_stdfloat get_pressure_coefficient() const;
INLINE PN_stdfloat get_volume_conservation_coefficient() const;
INLINE PN_stdfloat get_dynamic_friction_coefficient() const;
INLINE PN_stdfloat get_pose_matching_coefficient() const;
INLINE PN_stdfloat get_rigid_contacts_hardness() const;
INLINE PN_stdfloat get_kinetic_contacts_hardness() const;
INLINE PN_stdfloat get_soft_contacts_hardness() const;
INLINE PN_stdfloat get_anchors_hardness() const;
INLINE PN_stdfloat get_soft_vs_rigid_hardness() const;
INLINE PN_stdfloat get_soft_vs_kinetic_hardness() const;
INLINE PN_stdfloat get_soft_vs_soft_hardness() const;
INLINE PN_stdfloat get_soft_vs_rigid_impulse_split() const;
INLINE PN_stdfloat get_soft_vs_kinetic_impulse_split() const;
INLINE PN_stdfloat get_soft_vs_soft_impulse_split() const;
INLINE PN_stdfloat get_maxvolume() const;
INLINE PN_stdfloat get_timescale() const;
INLINE int get_positions_solver_iterations() const;
INLINE int get_velocities_solver_iterations() const;
INLINE int get_drift_solver_iterations() const;
INLINE int get_cluster_solver_iterations() const;
PN_stdfloat get_velocities_correction_factor() const;
PN_stdfloat get_damping_coefficient() const;
PN_stdfloat get_drag_coefficient() const;
PN_stdfloat get_lift_coefficient() const;
PN_stdfloat get_pressure_coefficient() const;
PN_stdfloat get_volume_conservation_coefficient() const;
PN_stdfloat get_dynamic_friction_coefficient() const;
PN_stdfloat get_pose_matching_coefficient() const;
PN_stdfloat get_rigid_contacts_hardness() const;
PN_stdfloat get_kinetic_contacts_hardness() const;
PN_stdfloat get_soft_contacts_hardness() const;
PN_stdfloat get_anchors_hardness() const;
PN_stdfloat get_soft_vs_rigid_hardness() const;
PN_stdfloat get_soft_vs_kinetic_hardness() const;
PN_stdfloat get_soft_vs_soft_hardness() const;
PN_stdfloat get_soft_vs_rigid_impulse_split() const;
PN_stdfloat get_soft_vs_kinetic_impulse_split() const;
PN_stdfloat get_soft_vs_soft_impulse_split() const;
PN_stdfloat get_maxvolume() const;
PN_stdfloat get_timescale() const;
int get_positions_solver_iterations() const;
int get_velocities_solver_iterations() const;
int get_drift_solver_iterations() const;
int get_cluster_solver_iterations() const;
MAKE_PROPERTY(aero_model, get_aero_model, set_aero_model);
MAKE_PROPERTY(velocities_correction_factor, get_velocities_correction_factor, set_velocities_correction_factor);

View File

@ -30,66 +30,3 @@ empty() {
return BulletSoftBodyMaterial(material);
}
/**
*
*/
INLINE btSoftBody::Material &BulletSoftBodyMaterial::
get_material() const {
return _material;
}
/**
* Getter for the property m_kLST.
*/
INLINE PN_stdfloat BulletSoftBodyMaterial::
get_linear_stiffness() const {
return (PN_stdfloat)_material.m_kLST;
}
/**
* Setter for the property m_kLST.
*/
INLINE void BulletSoftBodyMaterial::
set_linear_stiffness(PN_stdfloat value) {
_material.m_kLST = (btScalar)value;
}
/**
* Getter for the property m_kAST.
*/
INLINE PN_stdfloat BulletSoftBodyMaterial::
get_angular_stiffness() const {
return (PN_stdfloat)_material.m_kAST;
}
/**
* Setter for the property m_kAST.
*/
INLINE void BulletSoftBodyMaterial::
set_angular_stiffness(PN_stdfloat value) {
_material.m_kAST = (btScalar)value;
}
/**
* Getter for the property m_kVST.
*/
INLINE PN_stdfloat BulletSoftBodyMaterial::
get_volume_preservation() const {
return (PN_stdfloat)_material.m_kVST;
}
/**
* Setter for the property m_kVST.
*/
INLINE void BulletSoftBodyMaterial::
set_volume_preservation(PN_stdfloat value) {
_material.m_kVST = (btScalar)value;
}

View File

@ -20,3 +20,72 @@ BulletSoftBodyMaterial::
BulletSoftBodyMaterial(btSoftBody::Material &material) : _material(material) {
}
/**
*
*/
btSoftBody::Material &BulletSoftBodyMaterial::
get_material() const {
return _material;
}
/**
* Getter for the property m_kLST.
*/
PN_stdfloat BulletSoftBodyMaterial::
get_linear_stiffness() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_material.m_kLST;
}
/**
* Setter for the property m_kLST.
*/
void BulletSoftBodyMaterial::
set_linear_stiffness(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_material.m_kLST = (btScalar)value;
}
/**
* Getter for the property m_kAST.
*/
PN_stdfloat BulletSoftBodyMaterial::
get_angular_stiffness() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_material.m_kAST;
}
/**
* Setter for the property m_kAST.
*/
void BulletSoftBodyMaterial::
set_angular_stiffness(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_material.m_kAST = (btScalar)value;
}
/**
* Getter for the property m_kVST.
*/
PN_stdfloat BulletSoftBodyMaterial::
get_volume_preservation() const {
LightMutexHolder holder(BulletWorld::get_global_lock());
return (PN_stdfloat)_material.m_kVST;
}
/**
* Setter for the property m_kVST.
*/
void BulletSoftBodyMaterial::
set_volume_preservation(PN_stdfloat value) {
LightMutexHolder holder(BulletWorld::get_global_lock());
_material.m_kVST = (btScalar)value;
}

Some files were not shown because too many files have changed in this diff Show More