mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 01:07:51 -04:00
parent
186d8feef4
commit
ca5b4e7b54
@ -83,7 +83,7 @@ PUBLISHED:
|
|||||||
INLINE void set_feedback(bool flag = true);
|
INLINE void set_feedback(bool flag = true);
|
||||||
INLINE OdeJointFeedback *get_feedback();
|
INLINE OdeJointFeedback *get_feedback();
|
||||||
|
|
||||||
EXTENSION(void attach(const OdeBody *body1, const OdeBody *body2));
|
EXTENSION(void attach(PyObject *body1, PyObject *body2));
|
||||||
void attach_bodies(const OdeBody &body1, const OdeBody &body2);
|
void attach_bodies(const OdeBody &body1, const OdeBody &body2);
|
||||||
void attach_body(const OdeBody &body, int index);
|
void attach_body(const OdeBody &body, int index);
|
||||||
void detach();
|
void detach();
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "odePlane2dJoint.h"
|
#include "odePlane2dJoint.h"
|
||||||
|
|
||||||
#ifndef CPPPARSER
|
#ifndef CPPPARSER
|
||||||
|
extern Dtool_PyTypedObject Dtool_OdeBody;
|
||||||
extern Dtool_PyTypedObject Dtool_OdeJoint;
|
extern Dtool_PyTypedObject Dtool_OdeJoint;
|
||||||
extern Dtool_PyTypedObject Dtool_OdeBallJoint;
|
extern Dtool_PyTypedObject Dtool_OdeBallJoint;
|
||||||
extern Dtool_PyTypedObject Dtool_OdeHingeJoint;
|
extern Dtool_PyTypedObject Dtool_OdeHingeJoint;
|
||||||
@ -48,7 +49,23 @@ extern Dtool_PyTypedObject Dtool_OdePlane2dJoint;
|
|||||||
* attached to the environment.
|
* attached to the environment.
|
||||||
*/
|
*/
|
||||||
void Extension<OdeJoint>::
|
void Extension<OdeJoint>::
|
||||||
attach(const OdeBody *body1, const OdeBody *body2) {
|
attach(PyObject *param1, PyObject *param2) {
|
||||||
|
const OdeBody *body1 = nullptr;
|
||||||
|
if (param1 != Py_None) {
|
||||||
|
body1 = (const OdeBody *)DTOOL_Call_GetPointerThisClass(param1, &Dtool_OdeBody, 1, "OdeJoint.attach", true, true);
|
||||||
|
if (body1 == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const OdeBody *body2 = nullptr;
|
||||||
|
if (param2 != Py_None) {
|
||||||
|
body2 = (const OdeBody *)DTOOL_Call_GetPointerThisClass(param2, &Dtool_OdeBody, 2, "OdeJoint.attach", true, true);
|
||||||
|
if (body2 == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (body1 && body2) {
|
if (body1 && body2) {
|
||||||
_this->attach_bodies(*body1, *body2);
|
_this->attach_bodies(*body1, *body2);
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
template<>
|
template<>
|
||||||
class Extension<OdeJoint> : public ExtensionBase<OdeJoint> {
|
class Extension<OdeJoint> : public ExtensionBase<OdeJoint> {
|
||||||
public:
|
public:
|
||||||
void attach(const OdeBody *body1, const OdeBody *body2);
|
void attach(PyObject *body1, PyObject *body2);
|
||||||
|
|
||||||
PyObject *convert() const;
|
PyObject *convert() const;
|
||||||
};
|
};
|
||||||
|
7
tests/ode/conftest.py
Normal file
7
tests/ode/conftest.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def world():
|
||||||
|
ode = pytest.importorskip("panda3d.ode")
|
||||||
|
return ode.OdeWorld()
|
43
tests/ode/test_ode_joints.py
Normal file
43
tests/ode/test_ode_joints.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
def test_odejoint_attach_both(world):
|
||||||
|
from panda3d import ode
|
||||||
|
|
||||||
|
body1 = ode.OdeBody(world)
|
||||||
|
body2 = ode.OdeBody(world)
|
||||||
|
|
||||||
|
assert len(body1.joints) == 0
|
||||||
|
assert len(body2.joints) == 0
|
||||||
|
|
||||||
|
joint = ode.OdeBallJoint(world)
|
||||||
|
joint.attach(body1, body2)
|
||||||
|
|
||||||
|
assert tuple(body1.joints) == (joint,)
|
||||||
|
assert tuple(body2.joints) == (joint,)
|
||||||
|
|
||||||
|
|
||||||
|
def test_odejoint_attach_0(world):
|
||||||
|
from panda3d import ode
|
||||||
|
|
||||||
|
body = ode.OdeBody(world)
|
||||||
|
|
||||||
|
assert len(body.joints) == 0
|
||||||
|
|
||||||
|
joint = ode.OdeBallJoint(world)
|
||||||
|
joint.attach(body, None)
|
||||||
|
|
||||||
|
assert tuple(body.joints) == (joint,)
|
||||||
|
|
||||||
|
|
||||||
|
def test_odejoint_attach_1(world):
|
||||||
|
from panda3d import ode
|
||||||
|
|
||||||
|
body = ode.OdeBody(world)
|
||||||
|
|
||||||
|
assert len(body.joints) == 0
|
||||||
|
|
||||||
|
joint = ode.OdeBallJoint(world)
|
||||||
|
joint.attach(None, body)
|
||||||
|
|
||||||
|
assert tuple(body.joints) == (joint,)
|
Loading…
x
Reference in New Issue
Block a user