Panda3D
|
00001 // Filename: physxContactReport.cxx 00002 // Created by: enn0x (19Sep09) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "physxContactReport.h" 00016 #include "physxContactPair.h" 00017 #include "physxManager.h" 00018 00019 #include "event.h" 00020 #include "eventQueue.h" 00021 #include "eventParameter.h" 00022 00023 PStatCollector PhysxContactReport::_pcollector("App:PhysX:Contact Reporting"); 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Function: PhysxContactReport::enable 00027 // Access: Public 00028 // Description: 00029 //////////////////////////////////////////////////////////////////// 00030 void PhysxContactReport:: 00031 enable() { 00032 00033 _enabled = true; 00034 } 00035 00036 //////////////////////////////////////////////////////////////////// 00037 // Function: PhysxContactReport::disable 00038 // Access: Public 00039 // Description: 00040 //////////////////////////////////////////////////////////////////// 00041 void PhysxContactReport:: 00042 disable() { 00043 00044 _enabled = false; 00045 } 00046 00047 //////////////////////////////////////////////////////////////////// 00048 // Function: PhysxContactReport::is_enabled 00049 // Access: Public 00050 // Description: 00051 //////////////////////////////////////////////////////////////////// 00052 bool PhysxContactReport:: 00053 is_enabled() const { 00054 00055 return _enabled; 00056 } 00057 00058 //////////////////////////////////////////////////////////////////// 00059 // Function: PhysxContactReport::onContactNotify 00060 // Access: Public 00061 // Description: 00062 //////////////////////////////////////////////////////////////////// 00063 void PhysxContactReport:: 00064 onContactNotify(NxContactPair &pair, NxU32 flags) { 00065 00066 if (!_enabled) { 00067 return; 00068 } 00069 00070 _pcollector.start(); 00071 00072 Event *event; 00073 if (flags & NX_NOTIFY_ON_START_TOUCH) { 00074 event = new Event("physx-contact-start"); 00075 } 00076 else if (flags & NX_NOTIFY_ON_END_TOUCH) { 00077 event = new Event("physx-contact-stop"); 00078 } 00079 else if (flags & NX_NOTIFY_ON_TOUCH) { 00080 event = new Event("physx-contact-touch"); 00081 } 00082 else if (flags & NX_NOTIFY_ON_START_TOUCH_FORCE_THRESHOLD) { 00083 event = new Event("physx-contact-start-force-threshold"); 00084 } 00085 else if (flags & NX_NOTIFY_ON_END_TOUCH_FORCE_THRESHOLD) { 00086 event = new Event("physx-contact-stop-force-threshold"); 00087 } 00088 else if (flags & NX_NOTIFY_ON_TOUCH_FORCE_THRESHOLD) { 00089 event = new Event("physx-contact-touch-force-threshold"); 00090 } 00091 else { 00092 return; 00093 } 00094 00095 PT(PhysxContactPair) ppair = new PhysxContactPair(pair); 00096 event->add_parameter(EventParameter(ppair)); 00097 EventQueue::get_global_event_queue()->queue_event(event); 00098 00099 _pcollector.stop(); 00100 } 00101