MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / CustomModel_BuildPart

Function CustomModel_BuildPart

src/Model.c:549–580  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

547#endif
548
549void CustomModel_BuildPart(struct CustomModel* cm, struct CustomModelPartDef* part) {
550 float x1 = part->min.x, y1 = part->min.y, z1 = part->min.z;
551 float x2 = part->max.x, y2 = part->max.y, z2 = part->max.z;
552 struct CustomModelPart* p = &cm->parts[cm->curPartIndex];
553
554 cm->model.index = cm->curPartIndex * MODEL_BOX_VERTICES;
555 p->fullbright = part->flags & 0x01;
556 p->firstPersonArm = part->flags & 0x02;
557 if (p->firstPersonArm) cm->numArmParts++;
558
559 BoxDesc_YQuad2(&cm->model, x1, x2, z2, z1, y2, /* top */
560 part->u1[0], part->v1[0],
561 part->u2[0], part->v2[0]);
562 BoxDesc_YQuad2(&cm->model, x2, x1, z2, z1, y1, /* bottom */
563 part->u1[1], part->v1[1],
564 part->u2[1], part->v2[1]);
565 BoxDesc_ZQuad2(&cm->model, x1, x2, y1, y2, z1, /* front */
566 part->u1[2], part->v1[2],
567 part->u2[2], part->v2[2]);
568 BoxDesc_ZQuad2(&cm->model, x2, x1, y1, y2, z2, /* back */
569 part->u1[3], part->v1[3],
570 part->u2[3], part->v2[3]);
571 BoxDesc_XQuad2(&cm->model, z1, z2, y1, y2, x2, /* left */
572 part->u1[4], part->v1[4],
573 part->u2[4], part->v2[4]);
574 BoxDesc_XQuad2(&cm->model, z2, z1, y1, y2, x1, /* right */
575 part->u1[5], part->v1[5],
576 part->u2[5], part->v2[5]);
577
578 ModelPart_Init(&p->modelPart, cm->model.index - MODEL_BOX_VERTICES, MODEL_BOX_VERTICES,
579 part->rotationOrigin.x, part->rotationOrigin.y, part->rotationOrigin.z);
580}
581
582/* fmodf behaves differently on negatives vs positives,
583 but we want the function to be consistent on both so that the user can

Callers 1

CPE_DefineModelPartFunction · 0.85

Calls 4

BoxDesc_YQuad2Function · 0.85
BoxDesc_ZQuad2Function · 0.85
BoxDesc_XQuad2Function · 0.85
ModelPart_InitFunction · 0.85

Tested by

no test coverage detected