mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 09:35:23 -04:00
Slightly reduce class size of TerrainParticle.
This commit is contained in:
parent
9c557ab234
commit
d24d8bba2e
@ -7,9 +7,8 @@ namespace ClassicalSharp.Particles {
|
|||||||
|
|
||||||
public Vector3 Position;
|
public Vector3 Position;
|
||||||
public Vector3 Velocity;
|
public Vector3 Velocity;
|
||||||
public Vector2 Size = new Vector2( 1 / 16f, 1 / 16f );
|
|
||||||
public TextureRectangle Rectangle;
|
public TextureRectangle Rectangle;
|
||||||
public double Lifetime;
|
public float Lifetime;
|
||||||
protected Game game;
|
protected Game game;
|
||||||
protected Vector3 lastPos, nextPos;
|
protected Vector3 lastPos, nextPos;
|
||||||
|
|
||||||
@ -21,16 +20,17 @@ namespace ClassicalSharp.Particles {
|
|||||||
game = window;
|
game = window;
|
||||||
Position = lastPos = nextPos = pos;
|
Position = lastPos = nextPos = pos;
|
||||||
Velocity = velocity;
|
Velocity = velocity;
|
||||||
Lifetime = lifetime;
|
Lifetime = (float)lifetime;
|
||||||
Rectangle = rec;
|
Rectangle = rec;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool Tick( double delta ) {
|
public virtual bool Tick( double delta ) {
|
||||||
Lifetime -= delta;
|
Lifetime -= (float)delta;
|
||||||
return Lifetime < 0;
|
return Lifetime < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://www.opengl-tutorial.org/intermediate-tutorials/billboards-particles/billboards/
|
// 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 ) {
|
protected void TranslatePoints( out Vector3 p111, out Vector3 p121, out Vector3 p212, out Vector3 p222 ) {
|
||||||
Vector3 centre = Position;
|
Vector3 centre = Position;
|
||||||
Matrix4 camera = game.View;
|
Matrix4 camera = game.View;
|
||||||
|
@ -6,6 +6,7 @@ namespace ClassicalSharp.Particles {
|
|||||||
public sealed class TerrainParticle : Particle {
|
public sealed class TerrainParticle : Particle {
|
||||||
|
|
||||||
const float gravity = 2.4f;
|
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 )
|
public TerrainParticle( Game game, Vector3 pos, Vector3 velocity, double lifetime, TextureRectangle rec )
|
||||||
: base( game, pos, velocity, lifetime, 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 ) {
|
public override void Render( double delta, float t, VertexPos3fTex2fCol4b[] vertices, ref int index ) {
|
||||||
Position = Vector3.Lerp( lastPos, nextPos, t );
|
Position = Vector3.Lerp( lastPos, nextPos, t );
|
||||||
Vector3 p111, p121, p212, p222;
|
Vector3 p111, p121, p212, p222;
|
||||||
|
Size = terrainSize;
|
||||||
TranslatePoints( out p111, out p121, out p212, out p222 );
|
TranslatePoints( out p111, out p121, out p212, out p222 );
|
||||||
Map map = game.Map;
|
Map map = game.Map;
|
||||||
FastColour col = map.IsLit( Vector3I.Floor( Position ) ) ? map.Sunlight : map.Shadowlight;
|
FastColour col = map.IsLit( Vector3I.Floor( Position ) ) ? map.Sunlight : map.Shadowlight;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user