Skip to content

Commit 86cbddd

Browse files
Cheatermanrdb
authored andcommitted
Fix float precision issues in bulletHeightfieldShape
Closes: panda3d#152
1 parent 2b537d2 commit 86cbddd

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

panda/src/bullet/bulletHeightfieldShape.I

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ BulletHeightfieldShape(const BulletHeightfieldShape &copy) :
3030
_num_rows(copy._num_rows),
3131
_num_cols(copy._num_cols) {
3232

33-
_data = new float[_num_rows * _num_cols];
34-
memcpy(_data, copy._data, _num_rows * _num_cols * sizeof(float));
33+
_data = new btScalar[_num_rows * _num_cols];
34+
memcpy(_data, copy._data, _num_rows * _num_cols * sizeof(btScalar));
3535
}
3636

3737
/**
@@ -44,6 +44,6 @@ operator = (const BulletHeightfieldShape &copy) {
4444
_num_rows = copy._num_rows;
4545
_num_cols = copy._num_cols;
4646

47-
_data = new float[_num_rows * _num_cols];
48-
memcpy(_data, copy._data, _num_rows * _num_cols * sizeof(float));
47+
_data = new btScalar[_num_rows * _num_cols];
48+
memcpy(_data, copy._data, _num_rows * _num_cols * sizeof(btScalar));
4949
}

panda/src/bullet/bulletHeightfieldShape.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ BulletHeightfieldShape(const PNMImage &image, PN_stdfloat max_height, BulletUpAx
2626
_num_rows = image.get_x_size();
2727
_num_cols = image.get_y_size();
2828

29-
_data = new float[_num_rows * _num_cols];
29+
_data = new btScalar[_num_rows * _num_cols];
3030

3131
for (int row=0; row < _num_rows; row++) {
3232
for (int column=0; column < _num_cols; column++) {
@@ -75,10 +75,10 @@ BulletHeightfieldShape(Texture *tex, PN_stdfloat max_height, BulletUpAxis up) {
7575

7676
_num_rows = tex->get_x_size() + 1;
7777
_num_cols = tex->get_y_size() + 1;
78-
_data = new float[_num_rows * _num_cols];
78+
_data = new btScalar[_num_rows * _num_cols];
7979

80-
PN_stdfloat step_x = 1.0 / (PN_stdfloat)tex->get_x_size();
81-
PN_stdfloat step_y = 1.0 / (PN_stdfloat)tex->get_y_size();
80+
btScalar step_x = 1.0 / (btScalar)tex->get_x_size();
81+
btScalar step_y = 1.0 / (btScalar)tex->get_y_size();
8282

8383
PT(TexturePeeker) peeker = tex->peek();
8484
LColor sample;
@@ -100,4 +100,4 @@ BulletHeightfieldShape(Texture *tex, PN_stdfloat max_height, BulletUpAxis up) {
100100
up,
101101
true, false);
102102
_shape->setUserPointer(this);
103-
}
103+
}

panda/src/bullet/bulletHeightfieldShape.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class EXPCL_PANDABULLET BulletHeightfieldShape : public BulletShape {
4444
private:
4545
int _num_rows;
4646
int _num_cols;
47-
float *_data;
47+
btScalar *_data;
4848
btHeightfieldTerrainShape *_shape;
4949

5050
public:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy