forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathodeBody_ext.cxx
More file actions
37 lines (32 loc) · 900 Bytes
/
odeBody_ext.cxx
File metadata and controls
37 lines (32 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file odeBody_ext.cxx
* @author rdb
* @date 2018-11-06
*/
#include "odeBody_ext.h"
static void destroy_callback(OdeBody &body) {
Py_XDECREF((PyObject *)body.get_data());
}
/**
* Sets custom data to be associated with the OdeBody.
*/
void Extension<OdeBody>::
set_data(PyObject *data) {
void *old_data = _this->get_data();
if (data != nullptr && data != Py_None) {
Py_INCREF(data);
_this->set_data((void *)data);
_this->_destroy_callback = &destroy_callback;
} else {
_this->set_data(nullptr);
_this->_destroy_callback = nullptr;
}
Py_XDECREF((PyObject *)old_data);
}