Player: more line-of-sight debug lines
GitOrigin-RevId: 655eef228659215ce53ac3e58bc324581a0fec3f
This commit is contained in:
parent
80746ecaed
commit
6b9890b6f7
@ -210,30 +210,34 @@ namespace SemiColinGames {
|
||||
}
|
||||
if (points.Count > hitCount) {
|
||||
boxes.Add(box);
|
||||
Debug.AddRect(box, color);
|
||||
}
|
||||
}
|
||||
|
||||
HashSet<AABB> boxesSeen = new HashSet<AABB>();
|
||||
foreach (Vector2 hit in points) {
|
||||
foreach (Vector2 point in points) {
|
||||
float minTime = 1;
|
||||
AABB? closestBox = null;
|
||||
Vector2 delta = Vector2.Subtract(hit, eyePos);
|
||||
Vector2 delta = Vector2.Subtract(point, eyePos);
|
||||
foreach (AABB box in boxes) {
|
||||
Hit? maybeHit = box.IntersectSegment(eyePos, delta);
|
||||
if (maybeHit != null && maybeHit.Value.Time < minTime) {
|
||||
minTime = maybeHit.Value.Time;
|
||||
if (maybeHit != null) {
|
||||
float time = FMath.Clamp(maybeHit.Value.Time, 0, 1);
|
||||
Vector2 target = Vector2.Add(eyePos, Vector2.Multiply(delta, time));
|
||||
Debug.AddLine(eyePos, target, color);
|
||||
if (time < minTime) {
|
||||
minTime = time;
|
||||
closestBox = box;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (closestBox != null) {
|
||||
Vector2 target = Vector2.Add(eyePos, Vector2.Multiply(delta, minTime));
|
||||
Debug.AddLine(eyePos, target, color);
|
||||
boxesSeen.Add(closestBox.Value);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (AABB box in boxesSeen) {
|
||||
Debug.AddRect(box, color);
|
||||
Debug.AddRect(box, Color.Orange);
|
||||
}
|
||||
|
||||
Debug.AddLine(eyePos, Vector2.Add(eyePos, ray), Color.Red);
|
||||
|
Loading…
Reference in New Issue
Block a user