@@ -76,7 +76,7 @@ class Geometry3D {
76
76
real_t tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0
77
77
78
78
// Compute the line parameters of the two closest points.
79
- if (D < CMP_EPSILON) { // The lines are almost parallel.
79
+ if (D < ( real_t ) CMP_EPSILON) { // The lines are almost parallel.
80
80
sN = 0 .0f ; // Force using point P0 on segment S1
81
81
sD = 1 .0f ; // to prevent possible division by 0.0 later.
82
82
tN = e;
@@ -142,15 +142,15 @@ class Geometry3D {
142
142
Vector3 s = p_from - p_v0;
143
143
real_t u = f * s.dot (h);
144
144
145
- if (u < 0 .0f || u > 1 .0f ) {
145
+ if (( u < 0 .0f ) || ( u > 1 .0f ) ) {
146
146
return false ;
147
147
}
148
148
149
149
Vector3 q = s.cross (e1 );
150
150
151
151
real_t v = f * p_dir.dot (q);
152
152
153
- if (v < 0 .0f || u + v > 1 .0f ) {
153
+ if (( v < 0 .0f ) || ( u + v > 1 .0f ) ) {
154
154
return false ;
155
155
}
156
156
@@ -183,23 +183,23 @@ class Geometry3D {
183
183
Vector3 s = p_from - p_v0;
184
184
real_t u = f * s.dot (h);
185
185
186
- if (u < 0 .0f || u > 1 .0f ) {
186
+ if (( u < 0 .0f ) || ( u > 1 .0f ) ) {
187
187
return false ;
188
188
}
189
189
190
190
Vector3 q = s.cross (e1 );
191
191
192
192
real_t v = f * rel.dot (q);
193
193
194
- if (v < 0 .0f || u + v > 1 .0f ) {
194
+ if (( v < 0 .0f ) || ( u + v > 1 .0f ) ) {
195
195
return false ;
196
196
}
197
197
198
198
// At this stage we can compute t to find out where
199
199
// the intersection point is on the line.
200
200
real_t t = f * e2 .dot (q);
201
201
202
- if (t > CMP_EPSILON && t <= 1 .0f ) { // Ray intersection.
202
+ if (t > ( real_t ) CMP_EPSILON && t <= 1 .0f ) { // Ray intersection.
203
203
if (r_res) {
204
204
*r_res = p_from + rel * t;
205
205
}
@@ -213,7 +213,7 @@ class Geometry3D {
213
213
Vector3 sphere_pos = p_sphere_pos - p_from;
214
214
Vector3 rel = (p_to - p_from);
215
215
real_t rel_l = rel.length ();
216
- if (rel_l < CMP_EPSILON) {
216
+ if (rel_l < ( real_t ) CMP_EPSILON) {
217
217
return false ; // Both points are the same.
218
218
}
219
219
Vector3 normal = rel / rel_l;
@@ -229,7 +229,7 @@ class Geometry3D {
229
229
real_t inters_d2 = p_sphere_radius * p_sphere_radius - ray_distance * ray_distance;
230
230
real_t inters_d = sphere_d;
231
231
232
- if (inters_d2 >= CMP_EPSILON) {
232
+ if (inters_d2 >= ( real_t ) CMP_EPSILON) {
233
233
inters_d -= Math::sqrt (inters_d2);
234
234
}
235
235
@@ -253,7 +253,7 @@ class Geometry3D {
253
253
static inline bool segment_intersects_cylinder (const Vector3 &p_from, const Vector3 &p_to, real_t p_height, real_t p_radius, Vector3 *r_res = nullptr , Vector3 *r_norm = nullptr , int p_cylinder_axis = 2 ) {
254
254
Vector3 rel = (p_to - p_from);
255
255
real_t rel_l = rel.length ();
256
- if (rel_l < CMP_EPSILON) {
256
+ if (rel_l < ( real_t ) CMP_EPSILON) {
257
257
return false ; // Both points are the same.
258
258
}
259
259
@@ -269,7 +269,7 @@ class Geometry3D {
269
269
270
270
Vector3 axis_dir;
271
271
272
- if (crs_l < CMP_EPSILON) {
272
+ if (crs_l < ( real_t ) CMP_EPSILON) {
273
273
Vector3 side_axis;
274
274
side_axis[(p_cylinder_axis + 1 ) % 3 ] = 1 .0f ; // Any side axis OK.
275
275
axis_dir = side_axis;
@@ -285,7 +285,7 @@ class Geometry3D {
285
285
286
286
// Convert to 2D.
287
287
real_t w2 = p_radius * p_radius - dist * dist;
288
- if (w2 < CMP_EPSILON) {
288
+ if (w2 < ( real_t ) CMP_EPSILON) {
289
289
return false ; // Avoid numerical error.
290
290
}
291
291
Size2 size (Math::sqrt (w2), p_height * 0 .5f );
@@ -366,7 +366,7 @@ class Geometry3D {
366
366
Vector3 rel = p_to - p_from;
367
367
real_t rel_l = rel.length ();
368
368
369
- if (rel_l < CMP_EPSILON) {
369
+ if (rel_l < ( real_t ) CMP_EPSILON) {
370
370
return false ;
371
371
}
372
372
@@ -379,7 +379,7 @@ class Geometry3D {
379
379
380
380
real_t den = p.normal .dot (dir);
381
381
382
- if (Math::abs (den) <= CMP_EPSILON) {
382
+ if (Math::abs (den) <= ( real_t ) CMP_EPSILON) {
383
383
continue ; // Ignore parallel plane.
384
384
}
385
385
@@ -564,11 +564,11 @@ class Geometry3D {
564
564
565
565
for (int a = 0 ; a < polygon.size (); a++) {
566
566
real_t dist = p_plane.distance_to (polygon[a]);
567
- if (dist < -CMP_POINT_IN_PLANE_EPSILON) {
567
+ if (dist < ( real_t ) -CMP_POINT_IN_PLANE_EPSILON) {
568
568
location_cache[a] = LOC_INSIDE;
569
569
inside_count++;
570
570
} else {
571
- if (dist > CMP_POINT_IN_PLANE_EPSILON) {
571
+ if (dist > ( real_t ) CMP_POINT_IN_PLANE_EPSILON) {
572
572
location_cache[a] = LOC_OUTSIDE;
573
573
outside_count++;
574
574
} else {
0 commit comments