rename numEdgeVertices -> NUM_EDGE_VERTICES
GitOrigin-RevId: c7a67e06ea330f1fd3de4abdbeb8021402b6f330
This commit is contained in:
parent
3a8defcf3f
commit
5549f15029
@ -5,20 +5,20 @@ using System;
|
|||||||
namespace SemiColinGames {
|
namespace SemiColinGames {
|
||||||
class LinesOfSight : IDisposable {
|
class LinesOfSight : IDisposable {
|
||||||
|
|
||||||
const int numEdgeVertices = 60;
|
const int NUM_EDGE_VERTICES = 60;
|
||||||
|
|
||||||
readonly VertexBuffer vertexBuffer;
|
readonly VertexBuffer vertexBuffer;
|
||||||
readonly IndexBuffer indexBuffer;
|
readonly IndexBuffer indexBuffer;
|
||||||
// coneVertices[0] is the eye position; the rest are the edge vertices.
|
// coneVertices[0] is the eye position; the rest are the edge vertices.
|
||||||
readonly VertexPositionColor[] coneVertices = new VertexPositionColor[numEdgeVertices + 1];
|
readonly VertexPositionColor[] coneVertices = new VertexPositionColor[NUM_EDGE_VERTICES + 1];
|
||||||
// The number of total triangles drawn is one less than the number of edge points.
|
// The number of total triangles drawn is one less than the number of edge points.
|
||||||
readonly int[] indices = new int[(numEdgeVertices - 1) * 3];
|
readonly int[] indices = new int[(NUM_EDGE_VERTICES - 1) * 3];
|
||||||
|
|
||||||
Color color = Color.FromNonPremultiplied(new Vector4(0, 0, 1, 0.6f));
|
Color color = Color.FromNonPremultiplied(new Vector4(0, 0, 1, 0.6f));
|
||||||
|
|
||||||
public LinesOfSight(GraphicsDevice graphics) {
|
public LinesOfSight(GraphicsDevice graphics) {
|
||||||
vertexBuffer = new VertexBuffer(
|
vertexBuffer = new VertexBuffer(
|
||||||
graphics, typeof(VertexPositionColor), numEdgeVertices * 3, BufferUsage.WriteOnly);
|
graphics, typeof(VertexPositionColor), NUM_EDGE_VERTICES * 3, BufferUsage.WriteOnly);
|
||||||
indexBuffer = new IndexBuffer(
|
indexBuffer = new IndexBuffer(
|
||||||
graphics, typeof(int), indices.Length, BufferUsage.WriteOnly);
|
graphics, typeof(int), indices.Length, BufferUsage.WriteOnly);
|
||||||
}
|
}
|
||||||
@ -40,10 +40,10 @@ namespace SemiColinGames {
|
|||||||
float fov = player.FieldOfView;
|
float fov = player.FieldOfView;
|
||||||
|
|
||||||
float visionRangeSq = visionRange * visionRange;
|
float visionRangeSq = visionRange * visionRange;
|
||||||
float fovStep = fov / (numEdgeVertices - 1);
|
float fovStep = fov / (NUM_EDGE_VERTICES - 1);
|
||||||
|
|
||||||
coneVertices[0] = new VertexPositionColor(new Vector3(player.EyePosition, 0), color);
|
coneVertices[0] = new VertexPositionColor(new Vector3(player.EyePosition, 0), color);
|
||||||
for (int i = 0; i < numEdgeVertices; i++) {
|
for (int i = 0; i < NUM_EDGE_VERTICES; i++) {
|
||||||
float angle = -fov / 2 + fovStep * i;
|
float angle = -fov / 2 + fovStep * i;
|
||||||
Vector2 rotated = ray.Rotate(angle);
|
Vector2 rotated = ray.Rotate(angle);
|
||||||
Vector2 closestHit = Vector2.Add(eyePos, rotated);
|
Vector2 closestHit = Vector2.Add(eyePos, rotated);
|
||||||
@ -77,7 +77,7 @@ namespace SemiColinGames {
|
|||||||
|
|
||||||
public void Draw(GraphicsDevice graphics, BasicEffect lightingEffect) {
|
public void Draw(GraphicsDevice graphics, BasicEffect lightingEffect) {
|
||||||
|
|
||||||
for (int i = 0; i < numEdgeVertices - 1; i++) {
|
for (int i = 0; i < NUM_EDGE_VERTICES - 1; i++) {
|
||||||
indices[i * 3] = 0;
|
indices[i * 3] = 0;
|
||||||
indices[i * 3 + 1] = i + 1;
|
indices[i * 3 + 1] = i + 1;
|
||||||
indices[i * 3 + 2] = i + 2;
|
indices[i * 3 + 2] = i + 2;
|
||||||
|
Loading…
Reference in New Issue
Block a user