/* * @brief Create surface fragments for light-emitting surfaces so that light sources * may be computed along them. */ void BuildPatches(void) { int32_t i, j, k; winding_t *w; vec3_t origin; for (i = 0; i < d_bsp.num_models; i++) { const d_bsp_model_t *mod = &d_bsp.models[i]; const entity_t *ent = EntityForModel(i); // bmodels with origin brushes need to be offset into their // in-use position GetVectorForKey(ent, "origin", origin); for (j = 0; j < mod->num_faces; j++) { const int32_t facenum = mod->first_face + j; d_bsp_face_t *f = &d_bsp.faces[facenum]; VectorCopy(origin, face_offset[facenum]); if (!HasLight(f)) // no light continue; w = WindingForFace(f); for (k = 0; k < w->num_points; k++) { VectorAdd(w->points[k], origin, w->points[k]); } BuildPatch(facenum, w); } } }
/* ============= MakePatches ============= */ void MakePatches (void) { int i, j, k; dface_t *f; int fn; winding_t *w; dmodel_t *mod; vec3_t origin; entity_t *ent; char *s; ParseEntities (); qprintf ("%i faces\n", numfaces); for (i=0 ; i<nummodels ; i++) { mod = dmodels+i; ent = EntityForModel (i); VectorCopy (vec3_origin, origin); // bmodels with origin brushes need to be offset into their // in-use position if ( *(s = ValueForKey(ent,"origin")) ) { double v1, v2, v3; if ( sscanf (s, "%lf %lf %lf", &v1, &v2, &v3) == 3 ) { origin[0] = v1; origin[1] = v2; origin[2] = v3; } } for (j=0 ; j<mod->numfaces ; j++) { fn = mod->firstface + j; face_entity[fn] = ent; VectorCopy (origin, face_offset[fn]); f = dfaces+fn; w = WindingFromFace (f); for (k=0 ; k<w->numpoints ; k++) { VectorAdd (w->p[k], origin, w->p[k]); } MakePatchForFace (fn, w); } } qprintf ("%i square feet [%.2f square inches]\n", (int)(totalarea/144), totalarea ); }
/* ============= MakePatches ============= */ void MakePatches( void ){ int i, j, k; dface_t *f; int fn; winding_t *w; dmodel_t *mod; vec3_t origin; entity_t *ent; Sys_FPrintf( SYS_VRB, "%i faces\n", numfaces ); for ( i = 0 ; i < nummodels ; i++ ) { mod = &dmodels[i]; ent = EntityForModel( i ); // bmodels with origin brushes need to be offset into their // in-use position GetVectorForKey( ent, "origin", origin ); //VectorCopy (vec3_origin, origin); for ( j = 0 ; j < mod->numfaces ; j++ ) { fn = mod->firstface + j; face_entity[fn] = ent; VectorCopy( origin, face_offset[fn] ); f = &dfaces[fn]; w = WindingFromFace( f ); for ( k = 0 ; k < w->numpoints ; k++ ) { VectorAdd( w->p[k], origin, w->p[k] ); } MakePatchForFace( fn, w ); } } Sys_FPrintf( SYS_VRB, "%i sqaure feet\n", (int)( totalarea / 64 ) ); }
/** * @brief Create surface fragments for light-emitting surfaces so that light sources * may be computed along them. */ void BuildPatches (void) { int i; OBJZERO(face_patches); for (i = 0; i < curTile->nummodels; i++) { const dBspModel_t* mod = &curTile->models[i]; const entity_t* ent = EntityForModel(i); vec3_t origin; int j; /* bmodels with origin brushes (like func_door) need to be offset into their * in-use position */ GetVectorForKey(ent, "origin", origin); for (j = 0; j < mod->numfaces; j++) { const int facenum = mod->firstface + j; dBspSurface_t* f = &curTile->faces[facenum]; winding_t* w; int k; /* store the origin in case of moving bmodels (e.g. func_door) */ VectorCopy(origin, face_offset[facenum]); if (!HasLight(f)) /* no light */ continue; w = WindingFromFace(f); for (k = 0; k < w->numpoints; k++) VectorAdd(w->p[k], origin, w->p[k]); BuildPatch(facenum, w); } } }