00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
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
00027
00028
00029
00030 void PhysxContactReport::
00031 enable() {
00032
00033 _enabled = true;
00034 }
00035
00036
00037
00038
00039
00040
00041 void PhysxContactReport::
00042 disable() {
00043
00044 _enabled = false;
00045 }
00046
00047
00048
00049
00050
00051
00052 bool PhysxContactReport::
00053 is_enabled() const {
00054
00055 return _enabled;
00056 }
00057
00058
00059
00060
00061
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