mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 00:32:57 -04:00
bullet: change wheel get/setSteering to use degrees
Fixes #757 Closes #784
This commit is contained in:
parent
8615e25a12
commit
636c3d044a
@ -218,22 +218,28 @@ get_wheel_radius() const {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the steering angle.
|
* Sets the steering angle.
|
||||||
|
*
|
||||||
|
* @warning
|
||||||
|
* As of 1.11, this method uses degrees. Previous versions used radians.
|
||||||
*/
|
*/
|
||||||
void BulletWheel::
|
void BulletWheel::
|
||||||
set_steering(PN_stdfloat value) {
|
set_steering(PN_stdfloat value) {
|
||||||
LightMutexHolder holder(BulletWorld::get_global_lock());
|
LightMutexHolder holder(BulletWorld::get_global_lock());
|
||||||
|
|
||||||
_info.m_steering = (btScalar)value;
|
_info.m_steering = (btScalar)deg_2_rad(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the steering angle in degrees.
|
* Returns the steering angle in degrees.
|
||||||
|
*
|
||||||
|
* @warning
|
||||||
|
* As of 1.11, this method uses degrees. Previous versions used radians.
|
||||||
*/
|
*/
|
||||||
PN_stdfloat BulletWheel::
|
PN_stdfloat BulletWheel::
|
||||||
get_steering() const {
|
get_steering() const {
|
||||||
LightMutexHolder holder(BulletWorld::get_global_lock());
|
LightMutexHolder holder(BulletWorld::get_global_lock());
|
||||||
|
|
||||||
return (PN_stdfloat)_info.m_steering;
|
return rad_2_deg((PN_stdfloat)_info.m_steering);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
27
tests/bullet/test_bullet_wheel.py
Normal file
27
tests/bullet/test_bullet_wheel.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import pytest
|
||||||
|
from pytest import approx
|
||||||
|
# Skip these tests if we can't import bullet.
|
||||||
|
bullet = pytest.importorskip("panda3d.bullet")
|
||||||
|
|
||||||
|
from panda3d.core import Vec3
|
||||||
|
from panda3d.bullet import BulletWorld
|
||||||
|
from panda3d.bullet import BulletBoxShape
|
||||||
|
from panda3d.bullet import BulletRigidBodyNode
|
||||||
|
from panda3d.bullet import BulletVehicle
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_steering():
|
||||||
|
world = BulletWorld()
|
||||||
|
# Chassis
|
||||||
|
shape = BulletBoxShape(Vec3(0.6, 1.4, 0.5))
|
||||||
|
body = BulletRigidBodyNode('Vehicle')
|
||||||
|
body.addShape(shape)
|
||||||
|
world.attach(body)
|
||||||
|
# Vehicle
|
||||||
|
vehicle = BulletVehicle(world, body)
|
||||||
|
world.attachVehicle(vehicle)
|
||||||
|
# Wheel
|
||||||
|
wheel = vehicle.createWheel()
|
||||||
|
wheel.setSteering(30.0)
|
||||||
|
# Returns the steering angle in degrees.
|
||||||
|
assert wheel.getSteering() == approx(30.0)
|
Loading…
x
Reference in New Issue
Block a user