File: DebugRenderer.h

package info (click to toggle)
caveexpress 2.4+git20160609-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 48,824 kB
  • sloc: cpp: 66,239; ansic: 1,135; sh: 471; xml: 186; python: 74; makefile: 20
file content (57 lines) | stat: -rw-r--r-- 1,763 bytes parent folder | download | duplicates (2)
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
#pragma once

#include <SDL_assert.h>
#ifndef b2Assert
#define b2Assert SDL_assert
#endif
#include <Box2D/Box2D.h>
#include "common/IFrontend.h"
#include "common/Compiler.h"
#include "common/DebugRendererData.h"
#include <vector>

// forward decl
class IFrontend;

struct ContactPoint {
	b2Fixture* fixtureA;
	b2Fixture* fixtureB;
	b2Vec2 normal;
	b2Vec2 position;
	b2PointState state;
	float32 normalImpulse;
	float32 tangentImpulse;
};

struct TraceData {
	b2Vec2 start;
	b2Vec2 end;
	float fraction;
};

#define DEBUG_RENDERER_MAX_COLORS 128
class DebugRenderer: public b2Draw {
private:
	int _pointCount;
	const ContactPoint *_points;
	const std::vector<b2Vec2>& _waterIntersectionPoints;
	int _traceCount;
	const TraceData *_traceData;
	const DebugRendererData _data;
	IFrontend* _frontend;

	void DrawPoint(const b2Vec2& p, float32 size, const b2Color& color);
	void DrawSegmentWithAlpha (const b2Vec2& p1, const b2Vec2& p2, const b2Color& color, float alpha);
public:
	DebugRenderer (int pointCount, const ContactPoint *points, int traceCount, const TraceData *traceData, const std::vector<b2Vec2>& waterIntersectionPoints, const DebugRendererData& rect, IFrontend* frontend);
	virtual ~DebugRenderer ();

	// b2Draw
	void DrawPolygon (const b2Vec2* vertices, int32 vertexCount, const b2Color& color) override;
	void DrawSolidPolygon (const b2Vec2* vertices, int32 vertexCount, const b2Color& color) override;
	void DrawCircle (const b2Vec2& center, float32 radius, const b2Color& color) override;
	void DrawSolidCircle (const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color) override;
	void DrawSegment (const b2Vec2& p1, const b2Vec2& p2, const b2Color& color) override;
	void DrawTransform (const b2Transform& xf) override;
};