Exemple #1
0
/*
 * @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);
		}
	}
}
Exemple #2
0
/*
 * @brief
 */
static inline void EmissiveLight(patch_t *patch) {

	if (HasLight(patch->face)) {
		const d_bsp_texinfo_t *tex = &d_bsp.texinfo[patch->face->texinfo];
		const vec_t *ref = texture_reflectivity[patch->face->texinfo];

		VectorScale(ref, tex->value, patch->light);
	}
}
Exemple #3
0
/**
 * @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);
		}
	}
}