载入中...
搜索中...
未找到
Fixture.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include <string>
6
7class b2Fixture;
8
9namespace eve::physics {
10
11class Body;
12class World;
13
19public:
21 Fixture(World *world, Body *body, b2Fixture *fixture);
23 ~Fixture();
24
25 Fixture(const Fixture &) = delete;
26 Fixture &operator=(const Fixture &) = delete;
27
29 void setSensor(bool sensor);
31 bool isSensor() const;
32
34 void setFriction(float friction);
36 float getFriction() const;
37
39 void setRestitution(float restitution);
41 float getRestitution() const;
42
44 void setDensity(float density);
46 float getDensity() const;
47
49 void setTag(const std::string &tag) { tag_ = tag; }
51 const std::string &getTag() const { return tag_; }
52
54 void setCategoryBits(int bits);
56 int getCategoryBits() const;
58 void setMaskBits(int bits);
60 int getMaskBits() const;
62 void setGroupIndex(int index);
64 int getGroupIndex() const;
65
67 int getBodyId() const;
68
77 Body *getBody() { return body_; }
78
80 bool testPoint(float x, float y) const;
81
83 void destroy();
84
93 b2Fixture *raw() { return fixture_; }
102 const b2Fixture *raw() const { return fixture_; }
103
105 void invalidate();
106
107private:
108 friend struct WorldSnapshotAccess;
109 friend class World;
110 friend class Body;
111
112 World *world_ = nullptr;
113 Body *body_ = nullptr;
114 b2Fixture *fixture_ = nullptr;
115 std::string tag_;
116};
117
118} // namespace eve::physics
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
#define EVENGINE_API_WORLD
Definition Export.h:109
void(* destroy)(void *)
const std::string * tag
World3D * world
double restitution
std::string body
uint32_t index
2D rigid body (Box2D) in pixel-space coordinates. Owned by a World; create shapes with newRectangleFi...
Definition Body.h:21
2D fixture: a shape attached to a Body with material + filter settings. Also carries a string tag use...
Definition Fixture.h:18
Body * getBody()
Returns the owning body, or null after invalidation.
Definition Fixture.h:77
b2Fixture * raw()
Exposes the underlying Box2D fixture for tightly-scoped backend integration.
Definition Fixture.h:93
Fixture & operator=(const Fixture &)=delete
const b2Fixture * raw() const
Exposes the underlying Box2D fixture for read-only backend integration.
Definition Fixture.h:102
const std::string & getTag() const
Returns the tag.
Definition Fixture.h:51
Fixture(const Fixture &)=delete
void setTag(const std::string &tag)
Arbitrary string tag surfaced in begin/end contact events.
Definition Fixture.h:49
Box2D world wrapper (2D physics) with pixel-space coordinates. Handles stepping, gravity,...
Definition World.h:41
Optional physics backend for vehicle mobility and body attach.
Definition Climbing.h:36