/// <summary> /// Mod_LoadClipnodes /// </summary> static void LoadClipNodes(ref lump_t l) { if ((l.filelen % dclipnode_t.SizeInBytes) != 0) Sys.Error("MOD_LoadBmodel: funny lump size in {0}", _LoadModel.name); int count = l.filelen / dclipnode_t.SizeInBytes; dclipnode_t[] dest = new dclipnode_t[count]; _LoadModel.clipnodes = dest; _LoadModel.numclipnodes = count; hull_t hull = _LoadModel.hulls[1]; hull.clipnodes = dest; hull.firstclipnode = 0; hull.lastclipnode = count - 1; hull.planes = _LoadModel.planes; hull.clip_mins.X = -16; hull.clip_mins.Y = -16; hull.clip_mins.Z = -24; hull.clip_maxs.X = 16; hull.clip_maxs.Y = 16; hull.clip_maxs.Z = 32; hull = _LoadModel.hulls[2]; hull.clipnodes = dest; hull.firstclipnode = 0; hull.lastclipnode = count - 1; hull.planes = _LoadModel.planes; hull.clip_mins.X = -32; hull.clip_mins.Y = -32; hull.clip_mins.Z = -24; hull.clip_maxs.X = 32; hull.clip_maxs.Y = 32; hull.clip_maxs.Z = 64; for (int i = 0, offset = l.fileofs; i < count; i++, offset += dclipnode_t.SizeInBytes) { dclipnode_t src = Sys.BytesToStructure<dclipnode_t>(_ModBase, offset); dest[i].planenum = Common.LittleLong(src.planenum); // Uze: changed from LittleShort dest[i].children = new short[2]; dest[i].children[0] = Common.LittleShort(src.children[0]); dest[i].children[1] = Common.LittleShort(src.children[1]); } }
/// <summary> /// Mod_MakeHull0 /// Deplicate the drawing hull structure as a clipping hull /// </summary> static void MakeHull0() { hull_t hull = _LoadModel.hulls[0]; mnode_t[] src = _LoadModel.nodes; int count = _LoadModel.numnodes; dclipnode_t[] dest = new dclipnode_t[count]; hull.clipnodes = dest; hull.firstclipnode = 0; hull.lastclipnode = count - 1; hull.planes = _LoadModel.planes; for (int i = 0; i < count; i++) { dest[i].planenum = Array.IndexOf(_LoadModel.planes, src[i].plane); // todo: optimize this dest[i].children = new short[2]; for (int j = 0; j < 2; j++) { mnodebase_t child = src[i].children[j]; if (child.contents < 0) dest[i].children[j] = (short)child.contents; else dest[i].children[j] = (short)Array.IndexOf(_LoadModel.nodes, (mnode_t)child); // todo: optimize this } } }