Beispiel #1
0
/**
 * @brief Performs a frustum-cull of all entities. This is performed in a separate
 * thread while the renderer draws the world. Mesh entities which pass a frustum
 * cull will also have their lighting information updated.
 */
void R_CullEntities(void) {

	r_entity_t *e = r_view.entities;
	for (uint16_t i = 0; i < r_view.num_entities; i++, e++) {

		r_entities_t *ents = &r_sorted_entities.null_entities;

		if (IS_BSP_INLINE_MODEL(e->model)) {

			if (R_CullBspInlineModel(e)) {
				continue;
			}

			ents = &r_sorted_entities.bsp_inline_entities;
		} else if (IS_MESH_MODEL(e->model)) {

			if (R_CullMeshModel(e)) {
				continue;
			}

			R_UpdateMeshModelLighting(e);

			ents = &r_sorted_entities.mesh_entities;
		}

		R_ENTITY_TO_ENTITIES(ents, e); // append to the appropriate draw list

		R_SetMatrixForEntity(e); // set the transform matrix
	}

	// sort the mesh entities list by model to allow object instancing

	r_entities_t *mesh = &r_sorted_entities.mesh_entities;
	qsort(mesh, mesh->count, sizeof(r_entity_t *), R_CullEntities_compare);
}
Beispiel #2
0
/**
 * @brief Perform a frustum cull check for a given entity
 * @param[in,out] e The entity to perform the frustum cull check for
 * @return @c false if visible, @c true is the origin of the entity is outside the
 * current frustum view
 */
static bool R_CullEntity (entity_t* e)
{
	if (refdef.rendererFlags & RDF_NOWORLDMODEL)
		return false;

	if (r_nocull->integer)
		return false;

	if (!e->model)  /* don't bother culling null model ents */
		return false;

	if (e->model->type == mod_bsp_submodel)
		return R_CullBspModel(e);
	else
		return R_CullMeshModel(e);
}