Revert "Entity, Renderer: Add (incomplete) pig, remake entity renderer"

This reverts commit d6bf825c11.
This commit is contained in:
Er2
2023-12-06 19:39:37 +03:00
parent 470291c7e5
commit 149cd3127b
25 changed files with 70 additions and 283 deletions

View File

@@ -469,9 +469,8 @@ void Minecraft::tickInput()
bool thirdPerson = getOptions()->m_bThirdPerson;
if (thirdPerson && !getOptions()->field_241)
getOptions()->field_241 = 1;
else
{
getOptions()->m_bThirdPerson = !thirdPerson;
else {
getOptions()->m_bThirdPerson = !getOptions()->m_bThirdPerson;
getOptions()->field_241 = 0;
}
}

View File

@@ -16,29 +16,30 @@ Cube::Cube(int a, int b)
m_posX = m_posY = m_posZ = 0.0f;
m_rotX = m_rotY = m_rotZ = 0.0f;
m_swapX = false;
m_bIgnore = false;
field_18 = false;
field_19 = true;
field_1A = false;
m_bCompiled = false;
field_2C0 = 0;
m_buffer = 0;
m_brightness = 1.0f;
m_texOffsetX = a;
m_texOffsetY = b;
field_2B4 = a;
field_2B8 = b;
}
void Cube::addBox(float x, float y, float z, int displayX, int displayY, int displayZ, float scale)
void Cube::addBox(float x, float y, float z, int d, int e, int f, float g)
{
int d = displayX, e = displayY, f = displayZ;
float x1 = x, y1 = y, z1 = z;
float x2 = x + float(d), y2 = y + float(e), z2 = z + float(f);
x1 -= scale;
y1 -= scale;
z1 -= scale;
x2 += scale;
y2 += scale;
z2 += scale;
x1 -= g;
y1 -= g;
z1 -= g;
x2 += g;
y2 += g;
z2 += g;
if (m_swapX)
if (field_18)
std::swap(x1, x2);
m_verts[0] = VertexPT(x1, y1, z1, 0.0f, 0.0f);
@@ -50,7 +51,7 @@ void Cube::addBox(float x, float y, float z, int displayX, int displayY, int dis
m_verts[6] = VertexPT(x2, y2, z2, 8.0f, 8.0f);
m_verts[7] = VertexPT(x1, y2, z2, 8.0f, 0.0f);
int m = m_texOffsetX, n = m_texOffsetY;
int m = field_2B4, n = field_2B8;
m_faces[0] = PolygonQuad(&m_verts[5], &m_verts[1], &m_verts[2], &m_verts[6], m + f + d, n + f, m + f + d + f, n + f + e); // x2 face
m_faces[1] = PolygonQuad(&m_verts[0], &m_verts[4], &m_verts[7], &m_verts[3], m, n + f, m + f, n + f + e); // x1 face
@@ -67,7 +68,7 @@ void Cube::addBox(float x, float y, float z, int displayX, int displayY, int dis
m_faces[3].setColor(0.5f, 0.5f, 0.5f);
#endif
if (m_swapX)
if (field_18)
{
for (int i = 0; i < 6; i++)
m_faces[i].mirror();
@@ -113,7 +114,10 @@ void Cube::drawSlow(float scale)
void Cube::render(float scale)
{
if (m_bIgnore)
if (field_1A)
return;
if (!field_19)
return;
if (!m_bCompiled)
@@ -155,7 +159,10 @@ void Cube::translateRotTo(float scale)
void Cube::translateTo(float scale)
{
if (m_bIgnore)
if (field_1A)
return;
if (!field_19)
return;
if (!hasDefaultRot())
@@ -190,6 +197,6 @@ void Cube::setPos(float x, float y, float z)
void Cube::setTexOffs(int a, int b)
{
m_texOffsetX = a;
m_texOffsetY = b;
field_2B4 = a;
field_2B8 = b;
}

View File

@@ -15,7 +15,7 @@ class Cube
public:
Cube(int, int);
void addBox(float x, float y, float z, int displayX, int displayY, int displayZ, float scale = 0);
void addBox(float a, float b, float c, int d, int e, int f, float g = 0);
// @TODO: void addTexBox(float a, float b, float c, int d, int e, int f, int g); -- No xrefs
void compile(float scale);
void draw();
@@ -39,13 +39,15 @@ public:
float m_rotX;
float m_rotY;
float m_rotZ;
bool m_swapX;
bool m_bIgnore;
bool field_18;
bool field_19;
bool field_1A;
VertexPT m_verts[8];
PolygonQuad m_faces[6];
int m_texOffsetX;
int m_texOffsetY;
int field_2B4;
int field_2B8;
bool m_bCompiled;
int field_2C0;
GLuint m_buffer;
float m_brightness;

View File

@@ -27,12 +27,12 @@ HumanoidModel::HumanoidModel(float a, float b):
m_body.setPos(0, b, 0);
m_armL.addBox(-3, -2, -2, 4, 12, 4, a);
m_armL.setPos(-5, b + 2, 0);
m_armR.m_swapX = true;
m_armR.field_18 = true;
m_armR.addBox(-1, -2, -2, 4, 12, 4, a);
m_armR.setPos(5, b + 2, 0);
m_legL.addBox(-2, 0, -2, 4, 12, 4, a);
m_legL.setPos(-2, b + 12, 0);
m_legR.m_swapX = true;
m_legR.field_18 = true;
m_legR.addBox(-2, 0, -2, 4, 12, 4, a);
m_legR.setPos(2, b + 12, 0);
}

View File

@@ -8,11 +8,10 @@
#include "Model.hpp"
Model::Model(std::string texture)
Model::Model()
{
field_4 = 0.0f;
field_8 = false;
m_texture = texture;
}
void Model::onGraphicsReset()

View File

@@ -15,7 +15,7 @@ class Mob;
class Model
{
public:
Model(std::string texture = "mob/char.png");
Model();
virtual void onGraphicsReset();
virtual void prepareMobModel(Mob*, float, float, float);
virtual void render(float, float, float, float, float, float);
@@ -25,5 +25,4 @@ public:
public:
float field_4;
bool field_8;
std::string m_texture;
};

View File

@@ -1,107 +0,0 @@
/********************************************************************
Minecraft: Pocket Edition - Decompilation Project
Copyright (C) 2023 iProgramInCpp
The following code is licensed under the BSD 1 clause license.
SPDX-License-Identifier: BSD-1-Clause
********************************************************************/
#include "PigModel.hpp"
#include "client/app/Minecraft.hpp"
PigModel::PigModel(float a, float b):
Model("mob/pig.png"),
m_head(0, 0),
m_body(28, 16),
m_armL(0, 16),
m_armR(0, 16),
m_legL(0, 16),
m_legR(0, 16),
m_snout(16, 16)
{
// @NOTE: Why 25 (19+6) is lowest Y coordinate? I have many questions to Mojang
m_head.addBox(-2, 9, -9, 8, 8, 8, a);
m_head.setPos(0, b, 0);
m_snout.addBox(0, 12, -10, 4, 3, 1);
m_snout.setPos(0, b, 0);
m_body.addBox(-3, 11, -3, 10, 8, 16, a);
m_body.setPos(0, b, 0);
m_armL.addBox(-3, 19, -2, 4, 6, 4, a);
m_armL.setPos(0, b, 0);
m_armR.addBox(3, 19, -2, 4, 6, 4, a);
m_armR.setPos(0, b, 0);
m_legL.addBox(-3, 19, 9, 4, 6, 4, a);
m_legL.setPos(0, b, 0);
m_legR.addBox(3, 19, 9, 4, 6, 4, a);
m_legR.setPos(0, b, 0);
}
void PigModel::_logGraphics()
{
Matrix m;
if (Minecraft::customDebugId == 1)
{
// @NOTE: I think most of this function was ifdef'd/commented out
m.fetchGL(GL_MODELVIEW_MATRIX);
}
}
void PigModel::onGraphicsReset()
{
m_head.m_bCompiled = false;
m_body.m_bCompiled = false;
m_armL.m_bCompiled = false;
m_armR.m_bCompiled = false;
m_legL.m_bCompiled = false;
m_legR.m_bCompiled = false;
m_snout.m_bCompiled = false;
}
void PigModel::render(float a, float b, float c, float d, float e, float f)
{
setupAnim(a, b, c, d, e, f);
m_head.render(f);
m_snout.render(f);
m_body.render(f);
m_armL.render(f);
m_armR.render(f);
m_legL.render(f);
m_legR.render(f);
_logGraphics();
}
void PigModel::setupAnim(float a2, float a3, float a4, float yaw, float pitch, float a7)
{
m_snout.m_rotY = m_head.m_rotY = std::clamp(yaw * 0.017453f, -0.5f, 0.5f);
m_snout.m_rotX = m_head.m_rotX = std::clamp(pitch * 0.017453f, -0.5f, 0.5f);
float v12 = (a2 * 0.6662f) + 3.1416f;
m_armL.m_rotX = m_legL.m_rotX = Mth::cos(a2 * 0.6662f) * 0.2f * a3;
m_armR.m_rotX = m_legR.m_rotX = Mth::cos(v12) * 0.2f * a3;
m_armL.m_rotY = m_legL.m_rotY = 0.0f;
m_armR.m_rotY = m_legR.m_rotY = 0.0f;
if (field_8)
{
float v16 = (3.1416f * -0.5f) * 0.8f;
m_armL.m_rotX = m_legL.m_rotX = v16;
m_armR.m_rotX = m_legR.m_rotX = v16;
m_armL.m_rotY = m_legL.m_rotY = (3.1416f * 0.5f) * 0.2f;
m_armR.m_rotY = m_legR.m_rotY = (3.1416f * -0.5f) * 0.2f;
}
}
void PigModel::setBrightness(float f)
{
m_head.setBrightness(f);
m_snout.setBrightness(f);
m_body.setBrightness(f);
m_armL.setBrightness(f);
m_armR.setBrightness(f);
m_legL.setBrightness(f);
m_legR.setBrightness(f);
}

View File

@@ -1,31 +0,0 @@
/********************************************************************
Minecraft: Pocket Edition - Decompilation Project
Copyright (C) 2023 iProgramInCpp
The following code is licensed under the BSD 1 clause license.
SPDX-License-Identifier: BSD-1-Clause
********************************************************************/
#pragma once
#include "Model.hpp"
class PigModel : public Model
{
public:
PigModel(float a, float b);
void _logGraphics();
// @TODO - No xrefs: void render(PigModel* a, float f);
void onGraphicsReset() override;
void render(float, float, float, float, float, float) override;
void setupAnim(float, float, float, float, float, float) override;
void setBrightness(float) override;
public:
Cube m_head, m_body, m_armL, m_armR, m_legL, m_legR, m_snout;
bool field_10BC;
bool field_10BD;
bool field_10BE;
};

View File

@@ -7,7 +7,6 @@
********************************************************************/
#include "ItemInHandRenderer.hpp"
#include "entity/HumanoidMobRenderer.hpp"
#include "client/app/Minecraft.hpp"
ItemInHandRenderer::ItemInHandRenderer(Minecraft* pMC) :
@@ -187,8 +186,7 @@ void ItemInHandRenderer::render(float f)
glRotatef(Mth::sin(float(M_PI) * Mth::sqrt(fAnim)) * 70.0f, 0.0f, 1.0f, 0.0f);
glRotatef(Mth::sin(float(M_PI) * fAnim * fAnim) * -20.0f, 0.0f, 0.0f, 1.0f);
HumanoidMobRenderer* pRenderer = (HumanoidMobRenderer*)EntityRenderDispatcher::getInstance()->getRenderer(m_pMinecraft->m_pLocalPlayer);
m_pMinecraft->m_pTextures->loadAndBindTexture(pRenderer->m_pModel->m_texture);
m_pMinecraft->m_pTextures->loadAndBindTexture("mob/char.png");
glTranslatef(-1.0f, 3.6f, 3.5f);
glRotatef(120.0f, 0.0f, 0.0f, 1.0f);
glRotatef(200.0f, 1.0f, 0.0f, 0.0f);
@@ -196,6 +194,7 @@ void ItemInHandRenderer::render(float f)
glScalef(1.0f, 1.0f, 1.0f);
glTranslatef(5.6f, 0.0f, 0.0f);
HumanoidMobRenderer* pRenderer = (HumanoidMobRenderer*)EntityRenderDispatcher::getInstance()->getRenderer(m_pMinecraft->m_pLocalPlayer);
glScalef(1.0f, 1.0f, 1.0f);
pRenderer->renderHand();

View File

@@ -14,8 +14,7 @@ EntityRenderDispatcher* EntityRenderDispatcher::instance;
float EntityRenderDispatcher::xOff, EntityRenderDispatcher::yOff, EntityRenderDispatcher::zOff;
EntityRenderDispatcher::EntityRenderDispatcher() :
m_ModelRenderer(nullptr, 0),
m_HumanoidRenderer(new HumanoidModel(0.0f, 0.0f), 0.0f)
m_HumanoidMobRenderer(new HumanoidModel(0.0f, 0.0f), 0.0f)
{
m_pItemInHandRenderer = nullptr;
m_pTextures = nullptr;
@@ -27,8 +26,7 @@ EntityRenderDispatcher::EntityRenderDispatcher() :
m_pOptions = nullptr;
m_pFont = nullptr;
m_HumanoidRenderer.init(this);
m_ModelRenderer.init(this);
m_HumanoidMobRenderer.init(this);
m_TntRenderer.init(this);
m_CameraRenderer.init(this);
@@ -76,11 +74,7 @@ EntityRenderer* EntityRenderDispatcher::getRenderer(Entity* pEnt)
case RENDER_CAMERA:
return &m_CameraRenderer;
case RENDER_HUMANOID:
m_HumanoidRenderer.m_pModel = m_HumanoidRenderer.m_pHumanoidModel = (HumanoidModel *)pEnt->getModel();
return &m_HumanoidRenderer;
case RENDER_MODEL:
m_ModelRenderer.m_pModel = pEnt->getModel();
return &m_ModelRenderer;
return &m_HumanoidMobRenderer;
#ifdef ENH_ALLOW_SAND_GRAVITY
case RENDER_FALLING_TILE:
return &m_FallingTileRenderer;
@@ -92,8 +86,7 @@ EntityRenderer* EntityRenderDispatcher::getRenderer(Entity* pEnt)
void EntityRenderDispatcher::onGraphicsReset()
{
m_HumanoidRenderer.onGraphicsReset();
m_ModelRenderer.onGraphicsReset();
m_HumanoidMobRenderer.onGraphicsReset();
}
void EntityRenderDispatcher::prepare(Level* level, Textures* textures, Font* font, Mob* mob, Options* options, float f)

View File

@@ -9,12 +9,11 @@
#pragma once
#include "EntityRenderer.hpp"
#include "HumanoidMobRenderer.hpp"
#include "TripodCameraRenderer.hpp"
#include "TntRenderer.hpp"
#include "ItemRenderer.hpp"
#include "FallingTileRenderer.hpp"
#include "MobRenderer.hpp"
#include "HumanoidMobRenderer.hpp"
class Minecraft;
class Font;
@@ -41,8 +40,7 @@ public:
public:
ItemInHandRenderer* m_pItemInHandRenderer;
MobRenderer m_ModelRenderer;
HumanoidMobRenderer m_HumanoidRenderer;
HumanoidMobRenderer m_HumanoidMobRenderer;
TntRenderer m_TntRenderer;
ItemRenderer m_ItemRenderer;
TripodCameraRenderer m_CameraRenderer;

View File

@@ -9,7 +9,7 @@
#include "EntityRenderer.hpp"
#include "EntityRenderDispatcher.hpp"
EntityRenderer::EntityRenderer()
EntityRenderer::EntityRenderer() : m_model(0.0f, 0.0f)
{
field_4 = 0.0f;
field_8 = 1.0f;

View File

@@ -9,7 +9,7 @@
#pragma once
#include "world/phys/AABB.hpp"
#include "client/model/Model.hpp"
#include "client/model/HumanoidModel.hpp"
#include "client/renderer/Font.hpp"
class EntityRenderDispatcher;
@@ -31,4 +31,8 @@ public:
float field_4;
float field_8;
EntityRenderDispatcher* m_pDispatcher;
// @HUH: Why is there a HumanoidModel here? There's another
// in HumanoidMobRenderer...
HumanoidModel m_model;
};

View File

@@ -9,7 +9,6 @@
#pragma once
#include "MobRenderer.hpp"
#include "client/model/HumanoidModel.hpp"
class HumanoidMobRenderer : public MobRenderer
{

View File

@@ -104,7 +104,7 @@ void MobRenderer::render(Entity* entity, float x, float y, float z, float unused
x1 = 1.0f;
float x2 = pMob->field_130 - pMob->field_12C * (1.0f - f);
bindTexture(m_pModel->m_texture);
bindTexture("mob/char.png");
glEnable(GL_ALPHA_TEST);
m_pModel->setBrightness(entity->getBrightness(1.0f));
@@ -165,7 +165,7 @@ void MobRenderer::renderName(Mob* mob, float x, float y, float z)
void MobRenderer::renderNameTag(Mob* mob, const std::string& str, float x, float y, float z, int a)
{
if (mob->distanceToSqr(m_pDispatcher->m_pMob) > float(a * a) || str.length() == 0)
if (mob->distanceToSqr(m_pDispatcher->m_pMob) > float(a * a))
return;
Font* font = getFont();

View File

@@ -10,7 +10,6 @@
#include "common/Utils.hpp"
#include "world/entity/TripodCamera.hpp"
#include "world/entity/Pig.hpp"
#include "world/entity/PrimedTnt.hpp"
// This lets you make the server shut up and not log events in the debug console.
@@ -123,9 +122,9 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, LoginPacke
sgp.m_version = 2;
sgp.m_time = m_pLevel->getTime();
RakNet::BitStream sgpbs;
sgp.write(&sgpbs);
m_pRakNetPeer->Send(&sgpbs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, guid, false);
RakNet::BitStream *sgpbs;
sgp.write(sgpbs);
m_pRakNetPeer->Send(sgpbs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, guid, false);
// send the connecting player info about all other players in the world
for (int i = 0; i < int(m_pLevel->m_players.size()); i++)
@@ -572,11 +571,6 @@ void ServerSideNetworkHandler::commandSummon(OnlinePlayer* player, const std::ve
else tnt->m_fuseTimer = 0; // as in original
ent = tnt;
}
else if (entity == "pig")
{
Pig *pig = new Pig(m_pLevel, pos.x, pos.y, pos.z);
ent = pig;
}
if (!ent)
{

View File

@@ -1082,8 +1082,3 @@ bool Entity::isLocalPlayer()
{
return false;
}
Model *Entity::getModel()
{
return nullptr;
}

View File

@@ -8,7 +8,6 @@
#pragma once
//#include "client/model/Model.hpp"
#include "world/phys/Vec3.hpp"
#include "world/phys/AABB.hpp"
#include "world/level/Material.hpp"
@@ -26,7 +25,6 @@ enum eEntityRenderType
RENDER_NONE,
RENDER_TNT,
RENDER_HUMANOID,
RENDER_MODEL,
RENDER_ITEM,
RENDER_CAMERA,
@@ -49,7 +47,7 @@ struct EntityPos
EntityPos(const Vec3& pos)
{
m_pos = pos;
m_yaw = 0; m_pitch = 0;
m_yaw = 0; m_pitch = 0;
m_bHasPos = true;
m_bHasRot = false;
}
@@ -145,8 +143,6 @@ public:
virtual bool isLocalPlayer();
virtual Model *getModel();
int hashCode();
bool operator==(const Entity& other) const;

View File

@@ -57,8 +57,8 @@ Mob::Mob(Level* pLevel) : Entity(pLevel)
field_B84 = 0;
m_pEntLookedAt = nullptr;
m_texture = "/mob/char.png";
m_class = "";
m_renderType = RENDER_MODEL;
field_34 = 1;
@@ -439,6 +439,11 @@ void Mob::spawnAnim()
}
std::string Mob::getTexture()
{
return m_texture;
}
void Mob::playAmbientSound()
{

View File

@@ -40,6 +40,7 @@ public:
virtual bool canSee(Entity* pEnt);
virtual bool onLadder();
virtual void spawnAnim();
virtual std::string getTexture();
virtual bool isWaterMob();
virtual void playAmbientSound();
virtual int getAmbientSoundInterval();
@@ -108,8 +109,8 @@ public:
char field_B0C;
float field_B10;
float field_B14;
std::string m_texture;
std::string m_class;
std::string m_name;
int field_B48;
float field_B4C;
float field_B50;

View File

@@ -1,26 +0,0 @@
/********************************************************************
Minecraft: Pocket Edition - Decompilation Project
Copyright (C) 2023 iProgramInCpp
The following code is licensed under the BSD 1 clause license.
SPDX-License-Identifier: BSD-1-Clause
********************************************************************/
#include "Pig.hpp"
#include "world/level/Level.hpp"
Pig::Pig(Level* level, float x, float y, float z) : Mob(level)
{
setSize(1.5f, 0.5f);
field_84 = field_8C;
setPos(x, y, z);
field_3C.x = x;
field_3C.y = y;
field_3C.z = z;
}
Model *Pig::getModel()
{
return &m_model;
}

View File

@@ -1,28 +0,0 @@
/********************************************************************
Minecraft: Pocket Edition - Decompilation Project
Copyright (C) 2023 iProgramInCpp
The following code is licensed under the BSD 1 clause license.
SPDX-License-Identifier: BSD-1-Clause
********************************************************************/
#pragma once
#include "Mob.hpp"
#include "client/model/PigModel.hpp"
class Level;
class Player;
class PigModel;
class Pig : public Mob
{
public:
Pig(Level*, float, float, float);
Model *getModel();
private:
PigModel m_model = PigModel(0.0f, 0.0f);
};

View File

@@ -10,8 +10,7 @@
#include "world/level/Level.hpp"
#include "client/model/Model.hpp"
Player::Player(Level* pLevel) : Mob(pLevel),
m_model(0.0f, 0.0f)
Player::Player(Level* pLevel) : Mob(pLevel)
{
m_pInventory = nullptr;
field_B94 = 0;
@@ -37,6 +36,7 @@ Player::Player(Level* pLevel) : Mob(pLevel),
m_health = 20;
m_class = "humanoid";
m_texture = "mob/char.png";
field_C4 = 20;
field_B5C = 180.0f;
@@ -374,8 +374,3 @@ void Player::interact(Entity* pEnt)
{
pEnt->interact(this);
}
Model *Player::getModel()
{
return &m_model;
}

View File

@@ -8,7 +8,6 @@
#pragma once
#include "client/model/HumanoidModel.hpp"
#include "common/Utils.hpp"
#include "thirdparty/raknet/RakNetTypes.h"
#include "world/item/Inventory.hpp"
@@ -72,8 +71,6 @@ public:
void interact(Entity* pEnt);
#pragma GCC diagnostic pop
Model *getModel() override;
public:
//TODO
Inventory* m_pInventory;
@@ -83,6 +80,7 @@ public:
float field_BA0;
bool field_BA4;
int field_BA8;
std::string m_name;
int field_BC4;
RakNet::RakNetGUID m_guid;
//TODO
@@ -90,8 +88,5 @@ public:
//TODO
bool m_bHaveRespawnPos;
//TODO
private:
HumanoidModel m_model;
};

View File

@@ -7,7 +7,6 @@
********************************************************************/
#include "CameraItem.hpp"
#include "world/entity/Pig.hpp"
#include "world/level/Level.hpp"
#include "world/entity/TripodCamera.hpp"
#include "world/entity/Player.hpp"