diff --git a/src/Entity.c b/src/Entity.c index 118d5118a..6e3c13d1a 100644 --- a/src/Entity.c +++ b/src/Entity.c @@ -416,7 +416,9 @@ static cc_result ApplySkin(struct Entity* e, struct Bitmap* bmp, struct Stream* if (bmp->width > Gfx.MaxTexWidth || bmp->height > Gfx.MaxTexHeight) { Chat_Add1("&cSkin %s is too large", skin); } else { - if (e->Model->usesHumanSkin) Entity_ClearHat(bmp, e->SkinType); + if (e->Model->flags & MODEL_FLAG_CLEAR_HAT) + Entity_ClearHat(bmp, e->SkinType); + Gfx_RecreateTexture(&e->TextureId, bmp, TEXTURE_FLAG_MANAGED, false); Entity_SetSkinAll(e, false); } diff --git a/src/Model.c b/src/Model.c index dfcb9decb..7a13bca9d 100644 --- a/src/Model.c +++ b/src/Model.c @@ -423,7 +423,7 @@ static void MakeModel(struct Model* model) { Models.Active = model; model->MakeParts(); - model->inited = true; + model->flags |= MODEL_FLAG_INITED; model->index = 0; Models.Active = active; } @@ -434,7 +434,8 @@ struct Model* Model_Get(const cc_string* name) { for (model = models_head; model; model = model->next) { if (!String_CaselessEqualsConst(name, model->name)) continue; - if (!model->inited) MakeModel(model); + if (!(model->flags & MODEL_FLAG_INITED)) + MakeModel(model); return model; } return NULL; @@ -1089,8 +1090,11 @@ static struct Model human_model = { static void HumanoidModel_Register(void) { Model_Init(&human_model); human_model.DrawArm = HumanModel_DrawArm; + human_model.calcHumanAnims = true; human_model.usesHumanSkin = true; + human_model.flags |= MODEL_FLAG_CLEAR_HAT; + Model_Register(&human_model); } @@ -1178,9 +1182,13 @@ static struct Model chibi_model = { "chibi", chibi_vertices, &human_tex, static void ChibiModel_Register(void) { Model_Init(&chibi_model); chibi_model.DrawArm = ChibiModel_DrawArm; - chibi_model.armX = 3; chibi_model.armY = 6; + chibi_model.armX = 3; + chibi_model.armY = 6; + chibi_model.calcHumanAnims = true; chibi_model.usesHumanSkin = true; + chibi_model.flags |= MODEL_FLAG_CLEAR_HAT; + chibi_model.maxScale = 3.0f; chibi_model.shadowScale = 0.5f; Model_Register(&chibi_model); @@ -1216,8 +1224,11 @@ static struct Model sitting_model = { "sit", human_vertices, &human_tex, static void SittingModel_Register(void) { Model_Init(&sitting_model); sitting_model.DrawArm = HumanModel_DrawArm; + sitting_model.calcHumanAnims = true; sitting_model.usesHumanSkin = true; + sitting_model.flags |= MODEL_FLAG_CLEAR_HAT; + sitting_model.shadowScale = 0.5f; sitting_model.GetTransform = SittingModel_GetTransform; Model_Register(&sitting_model); @@ -1278,6 +1289,8 @@ static struct Model head_model = { "head", human_vertices, &human_tex, static void HeadModel_Register(void) { Model_Init(&head_model); head_model.usesHumanSkin = true; + head_model.flags |= MODEL_FLAG_CLEAR_HAT; + head_model.pushes = false; head_model.GetTransform = HeadModel_GetTransform; Model_Register(&head_model); diff --git a/src/Model.h b/src/Model.h index 5869af8cc..c4bb9cdbc 100644 --- a/src/Model.h +++ b/src/Model.h @@ -37,6 +37,9 @@ struct ModelTex; /* Contains information about a texture used for models. */ struct ModelTex { const char* name; cc_uint8 skinType; GfxResourceID texID; struct ModelTex* next; }; +#define MODEL_FLAG_INITED 0x01 +#define MODEL_FLAG_CLEAR_HAT 0x02 + struct Model; /* Contains a set of quads and/or boxes that describe a 3D object as well as the bounding boxes that contain the entire set of quads and/or boxes. */ @@ -67,7 +70,7 @@ struct Model { int index; cc_uint8 armX, armY; /* these translate arm model part back to (0, 0) */ - cc_bool inited; + cc_uint8 flags; /* Whether the model should be slightly bobbed up and down when rendering. */ /* e.g. for HumanoidModel, when legs are at the peak of their swing, whole model is moved slightly down */ cc_bool bobbing;