载入中...
搜索中...
未找到
Shape3D.h
浏览该文件的文档.
1#pragma once
2
3#include <box3d/id.h>
4
5namespace eve::physics {
6
7class Body3D;
8class World3D;
9
14class Shape3D {
15public:
17 enum class Kind { Box, Sphere, Capsule };
18
20 Shape3D(World3D *world, Body3D *body, b3ShapeId shapeId, Kind kind, float a, float b,
21 float c);
22 ~Shape3D();
23
24 Shape3D(const Shape3D &) = delete;
25 Shape3D &operator=(const Shape3D &) = delete;
26
28 void setSensor(bool sensor);
29 bool isSensor() const;
30
32 void setFriction(float friction);
33 float getFriction() const;
34
35 void setRestitution(float restitution);
36 float getRestitution() const;
37
38 void setDensity(float density);
39 float getDensity() const;
40
42 Body3D *getBody() { return body_; }
43
45 bool testPoint(float x, float y, float z) const;
46
48 void destroy();
49
51 b3ShapeId raw() const { return shapeId_; }
52 bool isValid() const;
53
55 void invalidate();
56
57private:
58 friend class World3D;
59 friend class Body3D;
60
61 void recreate(bool sensor);
62
63 World3D *world_ = nullptr;
64 Body3D *body_ = nullptr;
65 b3ShapeId shapeId_{};
66 Kind kind_ = Kind::Box;
67 float a_ = 0.f; // box hx | sphere r | capsule half-height
68 float b_ = 0.f; // box hy | unused | capsule radius
69 float c_ = 0.f; // box hz
70};
71
72} // namespace eve::physics
Tok kind
int y
Definition Grass.cpp:135
int z
Definition Grass.cpp:135
int x
Definition Grass.cpp:135
JobFunc body
uint32_t a
uint32_t b
uint32_t c
3D rigid body (Box3D) in meter-space coordinates (+Y up by convention). Owned by a World3D; create sh...
Definition Body3D.h:16
3D shape (box/sphere/capsule) attached to a Body3D with material settings. Created via Body3D::new*Sh...
Definition Shape3D.h:14
void setDensity(float density)
Definition Shape3D.cpp:126
void invalidate()
Internal: marks the wrapper invalid after destruction.
Definition Shape3D.cpp:42
bool testPoint(float x, float y, float z) const
Point-in-shape test in world meters.
Definition Shape3D.cpp:133
Kind
Shape geometry kind.
Definition Shape3D.h:17
bool isSensor() const
Definition Shape3D.cpp:108
void setRestitution(float restitution)
Definition Shape3D.cpp:117
Shape3D & operator=(const Shape3D &)=delete
bool isValid() const
Definition Shape3D.cpp:40
float getFriction() const
Definition Shape3D.cpp:115
float getRestitution() const
Definition Shape3D.cpp:122
void destroy()
Destroys the shape inside its world.
Definition Shape3D.cpp:49
Shape3D(const Shape3D &)=delete
float getDensity() const
Definition Shape3D.cpp:131
Body3D * getBody()
Owning body.
Definition Shape3D.h:42
b3ShapeId raw() const
Raw Box3D shape id / liveness.
Definition Shape3D.h:51
void setSensor(bool sensor)
Sensor shapes report contacts but never collide.
Definition Shape3D.cpp:102
void setFriction(float friction)
Material properties.
Definition Shape3D.cpp:110
Box3D rigid-body world. Script coordinates are meters (Box3D native), unlike 2D World which uses pixe...
Definition World3D.h:18