Avoid redundant fields in CustomModel

This commit is contained in:
UnknownShadow200 2020-06-17 19:22:33 +10:00
parent b9f2213aa6
commit e87390325e
3 changed files with 12 additions and 26 deletions

View File

@ -687,9 +687,7 @@ static void CustomModel_DrawArm(struct Entity* e) {
static void CheckMaxVertices(void) {
/* hack to undo plugins setting a smaller vertices buffer */
if (Models.MaxVertices < Array_Elems(defaultVertices)) {
Platform_LogConst(
"CheckMaxVertices found smaller buffer, resetting Models.Vb"
);
Platform_LogConst("CheckMaxVertices found smaller buffer, resetting Models.Vb");
Gfx_DeleteDynamicVb(&Models.Vb);
Models.Vertices = defaultVertices;
@ -713,13 +711,7 @@ void CustomModel_Register(struct CustomModel* cm) {
cm->model.GetEyeY = CustomModel_GetEyeY;
cm->model.GetCollisionSize = CustomModel_GetCollisionSize;
cm->model.GetPickingBounds = CustomModel_GetPickingBounds;
Model_Init(&cm->model);
cm->model.bobbing = cm->bobbing;
cm->model.pushes = cm->pushes;
cm->model.usesHumanSkin = cm->usesHumanSkin;
cm->model.calcHumanAnims = cm->calcHumanAnims;
cm->model.DrawArm = CustomModel_DrawArm;
cm->model.DrawArm = CustomModel_DrawArm;
/* add to front of models linked list to override original models */
if (!models_head) {
@ -800,7 +792,7 @@ static void HumanModel_DrawCore(struct Entity* e, struct ModelSet* model, cc_boo
Model_UpdateVB();
}
static void HumanModel_DrawArmCore(struct Entity* e, struct ModelSet* model) {
static void HumanModel_DrawArmCore(struct ModelSet* model) {
struct ModelLimbs* set;
int type;
@ -942,7 +934,7 @@ static void HumanModel_Draw(struct Entity* e) {
}
static void HumanModel_DrawArm(struct Entity* e) {
HumanModel_DrawArmCore(e, &human_set);
HumanModel_DrawArmCore(&human_set);
}
static float HumanModel_GetNameY(struct Entity* e) { return 32.5f/16.0f; }
@ -1033,7 +1025,7 @@ static void ChibiModel_Draw(struct Entity* e) {
}
static void ChibiModel_DrawArm(struct Entity* e) {
HumanModel_DrawArmCore(e, &chibi_set);
HumanModel_DrawArmCore(&chibi_set);
}
static float ChibiModel_GetNameY(struct Entity* e) { return 20.2f/16.0f; }
@ -1745,7 +1737,7 @@ static void ZombieModel_Draw(struct Entity* e) {
HumanModel_DrawCore(e, &human_set, false);
}
static void ZombieModel_DrawArm(struct Entity* e) {
HumanModel_DrawArmCore(e, &human_set);
HumanModel_DrawArmCore(&human_set);
}
static void ZombieModel_GetBounds(struct Entity* e) { Model_RetAABB(-4,0,-4, 4,32,4); }

View File

@ -256,13 +256,6 @@ struct CustomModel {
struct ModelVertex* vertices;
char name[STRING_SIZE + 1];
cc_bool bobbing;
cc_bool pushes;
/* if true, falls back to using your account's skin */
cc_bool usesHumanSkin;
/* use crazy arms */
cc_bool calcHumanAnims;
cc_bool hideFirstPersonArm;
float nameY;

View File

@ -1412,6 +1412,7 @@ static void CPE_DefineModel(cc_uint8* data) {
if (id >= MAX_CUSTOM_MODELS) return;
CustomModel_Undefine(customModel);
Model_Init(&customModel->model);
/* read name */
name = UNSAFE_GetString(data);
@ -1420,11 +1421,11 @@ static void CPE_DefineModel(cc_uint8* data) {
/* read bool flags */
flags = *data++;
customModel->bobbing = (flags >> 0) & 1;
customModel->pushes = (flags >> 1) & 1;
customModel->usesHumanSkin = (flags >> 2) & 1;
customModel->calcHumanAnims = (flags >> 3) & 1;
customModel->hideFirstPersonArm = (flags >> 4) & 1;
customModel->model.bobbing = (flags >> 0) & 1;
customModel->model.pushes = (flags >> 1) & 1;
customModel->model.usesHumanSkin = (flags >> 2) & 1;
customModel->model.calcHumanAnims = (flags >> 3) & 1;
customModel->hideFirstPersonArm = (flags >> 4) & 1;
/* read nameY, eyeY */
customModel->nameY = ReadFloat(data);