fix: complete architecture consolidation contracts
This commit is contained in:
1 parent
f3fc615443
commit
63246b8c68
497 files changed
+14385
-17010
No files matched your search
@@ -24,19 +24,17 @@ public:
|
||||
DebugDraw() { SetFlags(e_shapeBit | e_jointBit | e_aabbBit); }
|
||||
|
||||
void begin(graphics::Graphics *gfx, float meter) {
|
||||
gfx_ = gfx;
|
||||
gfx_ = gfx;
|
||||
meter_ = meter;
|
||||
}
|
||||
|
||||
void end() { gfx_ = nullptr; }
|
||||
|
||||
void DrawPolygon(const b2Vec2 *vertices, int32 vertexCount,
|
||||
const b2Color &color) override {
|
||||
void DrawPolygon(const b2Vec2 *vertices, int32 vertexCount, const b2Color &color) override {
|
||||
drawPoly(vertices, vertexCount, color, false);
|
||||
}
|
||||
|
||||
void DrawSolidPolygon(const b2Vec2 *vertices, int32 vertexCount,
|
||||
const b2Color &color) override {
|
||||
void DrawSolidPolygon(const b2Vec2 *vertices, int32 vertexCount, const b2Color &color) override {
|
||||
drawPoly(vertices, vertexCount, color, true);
|
||||
}
|
||||
|
||||
@@ -44,22 +42,20 @@ public:
|
||||
drawCircle(center, radius, color, false);
|
||||
}
|
||||
|
||||
void DrawSolidCircle(const b2Vec2 ¢er, float32 radius, const b2Vec2 & /*axis*/,
|
||||
const b2Color &color) override {
|
||||
void DrawSolidCircle(const b2Vec2 ¢er, float32 radius, const b2Vec2 & /*axis*/, const b2Color &color) override {
|
||||
drawCircle(center, radius, color, true);
|
||||
}
|
||||
|
||||
void DrawSegment(const b2Vec2 &p1, const b2Vec2 &p2, const b2Color &color) override {
|
||||
if (!gfx_)
|
||||
return;
|
||||
float x1 = p1.x * meter_;
|
||||
float y1 = p1.y * meter_;
|
||||
float x2 = p2.x * meter_;
|
||||
float y2 = p2.y * meter_;
|
||||
if (!gfx_) return;
|
||||
float x1 = p1.x * meter_;
|
||||
float y1 = p1.y * meter_;
|
||||
float x2 = p2.x * meter_;
|
||||
float y2 = p2.y * meter_;
|
||||
float minx = std::min(x1, x2);
|
||||
float miny = std::min(y1, y2);
|
||||
float w = std::max(1.f, std::fabs(x2 - x1));
|
||||
float h = std::max(1.f, std::fabs(y2 - y1));
|
||||
float w = std::max(1.f, std::fabs(x2 - x1));
|
||||
float h = std::max(1.f, std::fabs(y2 - y1));
|
||||
gfx_->drawSolidRect(minx, miny, w, h, Color(color.r, color.g, color.b, color.a * 0.8f));
|
||||
}
|
||||
|
||||
@@ -70,8 +66,7 @@ public:
|
||||
|
||||
private:
|
||||
void drawPoly(const b2Vec2 *vertices, int32 vertexCount, const b2Color &color, bool solid) {
|
||||
if (!gfx_ || vertexCount < 2)
|
||||
return;
|
||||
if (!gfx_ || vertexCount < 2) return;
|
||||
for (int32 i = 0; i < vertexCount; ++i) {
|
||||
const b2Vec2 &a = vertices[i];
|
||||
const b2Vec2 &b = vertices[(i + 1) % vertexCount];
|
||||
@@ -88,24 +83,22 @@ private:
|
||||
miny = std::min(miny, vertices[i].y);
|
||||
maxy = std::max(maxy, vertices[i].y);
|
||||
}
|
||||
gfx_->drawSolidRect(minx * meter_, miny * meter_, (maxx - minx) * meter_,
|
||||
(maxy - miny) * meter_,
|
||||
gfx_->drawSolidRect(minx * meter_, miny * meter_, (maxx - minx) * meter_, (maxy - miny) * meter_,
|
||||
Color(color.r, color.g, color.b, color.a * 0.25f));
|
||||
}
|
||||
}
|
||||
|
||||
void drawCircle(const b2Vec2 ¢er, float32 radius, const b2Color &color, bool solid) {
|
||||
if (!gfx_)
|
||||
return;
|
||||
if (!gfx_) return;
|
||||
float px = (center.x - radius) * meter_;
|
||||
float py = (center.y - radius) * meter_;
|
||||
float d = radius * 2.f * meter_;
|
||||
float a = solid ? color.a * 0.35f : color.a * 0.7f;
|
||||
float d = radius * 2.f * meter_;
|
||||
float a = solid ? color.a * 0.35f : color.a * 0.7f;
|
||||
gfx_->drawSolidRect(px, py, d, d, Color(color.r, color.g, color.b, a));
|
||||
}
|
||||
|
||||
graphics::Graphics *gfx_ = nullptr;
|
||||
float meter_ = 30.f;
|
||||
graphics::Graphics *gfx_ = nullptr;
|
||||
float meter_ = 30.f;
|
||||
};
|
||||
|
||||
class DebugDrawBinding final {
|
||||
@@ -113,7 +106,7 @@ public:
|
||||
DebugDrawBinding(b2World *world, b2Draw *draw) : world_(world) { world_->SetDebugDraw(draw); }
|
||||
~DebugDrawBinding() { world_->SetDebugDraw(nullptr); }
|
||||
|
||||
DebugDrawBinding(const DebugDrawBinding &) = delete;
|
||||
DebugDrawBinding(const DebugDrawBinding &) = delete;
|
||||
DebugDrawBinding &operator=(const DebugDrawBinding &) = delete;
|
||||
|
||||
private:
|
||||
@@ -124,8 +117,7 @@ private:
|
||||
|
||||
void World::drawDebug(graphics::Graphics *gfx) {
|
||||
b2World *world = raw();
|
||||
if (!world || !isValid() || !gfx)
|
||||
return;
|
||||
if (!world || !isValid() || !gfx) return;
|
||||
|
||||
DebugDraw draw;
|
||||
draw.begin(gfx, getMeter());
|
||||
|
||||
Reference in new issue
Block a user