l = (int)strlen(entname) - 4;
if (l >= 0 && !strcmp(entname + l, ".bsp"))
{
- strcpy(entname + l, ".ent");
+ memcpy(entname + l, ".ent", 5);
if ((entities = (char *)FS_LoadFile(entname, tempmempool, true, NULL)))
{
CL_ParseEntityLump(entities);
VectorClear(ent->modellight_diffuse);
VectorClear(ent->modellight_lightdir);
if ((ent->flags & RENDER_LIGHT) && r_refdef.worldmodel && r_refdef.worldmodel->brush.LightPoint)
- r_refdef.worldmodel->brush.LightPoint(r_refdef.worldmodel, ent->origin, ent->modellight_ambient, ent->modellight_diffuse, tempdiffusenormal);
+ {
+ vec3_t org;
+ Matrix4x4_OriginFromMatrix(&ent->matrix, org);
+ r_refdef.worldmodel->brush.LightPoint(r_refdef.worldmodel, org, ent->modellight_ambient, ent->modellight_diffuse, tempdiffusenormal);
+ }
else // highly rare
VectorSet(ent->modellight_ambient, 1, 1, 1);
Matrix4x4_Transform3x3(&ent->inversematrix, tempdiffusenormal, ent->modellight_lightdir);
for (i = 0;i < r_refdef.numentities;i++)
{
ent = r_refdef.entities[i];
- r_viewcache.entityvisible[i] = !(ent->flags & renderimask) && !R_CullBox(ent->mins, ent->maxs) && (ent->effects & EF_NODEPTHTEST);
+ r_viewcache.entityvisible[i] = !(ent->flags & renderimask) && !R_CullBox(ent->mins, ent->maxs);
}
}
}
for (i = 0;i < r_refdef.numentities;i++)
{
entity_render_t *ent = r_refdef.entities[i];
- // some of the renderer still relies on origin...
- Matrix4x4_OriginFromMatrix(&ent->matrix, ent->origin);
- // some of the renderer still relies on scale...
- ent->scale = Matrix4x4_ScaleFromMatrix(&ent->matrix);
R_UpdateEntityLighting(ent);
}
}
================
*/
void R_RenderView(void)
-{
- if (!r_refdef.entities/* || !r_refdef.worldmodel*/)
- return; //Host_Error ("R_RenderView: NULL worldmodel");
-
- CHECKGLERROR
- if (r_timereport_active)
- R_TimeReport("setup");
-
- R_View_Update();
- if (r_timereport_active)
- R_TimeReport("visibility");
-
- // GL is weird because it's bottom to top, r_view.y is top to bottom
- R_ResetViewRendering();
-
- R_ClearScreen();
- if (r_timereport_active)
- R_TimeReport("clear");
-
- // this produces a bloom texture to be used in R_BlendView() later
- if (r_hdr.integer)
- R_HDR_RenderBloomTexture();
-
- r_view.colorscale = r_hdr_scenebrightness.value;
- R_RenderScene();
-
- R_BlendView();
- if (r_timereport_active)
- R_TimeReport("blendview");
-
- GL_Scissor(0, 0, vid.width, vid.height);
- GL_ScissorTest(false);
- CHECKGLERROR
-}
-
-//[515]: csqc
-void CSQC_R_ClearScreen (void)
{
if (!r_refdef.entities/* || !r_refdef.worldmodel*/)
return; //Host_Error ("R_RenderView: NULL worldmodel");
R_ResetViewRendering();
- R_ClearScreen();
- if (r_timereport_active)
- R_TimeReport("clear");
- CHECKGLERROR
-}
-
-//[515]: csqc
-void CSQC_R_RenderScene (void)
-{
- R_ResetViewRendering();
-
R_ClearScreen();
if (r_timereport_active)
R_TimeReport("clear");
extern void R_DrawPortals (void);
void R_RenderScene(void)
{
+ DrawQ_Finish();
+
// don't let sound skip if going slow
if (r_refdef.extraupdate)
S_ExtraUpdate ();
R_Mesh_VertexPointer(nomodelvertex3f);
if (r_refdef.fogenabled)
{
+ vec3_t org;
memcpy(color4f, nomodelcolor4f, sizeof(float[6*4]));
R_Mesh_ColorPointer(color4f);
- f2 = VERTEXFOGTABLE(VectorDistance(ent->origin, r_view.origin));
+ Matrix4x4_OriginFromMatrix(&ent->matrix, org);
+ f2 = VERTEXFOGTABLE(VectorDistance(org, r_view.origin));
f1 = 1 - f2;
for (i = 0, c = color4f;i < 6;i++, c += 4)
{
void R_DrawNoModel(entity_render_t *ent)
{
+ vec3_t org;
+ Matrix4x4_OriginFromMatrix(&ent->matrix, org);
//if ((ent->effects & EF_ADDITIVE) || (ent->alpha < 1))
- R_MeshQueue_AddTransparent(ent->effects & EF_NODEPTHTEST ? r_view.origin : ent->origin, R_DrawNoModel_TransparentCallback, ent, 0, r_shadow_rtlight);
+ R_MeshQueue_AddTransparent(ent->effects & EF_NODEPTHTEST ? r_view.origin : org, R_DrawNoModel_TransparentCallback, ent, 0, r_shadow_rtlight);
//else
// R_DrawNoModelCallback(ent, 0);
}
{
w = 0;
tempnumpoints = 4;
- PolygonD_QuadForPlane(temppoints[w], plane->normal[0], plane->normal[1], plane->normal[2], plane->normal[3], maxdist);
+ PolygonD_QuadForPlane(temppoints[w], plane->normal[0], plane->normal[1], plane->normal[2], plane->dist, maxdist);
for (planenum2 = 0, plane2 = planes;planenum2 < numplanes && tempnumpoints >= 3;planenum2++, plane2++)
{
if (planenum2 == planenum)
void RSurf_PrepareVerticesForBatch(qboolean generatenormals, qboolean generatetangents, int texturenumsurfaces, msurface_t **texturesurfacelist)
{
+ // if vertices are dynamic (animated models), generate them into the temporary rsurface_array_model* arrays and point rsurface_model* at them instead of the static data from the model itself
if (rsurface_generatedvertex)
{
if (rsurface_texture->textureflags & (Q3TEXTUREFLAG_AUTOSPRITE | Q3TEXTUREFLAG_AUTOSPRITE2))
Mod_BuildTextureVectorsFromNormals(0, rsurface_model->surfmesh.num_vertices, rsurface_model->surfmesh.num_triangles, rsurface_modelvertex3f, rsurface_model->surfmesh.data_texcoordtexture2f, rsurface_modelnormal3f, rsurface_model->surfmesh.data_element3i, rsurface_array_modelsvector3f, rsurface_array_modeltvector3f, r_smoothnormals_areaweighting.integer);
}
}
+ // if vertices are deformed (sprite flares and things in maps, possibly water waves, bulges and other deformations), generate them into rsurface_deform* arrays from whatever the rsurface_model* array pointers point to (may be static model data or generated data for an animated model)
if (rsurface_texture->textureflags & (Q3TEXTUREFLAG_AUTOSPRITE | Q3TEXTUREFLAG_AUTOSPRITE2))
{
int texturesurfaceindex;
Matrix4x4_Transform(&rsurface_entity->inversematrix, r_view.forward, forward);
Matrix4x4_Transform(&rsurface_entity->inversematrix, r_view.right, right);
Matrix4x4_Transform(&rsurface_entity->inversematrix, r_view.up, up);
- // make deformed versions of only the vertices used by the specified surfaces
+ // make deformed versions of only the model vertices used by the specified surfaces
for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
{
int i, j;
{
VectorClear(center);
for (i = 0;i < 4;i++)
- VectorAdd(center, (rsurface_vertex3f + 3 * surface->num_firstvertex) + (j+i) * 3, center);
+ VectorAdd(center, (rsurface_modelvertex3f + 3 * surface->num_firstvertex) + (j+i) * 3, center);
VectorScale(center, 0.25f, center);
if (rsurface_texture->textureflags & Q3TEXTUREFLAG_AUTOSPRITE2)
{
VectorSet(up, 0, 0, 1);
}
// FIXME: calculate vectors from triangle edges instead of using texture vectors as an easy way out?
- Matrix4x4_FromVectors(&matrix1, (rsurface_normal3f + 3 * surface->num_firstvertex) + j*3, (rsurface_svector3f + 3 * surface->num_firstvertex) + j*3, (rsurface_tvector3f + 3 * surface->num_firstvertex) + j*3, center);
+ Matrix4x4_FromVectors(&matrix1, (rsurface_modelnormal3f + 3 * surface->num_firstvertex) + j*3, (rsurface_modelsvector3f + 3 * surface->num_firstvertex) + j*3, (rsurface_modeltvector3f + 3 * surface->num_firstvertex) + j*3, center);
Matrix4x4_Invert_Simple(&imatrix1, &matrix1);
for (i = 0;i < 4;i++)
- Matrix4x4_Transform(&imatrix1, (rsurface_vertex3f + 3 * surface->num_firstvertex) + (j+i)*3, v[i]);
+ Matrix4x4_Transform(&imatrix1, (rsurface_modelvertex3f + 3 * surface->num_firstvertex) + (j+i)*3, v[i]);
for (i = 0;i < 4;i++)
VectorMAMAMAM(1, center, v[i][0], forward, v[i][1], right, v[i][2], up, rsurface_array_deformedvertex3f + (surface->num_firstvertex+i+j) * 3);
}
r_refdef.stats.entities_surfaces += texturenumsurfaces;
CHECKGLERROR
GL_DepthTest(!(rsurface_texture->currentmaterialflags & MATERIALFLAG_NODEPTHTEST));
- if ((rsurface_texture->textureflags & Q3TEXTUREFLAG_TWOSIDED) || (rsurface_entity->flags & RENDER_NOCULLFACE))
- {
- qglDisable(GL_CULL_FACE);CHECKGLERROR
- }
+ GL_CullFace(((rsurface_texture->textureflags & Q3TEXTUREFLAG_TWOSIDED) || (rsurface_entity->flags & RENDER_NOCULLFACE)) ? GL_NONE : GL_FRONT); // quake is backwards, this culls back faces
if (r_showsurfaces.integer)
R_DrawTextureSurfaceList_ShowSurfaces(texturenumsurfaces, texturesurfacelist);
else if (rsurface_texture->currentmaterialflags & MATERIALFLAG_SKY)
}
CHECKGLERROR
GL_LockArrays(0, 0);
- if ((rsurface_texture->textureflags & Q3TEXTUREFLAG_TWOSIDED) || (rsurface_entity->flags & RENDER_NOCULLFACE))
- {
- qglEnable(GL_CULL_FACE);CHECKGLERROR
- }
}
#define BATCHSIZE 256