package com.ThirtyNineEighty.Renderable.Resources;

import com.ThirtyNineEighty.Helpers.Vector3;

import java.nio.FloatBuffer;

public class Geometry
{
  private MeshMode mode;

  private int handle;
  private FloatBuffer data;

  private int trianglesCount;
  private Vector3 position;
  private Vector3 angles;

  public Geometry(int handle, int trianglesCount, Vector3 position, Vector3 angles)
  {
    this.handle = handle;
    this.trianglesCount = trianglesCount;
    this.mode = MeshMode.Static;
    this.data = null;

    this.position = new Vector3(position);
    this.angles = new Vector3(angles);
  }

  public Geometry(FloatBuffer data, int trianglesCount, Vector3 position, Vector3 angles)
  {
    this.handle = 0;
    this.trianglesCount = trianglesCount;
    this.mode = MeshMode.Dynamic;
    this.data = data;

    this.position = new Vector3(position);
    this.angles = new Vector3(angles);
  }

  public MeshMode getMode() { return mode; }

  public int getHandle() { return handle; }
  public FloatBuffer getData()
  {
    if (mode != MeshMode.Dynamic)
      throw new IllegalStateException("not right mode");
    return data;
  }

  public int getTrianglesCount() { return trianglesCount; }
  public Vector3 getPosition() { return position; }
  public Vector3 getAngles() { return angles; }

  public void updateData(int handle, int trianglesCount, Vector3 position, Vector3 angles)
  {
    if (mode != MeshMode.Static)
      throw new IllegalStateException("not right mode");

    this.handle = handle;
    this.trianglesCount = trianglesCount;
    this.position = new Vector3(position);
    this.angles = new Vector3(angles);
  }

  public void updateData(FloatBuffer data, int trianglesCount, Vector3 position, Vector3 angles)
  {
    if (mode != MeshMode.Dynamic)
      throw new IllegalStateException("not right mode");

    this.data = data;
    this.trianglesCount = trianglesCount;
    this.position = new Vector3(position);
    this.angles = new Vector3(angles);
  }
}

@@ -1552,32 +1552,33 @@
 trianglesCount;%0A
+%0A
     this.positio
@@ -1572,32 +1572,58 @@
  this.position =
+ position == null ? null :
  new Vector3(pos
@@ -1639,32 +1639,56 @@
    this.angles =
+ angles == null ? null :
  new Vector3(ang
@@ -1966,32 +1966,58 @@
  this.position =
+ position == null ? null :
  new Vector3(pos
@@ -2033,32 +2033,56 @@
    this.angles =
+ angles == null ? null :
  new Vector3(ang

Fix nullReference exception;