TU46 Test content and patches

TU46 Test content, added missing commits by amending commit and cherry-picking to new branch, ready for iggy guis and tu46 bug fixes
This commit is contained in:
Tranqlmao authored and DrPerkyLegit committed 2026-10-22 13:55:39 -04:00
1 parent 8d6b69f599
commit ff562d1644
497 files changed
+11187 -771

No files matched your search

+94 -38
View File
@@ -1,51 +1,107 @@
#include "stdafx.h"
#include "BoatModel.h"
#include "../Minecraft.World/Boat.h"
#include "../Minecraft.World/Mth.h"
static float clampedLerp(float from, float to, float t)
{
if (t < 0.0f) return from;
if (t > 1.0f) return to;
return from + (to - from) * t;
}
ModelPart *BoatModel::makePaddle(bool isLeft)
{
ModelPart *paddle = new ModelPart(this, 62, isLeft ? 0 : 20);
paddle->setTexSize(128, 64);
paddle->addBox(-1.0f, 0.0f, -5.0f, 2, 2, 18);
paddle->addBox(isLeft ? -1.001f : 0.001f, -3.0f, 8.0f, 1, 6, 7);
return paddle;
}
BoatModel::BoatModel() : Model()
{
cubes[0] = new ModelPart(this, 0, 8);
cubes[1] = new ModelPart(this, 0, 0);
cubes[2] = new ModelPart(this, 0, 0);
cubes[3] = new ModelPart(this, 0, 0);
cubes[4] = new ModelPart(this, 0, 0);
texWidth = 128;
texHeight = 64;
int w = 24;
int d = 6;
int h = 20;
int yOff = 4;
bottom = new ModelPart(this, 0, 0);
back = new ModelPart(this, 0, 19);
front = new ModelPart(this, 0, 27);
right = new ModelPart(this, 0, 35);
left = new ModelPart(this, 0, 43);
cubes[0]->addBox(static_cast<float>(-w / 2), static_cast<float>(-h / 2 + 2), -3, w, h - 4, 4, 0);
cubes[0]->setPos(0, static_cast<float>(0 + yOff), 0);
cubes[1]->addBox(static_cast<float>(-w / 2 + 2), static_cast<float>(-d - 1), -1, w - 4, d, 2, 0);
cubes[1]->setPos(static_cast<float>(-w / 2 + 1), static_cast<float>(0 + yOff), 0);
cubes[2]->addBox(static_cast<float>(-w / 2 + 2), static_cast<float>(-d - 1), -1, w - 4, d, 2, 0);
cubes[2]->setPos(static_cast<float>(+w / 2 - 1), static_cast<float>(0 + yOff), 0);
cubes[3]->addBox(static_cast<float>(-w / 2 + 2), static_cast<float>(-d - 1), -1, w - 4, d, 2, 0);
cubes[3]->setPos(0, static_cast<float>(0 + yOff), static_cast<float>(-h / 2 + 1));
cubes[4]->addBox(static_cast<float>(-w / 2 + 2), static_cast<float>(-d - 1), -1, w - 4, d, 2, 0);
cubes[4]->setPos(0, static_cast<float>(0 + yOff), static_cast<float>(+h / 2 - 1));
cubes[0]->xRot = PI / 2;
cubes[1]->yRot = PI / 2 * 3;
cubes[2]->yRot = PI / 2 * 1;
cubes[3]->yRot = PI / 2 * 2;
bottom->addBox(-14.0f, -9.0f, -3.0f, 28, 16, 3, 0.0f);
bottom->setPos(0.0f, 3.0f, 1.0f);
back->addBox(-13.0f, -7.0f, -1.0f, 18, 6, 2, 0.0f);
back->setPos(-15.0f, 4.0f, 4.0f);
front->addBox(-8.0f, -7.0f, -1.0f, 16, 6, 2, 0.0f);
front->setPos(15.0f, 4.0f, 0.0f);
right->addBox(-14.0f, -7.0f, -1.0f, 28, 6, 2, 0.0f);
right->setPos(0.0f, 4.0f, -9.0f);
left->addBox(-14.0f, -7.0f, -1.0f, 28, 6, 2, 0.0f);
left->setPos(0.0f, 4.0f, 9.0f);
bottom->xRot = PI / 2;
back->yRot = PI / 2 * 3;
front->yRot = PI / 2;
right->yRot = PI;
paddleLeft = makePaddle(true);
paddleLeft->setPos(3.0f, -5.0f, 9.0f);
paddleRight = makePaddle(false);
paddleRight->setPos(3.0f, -5.0f, -9.0f);
paddleRight->yRot = PI;
paddleLeft->zRot = PI / 16;
paddleRight->zRot = PI / 16;
waterPatch = new ModelPart(this, 0, 0);
waterPatch->setTexSize(128, 64);
waterPatch->addBox(-14.0f, -9.0f, -3.0f, 28, 16, 3, 0.0f);
waterPatch->setPos(0.0f, -3.0f, 1.0f);
waterPatch->xRot = PI / 2;
// 4J added - compile now to avoid random performance hit first time cubes are rendered
cubes[0]->compile(1.0f/16.0f);
cubes[1]->compile(1.0f/16.0f);
cubes[2]->compile(1.0f/16.0f);
cubes[3]->compile(1.0f/16.0f);
cubes[4]->compile(1.0f/16.0f);
bottom->compile(1.0f / 16.0f);
back->compile(1.0f / 16.0f);
front->compile(1.0f / 16.0f);
right->compile(1.0f / 16.0f);
left->compile(1.0f / 16.0f);
paddleLeft->compile(1.0f / 16.0f);
paddleRight->compile(1.0f / 16.0f);
waterPatch->compile(1.0f / 16.0f);
}
void BoatModel::animatePaddle(ModelPart *paddle, float rowingTime, int side, float scale, bool usecompiled)
{
paddle->xRot = clampedLerp(-PI / 3, -PI / 12, (Mth::sin(-rowingTime) + 1.0f) / 2.0f);
paddle->yRot = clampedLerp(-PI / 4, PI / 4, (Mth::sin(-rowingTime + 1.0f) + 1.0f) / 2.0f);
if (side == 1)
{
paddle->yRot = PI - paddle->yRot;
}
paddle->render(scale, usecompiled);
}
void BoatModel::render(shared_ptr<Entity> entity, float time, float r, float bob, float yRot, float xRot, float scale, bool usecompiled)
{
for (int i = 0; i < 5; i++)
{
cubes[i]->render(scale, usecompiled);
}
}
glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
bottom->render(scale, usecompiled);
back->render(scale, usecompiled);
front->render(scale, usecompiled);
right->render(scale, usecompiled);
left->render(scale, usecompiled);
shared_ptr<Boat> boat = dynamic_pointer_cast<Boat>(entity);
float a = time;
animatePaddle(paddleLeft, boat != nullptr ? boat->getRowingTime(0, a) : 0.0f, 0, scale, usecompiled);
animatePaddle(paddleRight, boat != nullptr ? boat->getRowingTime(1, a) : 0.0f, 1, scale, usecompiled);
}
void BoatModel::renderWaterPatch(float scale, bool usecompiled)
{
glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
glColorMask(false, false, false, false);
waterPatch->render(scale, usecompiled);
glColorMask(true, true, true, true);
}