/* * @brief */ static void BuildPatch(int32_t fn, winding_t *w) { patch_t *patch; d_bsp_plane_t *plane; patch = (patch_t *) Mem_Malloc(sizeof(*patch)); face_patches[fn] = patch; patch->face = &d_bsp.faces[fn]; patch->winding = w; // resolve the normal plane = &d_bsp.planes[patch->face->plane_num]; if (patch->face->side) VectorNegate(plane->normal, patch->normal); else VectorCopy(plane->normal, patch->normal); WindingCenter(w, patch->origin); // nudge the origin out along the normal VectorMA(patch->origin, 2.0, patch->normal, patch->origin); patch->area = WindingArea(w); if (patch->area < 1.0) // clamp area patch->area = 1.0; EmissiveLight(patch); // surface light }
/** * @brief Build a patch for a surface that emits light * @note This is called in the lighting stage * @param fn The face number of the surface that emits the light * @param w The winding * @sa BuildLights */ static void BuildPatch (int fn, winding_t* w) { patch_t* patch; dBspPlane_t* plane; patch = Mem_AllocType(patch_t); face_patches[fn] = patch; patch->face = &curTile->faces[fn]; patch->winding = w; /* resolve the normal */ plane = &curTile->planes[patch->face->planenum]; if (patch->face->side) VectorNegate(plane->normal, patch->normal); else VectorCopy(plane->normal, patch->normal); WindingCenter(w, patch->origin); /* nudge the origin out along the normal */ VectorMA(patch->origin, 2.0, patch->normal, patch->origin); patch->area = WindingArea(w); if (patch->area < 1.0) /* clamp area */ patch->area = 1.0; EmissiveLight(patch); /* surface light */ }