Only try to clear solid white/black pixels in 'hat' area of skin for humanoid models - don't do this for skinnedcube or custom models

This commit is contained in:
UnknownShadow200 2023-10-25 22:06:02 +11:00
parent 8d012e9029
commit c0831a8f04
3 changed files with 23 additions and 5 deletions

View File

@ -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) { if (bmp->width > Gfx.MaxTexWidth || bmp->height > Gfx.MaxTexHeight) {
Chat_Add1("&cSkin %s is too large", skin); Chat_Add1("&cSkin %s is too large", skin);
} else { } 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); Gfx_RecreateTexture(&e->TextureId, bmp, TEXTURE_FLAG_MANAGED, false);
Entity_SetSkinAll(e, false); Entity_SetSkinAll(e, false);
} }

View File

@ -423,7 +423,7 @@ static void MakeModel(struct Model* model) {
Models.Active = model; Models.Active = model;
model->MakeParts(); model->MakeParts();
model->inited = true; model->flags |= MODEL_FLAG_INITED;
model->index = 0; model->index = 0;
Models.Active = active; Models.Active = active;
} }
@ -434,7 +434,8 @@ struct Model* Model_Get(const cc_string* name) {
for (model = models_head; model; model = model->next) { for (model = models_head; model; model = model->next) {
if (!String_CaselessEqualsConst(name, model->name)) continue; if (!String_CaselessEqualsConst(name, model->name)) continue;
if (!model->inited) MakeModel(model); if (!(model->flags & MODEL_FLAG_INITED))
MakeModel(model);
return model; return model;
} }
return NULL; return NULL;
@ -1089,8 +1090,11 @@ static struct Model human_model = {
static void HumanoidModel_Register(void) { static void HumanoidModel_Register(void) {
Model_Init(&human_model); Model_Init(&human_model);
human_model.DrawArm = HumanModel_DrawArm; human_model.DrawArm = HumanModel_DrawArm;
human_model.calcHumanAnims = true; human_model.calcHumanAnims = true;
human_model.usesHumanSkin = true; human_model.usesHumanSkin = true;
human_model.flags |= MODEL_FLAG_CLEAR_HAT;
Model_Register(&human_model); Model_Register(&human_model);
} }
@ -1178,9 +1182,13 @@ static struct Model chibi_model = { "chibi", chibi_vertices, &human_tex,
static void ChibiModel_Register(void) { static void ChibiModel_Register(void) {
Model_Init(&chibi_model); Model_Init(&chibi_model);
chibi_model.DrawArm = ChibiModel_DrawArm; 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.calcHumanAnims = true;
chibi_model.usesHumanSkin = true; chibi_model.usesHumanSkin = true;
chibi_model.flags |= MODEL_FLAG_CLEAR_HAT;
chibi_model.maxScale = 3.0f; chibi_model.maxScale = 3.0f;
chibi_model.shadowScale = 0.5f; chibi_model.shadowScale = 0.5f;
Model_Register(&chibi_model); Model_Register(&chibi_model);
@ -1216,8 +1224,11 @@ static struct Model sitting_model = { "sit", human_vertices, &human_tex,
static void SittingModel_Register(void) { static void SittingModel_Register(void) {
Model_Init(&sitting_model); Model_Init(&sitting_model);
sitting_model.DrawArm = HumanModel_DrawArm; sitting_model.DrawArm = HumanModel_DrawArm;
sitting_model.calcHumanAnims = true; sitting_model.calcHumanAnims = true;
sitting_model.usesHumanSkin = true; sitting_model.usesHumanSkin = true;
sitting_model.flags |= MODEL_FLAG_CLEAR_HAT;
sitting_model.shadowScale = 0.5f; sitting_model.shadowScale = 0.5f;
sitting_model.GetTransform = SittingModel_GetTransform; sitting_model.GetTransform = SittingModel_GetTransform;
Model_Register(&sitting_model); Model_Register(&sitting_model);
@ -1278,6 +1289,8 @@ static struct Model head_model = { "head", human_vertices, &human_tex,
static void HeadModel_Register(void) { static void HeadModel_Register(void) {
Model_Init(&head_model); Model_Init(&head_model);
head_model.usesHumanSkin = true; head_model.usesHumanSkin = true;
head_model.flags |= MODEL_FLAG_CLEAR_HAT;
head_model.pushes = false; head_model.pushes = false;
head_model.GetTransform = HeadModel_GetTransform; head_model.GetTransform = HeadModel_GetTransform;
Model_Register(&head_model); Model_Register(&head_model);

View File

@ -37,6 +37,9 @@ struct ModelTex;
/* Contains information about a texture used for models. */ /* Contains information about a texture used for models. */
struct ModelTex { const char* name; cc_uint8 skinType; GfxResourceID texID; struct ModelTex* next; }; 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; struct Model;
/* Contains a set of quads and/or boxes that describe a 3D object as well as /* 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. */ the bounding boxes that contain the entire set of quads and/or boxes. */
@ -67,7 +70,7 @@ struct Model {
int index; int index;
cc_uint8 armX, armY; /* these translate arm model part back to (0, 0) */ 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. */ /* 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 */ /* e.g. for HumanoidModel, when legs are at the peak of their swing, whole model is moved slightly down */
cc_bool bobbing; cc_bool bobbing;