static void SetupSubModel(model_t mod, ref dmodel_t submodel) { mod.hulls[0].firstclipnode = submodel.headnode[0]; for (int j = 1; j < BspFile.MAX_MAP_HULLS; j++) { mod.hulls[j].firstclipnode = submodel.headnode[j]; mod.hulls[j].lastclipnode = mod.numclipnodes - 1; } mod.firstmodelsurface = submodel.firstface; mod.nummodelsurfaces = submodel.numfaces; Common.Copy(submodel.maxs, out mod.maxs); // mod.maxs = submodel.maxs; Common.Copy(submodel.mins, out mod.mins); // mod.mins = submodel.mins; mod.radius = RadiusFromBounds(ref mod.mins, ref mod.maxs); mod.numleafs = submodel.visleafs; }
/// <summary> /// Mod_LoadSubmodels /// </summary> static void LoadSubModels(ref lump_t l) { if ((l.filelen % dmodel_t.SizeInBytes) != 0) Sys.Error("MOD_LoadBmodel: funny lump size in {0}", _LoadModel.name); int count = l.filelen / dmodel_t.SizeInBytes; dmodel_t[] dest = new dmodel_t[count]; _LoadModel.submodels = dest; _LoadModel.numsubmodels = count; for (int i = 0, offset = l.fileofs; i < count; i++, offset += dmodel_t.SizeInBytes) { dmodel_t src = Sys.BytesToStructure<dmodel_t>(_ModBase, offset); dest[i].mins = new float[3]; dest[i].maxs = new float[3]; dest[i].origin = new float[3]; for (int j = 0; j < 3; j++) { // spread the mins / maxs by a pixel dest[i].mins[j] = Common.LittleFloat(src.mins[j]) - 1; dest[i].maxs[j] = Common.LittleFloat(src.maxs[j]) + 1; dest[i].origin[j] = Common.LittleFloat(src.origin[j]); } dest[i].headnode = new int[BspFile.MAX_MAP_HULLS]; for (int j = 0; j < BspFile.MAX_MAP_HULLS; j++) dest[i].headnode[j] = Common.LittleLong(src.headnode[j]); dest[i].visleafs = Common.LittleLong(src.visleafs); dest[i].firstface = Common.LittleLong(src.firstface); dest[i].numfaces = Common.LittleLong(src.numfaces); } }