mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-23 09:34:35 -05:00
less hardcoding in BlockModel
This commit is contained in:
parent
e728e96be8
commit
4aad9a54cf
3 changed files with 3 additions and 16 deletions
|
@ -23,7 +23,6 @@ namespace ClassicalSharp.Model {
|
|||
bool bright;
|
||||
Vector3 minBB, maxBB;
|
||||
public bool NoShade = false, SwitchOrder = false;
|
||||
public float CosX = 1, SinX = 0;
|
||||
ModelCache cache;
|
||||
|
||||
public BlockModel(Game game) : base(game) {
|
||||
|
@ -99,7 +98,6 @@ namespace ClassicalSharp.Model {
|
|||
|
||||
IGraphicsApi gfx = game.Graphics;
|
||||
gfx.BindTexture(lastTexId);
|
||||
TransformVertices();
|
||||
|
||||
if (sprite) gfx.FaceCulling = true;
|
||||
UpdateVB();
|
||||
|
@ -112,22 +110,12 @@ namespace ClassicalSharp.Model {
|
|||
|
||||
if (lastTexId != -1) {
|
||||
game.Graphics.BindTexture(lastTexId);
|
||||
TransformVertices();
|
||||
UpdateVB();
|
||||
}
|
||||
lastTexId = texId;
|
||||
index = 0;
|
||||
}
|
||||
|
||||
void TransformVertices() {
|
||||
for (int i = 0; i < index; i++) {
|
||||
VertexP3fT2fC4b v = cache.vertices[i];
|
||||
float t = 0;
|
||||
t = CosX * v.Y + SinX * v.Z; v.Z = -SinX * v.Y + CosX * v.Z; v.Y = t; // Inlined RotX
|
||||
cache.vertices[i] = v;
|
||||
}
|
||||
}
|
||||
|
||||
CuboidDrawer drawer = new CuboidDrawer();
|
||||
void DrawParts(bool sprite) {
|
||||
// SwitchOrder is needed for held block, which renders without depth testing
|
||||
|
|
|
@ -114,9 +114,8 @@ namespace ClassicalSharp.Renderers {
|
|||
// For second cycle, rotate the block from 0-->15 then back to 15-->0.
|
||||
float rotX = Math.Max(0, (float)angle - 90 * Utils.Deg2Rad);
|
||||
if (rotX >= 45 * Utils.Deg2Rad) rotX = 90 * Utils.Deg2Rad - rotX;
|
||||
held.block.CosX = (float)Math.Cos(rotX * 0.33333);
|
||||
held.block.SinX = (float)Math.Sin(rotX * 0.33333);
|
||||
|
||||
held.held.RotX = (rotX * 0.33333f) * Utils.Rad2Deg;
|
||||
angleY = -90 * (float)Math.Sin(angle);
|
||||
held.block.SwitchOrder = angleY <= -30;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace ClassicalSharp.Renderers {
|
|||
internal HeldBlockAnimation anim;
|
||||
|
||||
Game game;
|
||||
FakePlayer held;
|
||||
internal FakePlayer held;
|
||||
Matrix4 heldBlockProj;
|
||||
|
||||
public void Init(Game game) {
|
||||
|
@ -46,7 +46,7 @@ namespace ClassicalSharp.Renderers {
|
|||
Vector3 last = anim.pos;
|
||||
anim.pos = Vector3.Zero;
|
||||
type = game.Inventory.Selected;
|
||||
block.CosX = 1; block.SinX = 0;
|
||||
held.RotX = 0;
|
||||
block.SwitchOrder = false;
|
||||
if (anim.doAnim) anim.Update(delta, last);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue