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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529 | /**************************************************************************/
/* shape_sw.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SHAPE_SW_H
#define SHAPE_SW_H
#include "core/local_vector.h"
#include "core/math/bsp_tree.h"
#include "core/math/geometry.h"
#include "servers/physics_server.h"
/*
SHAPE_LINE, ///< plane:"plane"
SHAPE_SEGMENT, ///< real_t:"length"
SHAPE_CIRCLE, ///< real_t:"radius"
SHAPE_RECTANGLE, ///< vec3:"extents"
SHAPE_CONVEX_POLYGON, ///< array of planes:"planes"
SHAPE_CONCAVE_POLYGON, ///< Vector3 array:"triangles" , or Dictionary with "indices" (int array) and "triangles" (Vector3 array)
SHAPE_CUSTOM, ///< Server-Implementation based custom shape, calling shape_create() with this value will result in an error
*/
class ShapeSW;
class ShapeOwnerSW : public RID_Data {
public:
virtual void _shape_changed() = 0;
virtual void remove_shape(ShapeSW *p_shape) = 0;
virtual ~ShapeOwnerSW() {}
};
class ShapeSW : public RID_Data {
RID self;
AABB aabb;
bool configured;
real_t custom_bias;
Map<ShapeOwnerSW *, int> owners;
protected:
void configure(const AABB &p_aabb);
public:
enum FeatureType {
FEATURE_POINT,
FEATURE_EDGE,
FEATURE_FACE,
FEATURE_CIRCLE,
};
virtual real_t get_area() const { return aabb.get_area(); }<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class
_FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; }
_FORCE_INLINE_ RID get_self() const { return self; }
virtual PhysicsServer::ShapeType get_type() const = 0;<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class
_FORCE_INLINE_ const AABB &get_aabb() const { return aabb; }
_FORCE_INLINE_ bool is_configured() const { return configured; }
virtual bool is_concave() const { return false; }<--- Virtual function in base class
virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const = 0;<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class
virtual Vector3 get_support(const Vector3 &p_normal) const;<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const = 0;<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class
virtual Vector3 get_closest_point_to(const Vector3 &p_point) const = 0;<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_point, Vector3 &r_normal) const = 0;<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class
virtual bool intersect_point(const Vector3 &p_point) const = 0;<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class
virtual Vector3 get_moment_of_inertia(real_t p_mass) const = 0;<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class
virtual void set_data(const Variant &p_data) = 0;<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class
virtual Variant get_data() const = 0;<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class
_FORCE_INLINE_ void set_custom_bias(real_t p_bias) { custom_bias = p_bias; }
_FORCE_INLINE_ real_t get_custom_bias() const { return custom_bias; }
void add_owner(ShapeOwnerSW *p_owner);
void remove_owner(ShapeOwnerSW *p_owner);
bool is_owner(ShapeOwnerSW *p_owner) const;
const Map<ShapeOwnerSW *, int> &get_owners() const;
ShapeSW();
virtual ~ShapeSW();
};
class ConcaveShapeSW : public ShapeSW {
public:
// Returns true to stop the query.
typedef bool (*QueryCallback)(void *p_userdata, ShapeSW *p_convex);
virtual bool is_concave() const { return true; }<--- Function in derived class
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const { r_amount = 0; }<--- Function in derived class
virtual void cull(const AABB &p_local_aabb, QueryCallback p_callback, void *p_userdata) const = 0;
ConcaveShapeSW() {}
};
class PlaneShapeSW : public ShapeSW {
Plane plane;
void _setup(const Plane &p_plane);
public:
Plane get_plane() const;
virtual real_t get_area() const { return Math_INF; }<--- Function in derived class
virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_PLANE; }<--- Function in derived class
virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;<--- Function in derived class
virtual Vector3 get_support(const Vector3 &p_normal) const;<--- Function in derived class
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const { r_amount = 0; }<--- Function in derived class
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;<--- Function in derived class
virtual bool intersect_point(const Vector3 &p_point) const;<--- Function in derived class
virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;<--- Function in derived class
virtual Vector3 get_moment_of_inertia(real_t p_mass) const;<--- Function in derived class
virtual void set_data(const Variant &p_data);<--- Function in derived class
virtual Variant get_data() const;<--- Function in derived class
PlaneShapeSW();
};
class RayShapeSW : public ShapeSW {
real_t length;
bool slips_on_slope;
void _setup(real_t p_length, bool p_slips_on_slope);
public:
real_t get_length() const;
bool get_slips_on_slope() const;
virtual real_t get_area() const { return 0.0; }<--- Function in derived class
virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_RAY; }<--- Function in derived class
virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;<--- Function in derived class
virtual Vector3 get_support(const Vector3 &p_normal) const;<--- Function in derived class
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const;<--- Function in derived class
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;<--- Function in derived class
virtual bool intersect_point(const Vector3 &p_point) const;<--- Function in derived class
virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;<--- Function in derived class
virtual Vector3 get_moment_of_inertia(real_t p_mass) const;<--- Function in derived class
virtual void set_data(const Variant &p_data);<--- Function in derived class
virtual Variant get_data() const;<--- Function in derived class
RayShapeSW();
};
class SphereShapeSW : public ShapeSW {
real_t radius;
void _setup(real_t p_radius);
public:
real_t get_radius() const;
virtual real_t get_area() const { return 4.0 / 3.0 * Math_PI * radius * radius * radius; }<--- Function in derived class
virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_SPHERE; }<--- Function in derived class
virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;<--- Function in derived class
virtual Vector3 get_support(const Vector3 &p_normal) const;<--- Function in derived class
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const;<--- Function in derived class
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;<--- Function in derived class
virtual bool intersect_point(const Vector3 &p_point) const;<--- Function in derived class
virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;<--- Function in derived class
virtual Vector3 get_moment_of_inertia(real_t p_mass) const;<--- Function in derived class
virtual void set_data(const Variant &p_data);<--- Function in derived class
virtual Variant get_data() const;<--- Function in derived class
SphereShapeSW();
};
class BoxShapeSW : public ShapeSW {
Vector3 half_extents;
void _setup(const Vector3 &p_half_extents);
public:
_FORCE_INLINE_ Vector3 get_half_extents() const { return half_extents; }
virtual real_t get_area() const { return 8 * half_extents.x * half_extents.y * half_extents.z; }<--- Function in derived class
virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_BOX; }<--- Function in derived class
virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;<--- Function in derived class
virtual Vector3 get_support(const Vector3 &p_normal) const;<--- Function in derived class
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const;<--- Function in derived class
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;<--- Function in derived class
virtual bool intersect_point(const Vector3 &p_point) const;<--- Function in derived class
virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;<--- Function in derived class
virtual Vector3 get_moment_of_inertia(real_t p_mass) const;<--- Function in derived class
virtual void set_data(const Variant &p_data);<--- Function in derived class
virtual Variant get_data() const;<--- Function in derived class
BoxShapeSW();
};
class CapsuleShapeSW : public ShapeSW {
real_t height;
real_t radius;
void _setup(real_t p_height, real_t p_radius);
public:
_FORCE_INLINE_ real_t get_height() const { return height; }
_FORCE_INLINE_ real_t get_radius() const { return radius; }
virtual real_t get_area() const { return height * Math_PI * radius * radius; }<--- Function in derived class
virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CAPSULE; }<--- Function in derived class
virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;<--- Function in derived class
virtual Vector3 get_support(const Vector3 &p_normal) const;<--- Function in derived class
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const;<--- Function in derived class
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;<--- Function in derived class
virtual bool intersect_point(const Vector3 &p_point) const;<--- Function in derived class
virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;<--- Function in derived class
virtual Vector3 get_moment_of_inertia(real_t p_mass) const;<--- Function in derived class
virtual void set_data(const Variant &p_data);<--- Function in derived class
virtual Variant get_data() const;<--- Function in derived class
CapsuleShapeSW();
};
class CylinderShapeSW : public ShapeSW {
real_t height;
real_t radius;
void _setup(real_t p_height, real_t p_radius);
public:
_FORCE_INLINE_ real_t get_height() const { return height; }
_FORCE_INLINE_ real_t get_radius() const { return radius; }
virtual real_t get_area() const { return 4.0 / 3.0 * Math_PI * radius * radius * radius + height * Math_PI * radius * radius; }<--- Function in derived class
virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CYLINDER; }<--- Function in derived class
virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;<--- Function in derived class
virtual Vector3 get_support(const Vector3 &p_normal) const;<--- Function in derived class
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const;<--- Function in derived class
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;<--- Function in derived class
virtual bool intersect_point(const Vector3 &p_point) const;<--- Function in derived class
virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;<--- Function in derived class
virtual Vector3 get_moment_of_inertia(real_t p_mass) const;<--- Function in derived class
virtual void set_data(const Variant &p_data);<--- Function in derived class
virtual Variant get_data() const;<--- Function in derived class
CylinderShapeSW();
};
struct ConvexPolygonShapeSW : public ShapeSW {
Geometry::MeshData mesh;
void _setup(const Vector<Vector3> &p_vertices);
public:
const Geometry::MeshData &get_mesh() const { return mesh; }
virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CONVEX_POLYGON; }<--- Function in derived class
virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;<--- Function in derived class
virtual Vector3 get_support(const Vector3 &p_normal) const;<--- Function in derived class
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const;<--- Function in derived class
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;<--- Function in derived class
virtual bool intersect_point(const Vector3 &p_point) const;<--- Function in derived class
virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;<--- Function in derived class
virtual Vector3 get_moment_of_inertia(real_t p_mass) const;<--- Function in derived class
virtual void set_data(const Variant &p_data);<--- Function in derived class
virtual Variant get_data() const;<--- Function in derived class
ConvexPolygonShapeSW();
};
struct _VolumeSW_BVH;
struct FaceShapeSW;
struct ConcavePolygonShapeSW : public ConcaveShapeSW {
// always a trimesh
struct Face {
Vector3 normal;
int indices[3];
};
PoolVector<Face> faces;
PoolVector<Vector3> vertices;
struct BVH {
AABB aabb;
int left;
int right;
int face_index;
};
PoolVector<BVH> bvh;
struct _CullParams {
AABB aabb;
QueryCallback callback;
void *userdata;
const Face *faces;
const Vector3 *vertices;
const BVH *bvh;
FaceShapeSW *face;
};
struct _SegmentCullParams {
Vector3 from;
Vector3 to;
const Face *faces;
const Vector3 *vertices;
const BVH *bvh;
Vector3 dir;
Vector3 result;
Vector3 normal;
real_t min_d;
int collisions;
};
void _cull_segment(int p_idx, _SegmentCullParams *p_params) const;
bool _cull(int p_idx, _CullParams *p_params) const;
void _fill_bvh(_VolumeSW_BVH *p_bvh_tree, BVH *p_bvh_array, int &p_idx);
void _setup(PoolVector<Vector3> p_faces);
public:
PoolVector<Vector3> get_faces() const;
virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CONCAVE_POLYGON; }<--- Function in derived class
virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;<--- Function in derived class
virtual Vector3 get_support(const Vector3 &p_normal) const;<--- Function in derived class
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;<--- Function in derived class
virtual bool intersect_point(const Vector3 &p_point) const;<--- Function in derived class
virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;<--- Function in derived class
virtual void cull(const AABB &p_local_aabb, QueryCallback p_callback, void *p_userdata) const;
virtual Vector3 get_moment_of_inertia(real_t p_mass) const;<--- Function in derived class
virtual void set_data(const Variant &p_data);<--- Function in derived class
virtual Variant get_data() const;<--- Function in derived class
ConcavePolygonShapeSW();
};
struct HeightMapShapeSW : public ConcaveShapeSW {
friend struct _HeightmapSegmentCullParams;
PoolVector<real_t> heights;
int width;
int depth;
Vector3 local_origin;
// Accelerator.
struct Range {
float min = 0.0;
float max = 0.0;
};
LocalVector<Range> bounds_grid;
int bounds_grid_width = 0;
int bounds_grid_depth = 0;
static const int BOUNDS_CHUNK_SIZE = 16;
_FORCE_INLINE_ const Range &_get_bounds_chunk(int p_x, int p_z) const {
return bounds_grid[(p_z * bounds_grid_width) + p_x];
}
_FORCE_INLINE_ real_t _get_height(int p_x, int p_z) const {
return heights[(p_z * width) + p_x];
}
_FORCE_INLINE_ void _get_point(int p_x, int p_z, Vector3 &r_point) const {
r_point.x = p_x - 0.5 * (width - 1.0);
r_point.y = _get_height(p_x, p_z);
r_point.z = p_z - 0.5 * (depth - 1.0);
}
void _get_cell(const Vector3 &p_point, int &r_x, int &r_y, int &r_z) const;
void _build_accelerator();
template <typename ProcessFunction>
bool _intersect_grid_segment(ProcessFunction &p_process, const Vector3 &p_begin, const Vector3 &p_end, int p_width, int p_depth, const Vector3 &offset, Vector3 &r_point, Vector3 &r_normal) const;
void _setup(const PoolVector<real_t> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height);
public:
PoolVector<real_t> get_heights() const;
int get_width() const;
int get_depth() const;
virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_HEIGHTMAP; }<--- Function in derived class
virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;<--- Function in derived class
virtual Vector3 get_support(const Vector3 &p_normal) const;<--- Function in derived class
virtual bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_point, Vector3 &r_normal) const;<--- Function in derived class
virtual bool intersect_point(const Vector3 &p_point) const;<--- Function in derived class
virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;<--- Function in derived class
virtual void cull(const AABB &p_local_aabb, QueryCallback p_callback, void *p_userdata) const;
virtual Vector3 get_moment_of_inertia(real_t p_mass) const;<--- Function in derived class
virtual void set_data(const Variant &p_data);<--- Function in derived class
virtual Variant get_data() const;<--- Function in derived class
HeightMapShapeSW();
};
//used internally
struct FaceShapeSW : public ShapeSW {
Vector3 normal; //cache
Vector3 vertex[3];
virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CONCAVE_POLYGON; }<--- Function in derived class
const Vector3 &get_vertex(int p_idx) const { return vertex[p_idx]; }
void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;<--- Function in derived class
Vector3 get_support(const Vector3 &p_normal) const;<--- Function in derived class
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const;<--- Function in derived class
bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const;<--- Function in derived class
virtual bool intersect_point(const Vector3 &p_point) const;<--- Function in derived class
virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;<--- Function in derived class
Vector3 get_moment_of_inertia(real_t p_mass) const;<--- Function in derived class
virtual void set_data(const Variant &p_data) {}<--- Function in derived class
virtual Variant get_data() const { return Variant(); }<--- Function in derived class
FaceShapeSW();
};
struct MotionShapeSW : public ShapeSW {
ShapeSW *shape;
Vector3 motion;
virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CONVEX_POLYGON; }<--- Function in derived class
void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const {<--- Function in derived class
Vector3 cast = p_transform.basis.xform(motion);
real_t mina, maxa;
real_t minb, maxb;
Transform ofsb = p_transform;
ofsb.origin += cast;
shape->project_range(p_normal, p_transform, mina, maxa);
shape->project_range(p_normal, ofsb, minb, maxb);
r_min = MIN(mina, minb);
r_max = MAX(maxa, maxb);
}
Vector3 get_support(const Vector3 &p_normal) const {<--- Function in derived class
Vector3 support = shape->get_support(p_normal);
if (p_normal.dot(motion) > 0) {
support += motion;
}
return support;
}
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const { r_amount = 0; }<--- Function in derived class
bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const { return false; }<--- Function in derived class
virtual bool intersect_point(const Vector3 &p_point) const { return false; }<--- Function in derived class
virtual Vector3 get_closest_point_to(const Vector3 &p_point) const { return p_point; }<--- Function in derived class
Vector3 get_moment_of_inertia(real_t p_mass) const { return Vector3(); }<--- Function in derived class
virtual void set_data(const Variant &p_data) {}<--- Function in derived class
virtual Variant get_data() const { return Variant(); }<--- Function in derived class
MotionShapeSW() { configure(AABB()); }<--- Member variable 'MotionShapeSW::shape' is not initialized in the constructor.
};
struct _ShapeTestConvexBSPSW {
const BSP_Tree *bsp;
const ShapeSW *shape;
Transform transform;
_FORCE_INLINE_ void project_range(const Vector3 &p_normal, real_t &r_min, real_t &r_max) const {
shape->project_range(p_normal, transform, r_min, r_max);
}
};
#endif // SHAPE_SW_H
|