MCPcopy Create free account
hub / github.com/JACoders/OpenJK / R_LoadSubmodels

Function R_LoadSubmodels

code/rd-vanilla/tr_bsp.cpp:737–787  ·  view source on GitHub ↗

================= R_LoadSubmodels ================= */

Source from the content-addressed store, hash-verified

735=================
736*/
737static void R_LoadSubmodels( lump_t *l, world_t &worldData, int index ) {
738 dmodel_t *in;
739 bmodel_t *out;
740 int i, j, count;
741
742 in = (dmodel_t *)(fileBase + l->fileofs);
743 if (l->filelen % sizeof(*in))
744 Com_Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData.name);
745 count = l->filelen / sizeof(*in);
746
747 worldData.bmodels = out = (bmodel_t *) R_Hunk_Alloc( count * sizeof(*out), qtrue );
748
749 for ( i=0 ; i<count ; i++, in++, out++ ) {
750 model_t *model;
751
752 model = R_AllocModel();
753
754 assert( model != NULL ); // this should never happen
755 if ( model == NULL ) {
756 ri.Error(ERR_DROP, "R_LoadSubmodels: R_AllocModel() failed");
757 }
758
759 model->type = MOD_BRUSH;
760 model->bmodel = out;
761 if (index)
762 {
763 Com_sprintf( model->name, sizeof( model->name ), "*%d-%d", index, i );
764 model->bspInstance = true;
765 }
766 else
767 {
768 Com_sprintf( model->name, sizeof( model->name ), "*%d", i);
769 }
770
771 for (j=0 ; j<3 ; j++) {
772 out->bounds[0][j] = LittleFloat (in->mins[j]);
773 out->bounds[1][j] = LittleFloat (in->maxs[j]);
774 }
775/*
776Ghoul2 Insert Start
777*/
778
779 RE_InsertModelIntoHash(model->name, model);
780/*
781Ghoul2 Insert End
782*/
783
784 out->firstSurface = worldData.surfaces + LittleLong( in->firstSurface );
785 out->numSurfaces = LittleLong( in->numSurfaces );
786 }
787}
788
789
790

Callers 1

RE_LoadWorldMap_ActualFunction · 0.70

Calls 6

R_Hunk_AllocFunction · 0.85
Com_ErrorFunction · 0.70
R_AllocModelFunction · 0.70
RE_InsertModelIntoHashFunction · 0.70
Com_sprintfFunction · 0.50
ErrorMethod · 0.45

Tested by

no test coverage detected