Slightly reduce class size of TerrainParticle.

This commit is contained in:
UnknownShadow200 2015-09-19 16:54:48 +10:00
parent 9c557ab234
commit d24d8bba2e
2 changed files with 6 additions and 4 deletions

View file

@ -7,9 +7,8 @@ namespace ClassicalSharp.Particles {
public Vector3 Position;
public Vector3 Velocity;
public Vector2 Size = new Vector2( 1 / 16f, 1 / 16f );
public TextureRectangle Rectangle;
public double Lifetime;
public float Lifetime;
protected Game game;
protected Vector3 lastPos, nextPos;
@ -21,16 +20,17 @@ namespace ClassicalSharp.Particles {
game = window;
Position = lastPos = nextPos = pos;
Velocity = velocity;
Lifetime = lifetime;
Lifetime = (float)lifetime;
Rectangle = rec;
}
public virtual bool Tick( double delta ) {
Lifetime -= delta;
Lifetime -= (float)delta;
return Lifetime < 0;
}
// http://www.opengl-tutorial.org/intermediate-tutorials/billboards-particles/billboards/
protected static Vector2 Size;
protected void TranslatePoints( out Vector3 p111, out Vector3 p121, out Vector3 p212, out Vector3 p222 ) {
Vector3 centre = Position;
Matrix4 camera = game.View;

View file

@ -6,6 +6,7 @@ namespace ClassicalSharp.Particles {
public sealed class TerrainParticle : Particle {
const float gravity = 2.4f;
static Vector2 terrainSize = new Vector2( 1/16f, 1/16f );
public TerrainParticle( Game game, Vector3 pos, Vector3 velocity, double lifetime, TextureRectangle rec )
: base( game, pos, velocity, lifetime, rec ) {
@ -14,6 +15,7 @@ namespace ClassicalSharp.Particles {
public override void Render( double delta, float t, VertexPos3fTex2fCol4b[] vertices, ref int index ) {
Position = Vector3.Lerp( lastPos, nextPos, t );
Vector3 p111, p121, p212, p222;
Size = terrainSize;
TranslatePoints( out p111, out p121, out p212, out p222 );
Map map = game.Map;
FastColour col = map.IsLit( Vector3I.Floor( Position ) ) ? map.Sunlight : map.Shadowlight;