mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Improves physics debug drawing
This commit is contained in:
parent
96689dec7f
commit
fde92a69a5
@ -47,6 +47,10 @@ class PhysicsWorld extends Node {
|
||||
|
||||
List<PhysicsBody> _bodiesScheduledForUpdate = <PhysicsBody>[];
|
||||
|
||||
bool drawDebug = false;
|
||||
|
||||
Matrix4 _debugDrawTransform ;
|
||||
|
||||
_PhysicsDebugDraw _debugDraw;
|
||||
|
||||
double b2WorldToNodeConversionFactor = 10.0;
|
||||
@ -228,8 +232,10 @@ class PhysicsWorld extends Node {
|
||||
}
|
||||
|
||||
void paint(PaintingCanvas canvas) {
|
||||
if (drawDebug) {
|
||||
_debugDrawTransform = new Matrix4.fromFloat64List(canvas.getTotalMatrix());
|
||||
}
|
||||
super.paint(canvas);
|
||||
paintDebug(canvas);
|
||||
}
|
||||
|
||||
void paintDebug(PaintingCanvas canvas) {
|
||||
|
@ -347,6 +347,14 @@ class SpriteBox extends RenderBox {
|
||||
Matrix4 totalMatrix = new Matrix4.fromFloat64List(canvas.getTotalMatrix());
|
||||
_rootNode._visit(canvas, totalMatrix);
|
||||
|
||||
// Draw physics debug
|
||||
for (PhysicsWorld world in _physicsNodes) {
|
||||
if (world.drawDebug) {
|
||||
canvas.setMatrix(world._debugDrawTransform.storage);
|
||||
world.paintDebug(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user