Panda3D

Loading...
Searching...
No Matches
physxTriggerReport.cxx
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file physxTriggerReport.cxx
10 * @author enn0x
11 * @date 2009-09-19
12 */
13
14#include "physxTriggerReport.h"
15
16#include "event.h"
17#include "eventQueue.h"
18#include "eventParameter.h"
19
20 PStatCollector PhysxTriggerReport::_pcollector("App:PhysX:Trigger Reporting");
21
22/**
23 *
24 */
25 void PhysxTriggerReport::
26enable() {
27
28 _enabled = true;
29}
30
31/**
32 *
33 */
34 void PhysxTriggerReport::
35disable() {
36
37 _enabled = false;
38}
39
40/**
41 *
42 */
43 bool PhysxTriggerReport::
44is_enabled() const {
45
46 return _enabled;
47}
48
49/**
50 *
51 */
52 void PhysxTriggerReport::
53onTrigger(NxShape &triggerShape, NxShape &otherShape, NxTriggerFlag status) {
54
55 if (!_enabled) {
56 return;
57 }
58
59 _pcollector.start();
60
61 Event *event;
62 if (status & NX_TRIGGER_ON_ENTER) {
63 event = new Event("physx-trigger-enter");
64 }
65 else if (status & NX_TRIGGER_ON_LEAVE) {
66 event = new Event("physx-trigger-leave");
67 }
68 else if (status & NX_TRIGGER_ON_STAY) {
69 event = new Event("physx-trigger-stay");
70 }
71 else {
72 return;
73 }
74
75 PT(PhysxShape) pTriggerShape = (PhysxShape *)triggerShape.userData;
76 PT(PhysxShape) pOtherShape = (PhysxShape *)otherShape.userData;
77 event->add_parameter(EventParameter(pTriggerShape));
78 event->add_parameter(EventParameter(pOtherShape));
79
80 EventQueue::get_global_event_queue()->queue_event(event);
81
82 _pcollector.stop();
83}
EventQueue::get_global_event_queue
static EventQueue * get_global_event_queue()
Returns a pointer to the one global EventQueue object.
Definition eventQueue.I:19
PStatCollector
A lightweight class that represents a single element that may be timed and/or counted via stats.
Definition pStatCollector.h:43
eventParameter.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
eventQueue.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
event.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
physxTriggerReport.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.