mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 18:15:28 -04:00
Save 32kb from custom_models array by avoiding pointless padding
This commit is contained in:
parent
6153ff8c8a
commit
f5bed6ff69
60
src/Model.c
60
src/Model.c
@ -581,13 +581,8 @@ static float EuclidianMod(float x, float y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct ModelVertex oldVertices[MODEL_BOX_VERTICES];
|
static struct ModelVertex oldVertices[MODEL_BOX_VERTICES];
|
||||||
static float CustomModel_GetAnimationValue(
|
static float CustomModel_GetAnimValue(cc_uint8 type, struct CustomModelAnim* anim, struct Entity* e) {
|
||||||
struct CustomModelAnim* anim,
|
switch (type) {
|
||||||
struct CustomModelPart* part,
|
|
||||||
struct CustomModel* cm,
|
|
||||||
struct Entity* e
|
|
||||||
) {
|
|
||||||
switch (anim->type) {
|
|
||||||
case CustomModelAnimType_Head:
|
case CustomModelAnimType_Head:
|
||||||
return -e->Pitch * MATH_DEG2RAD;
|
return -e->Pitch * MATH_DEG2RAD;
|
||||||
|
|
||||||
@ -670,6 +665,7 @@ static void CustomModel_DrawPart(
|
|||||||
float rotX, rotY, rotZ;
|
float rotX, rotY, rotZ;
|
||||||
cc_bool head = false;
|
cc_bool head = false;
|
||||||
cc_bool modifiedVertices = false;
|
cc_bool modifiedVertices = false;
|
||||||
|
cc_uint8 type, axis;
|
||||||
float value = 0.0f;
|
float value = 0.0f;
|
||||||
|
|
||||||
if (part->fullbright) {
|
if (part->fullbright) {
|
||||||
@ -690,20 +686,22 @@ static void CustomModel_DrawPart(
|
|||||||
for (animIndex = 0; animIndex < MAX_CUSTOM_MODEL_ANIMS; animIndex++)
|
for (animIndex = 0; animIndex < MAX_CUSTOM_MODEL_ANIMS; animIndex++)
|
||||||
{
|
{
|
||||||
struct CustomModelAnim* anim = &part->anims[animIndex];
|
struct CustomModelAnim* anim = &part->anims[animIndex];
|
||||||
if (anim->type == CustomModelAnimType_None) continue;
|
type = part->animType[animIndex];
|
||||||
|
axis = part->animAxis[animIndex];
|
||||||
|
|
||||||
value = CustomModel_GetAnimationValue(anim, part, cm, e);
|
if (type == CustomModelAnimType_None) continue;
|
||||||
|
value = CustomModel_GetAnimValue(type, anim, e);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!modifiedVertices &&
|
!modifiedVertices &&
|
||||||
(anim->type == CustomModelAnimType_SinTranslate ||
|
(type == CustomModelAnimType_SinTranslate ||
|
||||||
anim->type == CustomModelAnimType_SinTranslateVelocity ||
|
type == CustomModelAnimType_SinTranslateVelocity ||
|
||||||
anim->type == CustomModelAnimType_SinSize ||
|
type == CustomModelAnimType_SinSize ||
|
||||||
anim->type == CustomModelAnimType_SinSizeVelocity ||
|
type == CustomModelAnimType_SinSizeVelocity ||
|
||||||
anim->type == CustomModelAnimType_FlipTranslate ||
|
type == CustomModelAnimType_FlipTranslate ||
|
||||||
anim->type == CustomModelAnimType_FlipTranslateVelocity ||
|
type == CustomModelAnimType_FlipTranslateVelocity ||
|
||||||
anim->type == CustomModelAnimType_FlipSize ||
|
type == CustomModelAnimType_FlipSize ||
|
||||||
anim->type == CustomModelAnimType_FlipSizeVelocity)
|
type == CustomModelAnimType_FlipSizeVelocity)
|
||||||
) {
|
) {
|
||||||
modifiedVertices = true;
|
modifiedVertices = true;
|
||||||
Mem_Copy(
|
Mem_Copy(
|
||||||
@ -714,14 +712,14 @@ static void CustomModel_DrawPart(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
anim->type == CustomModelAnimType_SinTranslate ||
|
type == CustomModelAnimType_SinTranslate ||
|
||||||
anim->type == CustomModelAnimType_SinTranslateVelocity ||
|
type == CustomModelAnimType_SinTranslateVelocity ||
|
||||||
anim->type == CustomModelAnimType_FlipTranslate ||
|
type == CustomModelAnimType_FlipTranslate ||
|
||||||
anim->type == CustomModelAnimType_FlipTranslateVelocity
|
type == CustomModelAnimType_FlipTranslateVelocity
|
||||||
) {
|
) {
|
||||||
for (i = 0; i < MODEL_BOX_VERTICES; i++) {
|
for (i = 0; i < MODEL_BOX_VERTICES; i++) {
|
||||||
struct ModelVertex* vertex = &cm->model.vertices[part->modelPart.offset + i];
|
struct ModelVertex* vertex = &cm->model.vertices[part->modelPart.offset + i];
|
||||||
switch (anim->axis) {
|
switch (axis) {
|
||||||
case CustomModelAnimAxis_X:
|
case CustomModelAnimAxis_X:
|
||||||
vertex->x += value;
|
vertex->x += value;
|
||||||
break;
|
break;
|
||||||
@ -736,14 +734,14 @@ static void CustomModel_DrawPart(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
anim->type == CustomModelAnimType_SinSize ||
|
type == CustomModelAnimType_SinSize ||
|
||||||
anim->type == CustomModelAnimType_SinSizeVelocity ||
|
type == CustomModelAnimType_SinSizeVelocity ||
|
||||||
anim->type == CustomModelAnimType_FlipSize ||
|
type == CustomModelAnimType_FlipSize ||
|
||||||
anim->type == CustomModelAnimType_FlipSizeVelocity
|
type == CustomModelAnimType_FlipSizeVelocity
|
||||||
) {
|
) {
|
||||||
for (i = 0; i < MODEL_BOX_VERTICES; i++) {
|
for (i = 0; i < MODEL_BOX_VERTICES; i++) {
|
||||||
struct ModelVertex* vertex = &cm->model.vertices[part->modelPart.offset + i];
|
struct ModelVertex* vertex = &cm->model.vertices[part->modelPart.offset + i];
|
||||||
switch (anim->axis) {
|
switch (axis) {
|
||||||
case CustomModelAnimAxis_X:
|
case CustomModelAnimAxis_X:
|
||||||
vertex->x = Math_Lerp(part->modelPart.rotX, vertex->x, value);
|
vertex->x = Math_Lerp(part->modelPart.rotX, vertex->x, value);
|
||||||
break;
|
break;
|
||||||
@ -758,11 +756,11 @@ static void CustomModel_DrawPart(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (anim->type == CustomModelAnimType_Head) {
|
if (type == CustomModelAnimType_Head) {
|
||||||
head = true;
|
head = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (anim->axis) {
|
switch (axis) {
|
||||||
case CustomModelAnimAxis_X:
|
case CustomModelAnimAxis_X:
|
||||||
rotX += value;
|
rotX += value;
|
||||||
break;
|
break;
|
||||||
@ -2317,8 +2315,8 @@ static void RecalcProperties(struct Entity* e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void DrawBlockTransform(struct Entity* e, float dispX, float dispY, float dispZ, float scale) {
|
static void DrawBlockTransform(struct Entity* e, float dispX, float dispY, float dispZ, float scale) {
|
||||||
static Vec3 pos;
|
struct Matrix m, temp;
|
||||||
static struct Matrix m, temp;
|
Vec3 pos;
|
||||||
|
|
||||||
pos = e->Position;
|
pos = e->Position;
|
||||||
pos.y += e->Anim.BobbingModel;
|
pos.y += e->Anim.BobbingModel;
|
||||||
|
@ -252,8 +252,6 @@ enum CustomModelAnimAxis {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct CustomModelAnim {
|
struct CustomModelAnim {
|
||||||
cc_uint8 type;
|
|
||||||
cc_uint8 axis;
|
|
||||||
float a, b, c, d;
|
float a, b, c, d;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -269,6 +267,8 @@ struct CustomModelPart {
|
|||||||
struct ModelPart modelPart;
|
struct ModelPart modelPart;
|
||||||
Vec3 rotation; /* rotation angles */
|
Vec3 rotation; /* rotation angles */
|
||||||
struct CustomModelAnim anims[MAX_CUSTOM_MODEL_ANIMS];
|
struct CustomModelAnim anims[MAX_CUSTOM_MODEL_ANIMS];
|
||||||
|
cc_uint8 animType[MAX_CUSTOM_MODEL_ANIMS];
|
||||||
|
cc_uint8 animAxis[MAX_CUSTOM_MODEL_ANIMS];
|
||||||
cc_bool fullbright;
|
cc_bool fullbright;
|
||||||
cc_bool firstPersonArm;
|
cc_bool firstPersonArm;
|
||||||
};
|
};
|
||||||
|
@ -1707,8 +1707,8 @@ static void CPE_DefineModelPart(cc_uint8* data) {
|
|||||||
for (i = 0; i < MAX_CUSTOM_MODEL_ANIMS; i++)
|
for (i = 0; i < MAX_CUSTOM_MODEL_ANIMS; i++)
|
||||||
{
|
{
|
||||||
cc_uint8 tmp = *data++;
|
cc_uint8 tmp = *data++;
|
||||||
part->anims[i].type = tmp & 0x3F;
|
part->animType[i] = tmp & 0x3F;
|
||||||
part->anims[i].axis = tmp >> 6;
|
part->animAxis[i] = tmp >> 6;
|
||||||
|
|
||||||
part->anims[i].a = GetFloat(data);
|
part->anims[i].a = GetFloat(data);
|
||||||
data += 4;
|
data += 4;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user