29 #include "../idlib/precompiled.h"
73 float windowX, windowY;
110 float *regs =(
float *)_alloca( size );
122 if ( alpha <= 1.0
f ) {
138 d = forward.
Distance( (*w)[i].ToVec3() );
190 for ( check = ps; check; check = check->
next ) {
191 if ( check->
p == p ) {
247 for ( i = 0; i < addPlanes; i++ ) {
253 v1 = origin - w[
i].ToVec3();
254 v2 = origin - w[
j].ToVec3();
292 for ( i = 0 ; i < numPlanes ; i++ ) {
355 for ( check = ps; check; check = check->
next ) {
356 firstPortalStack = check;
357 if ( check->
p == p ) {
410 for ( i = 0; i < addPlanes; i++ ) {
455 memset( &ps, 0,
sizeof( ps ) );
458 for ( i = 0 ; i < 6 ; i++ ) {
484 for ( a = areas;
a; a = a->
next ) {
508 if ( newBounds[0][0] > newBounds[1][0] || newBounds[0][1] > newBounds[1][1] || newBounds[0][2] > newBounds[1][2] ) {
541 for ( a = areas;
a; a = a->
next ) {
657 for ( i = 0; i < 6; i++ ) {
699 for ( j = 0; j < tri->
numVerts; j++ ) {
796 for ( portal = area->
portals ; portal ; portal = portal->
next ) {
868 static int lastPrintedAreaNum;
875 for ( i = 0 ; i < 5 ; i++ ) {
942 if ( !(
p->doublePortal->blockingBits & (1<<portalAttributeIndex) ) ) {
955 if ( areaNum1 == -1 || areaNum2 == -1 ) {
959 common->
Error(
"idRenderWorldLocal::AreAreasConnected: bad parms: %i, %i", areaNum1, areaNum2 );
964 int intConnection = (
int)connection;
966 while ( intConnection > 1 ) {
970 if ( attribute >= NUM_PORTAL_ATTRIBUTES || ( 1 << attribute ) != (
int)connection ) {
971 common->
Error(
"idRenderWorldLocal::AreasAreConnected: bad connection number: %i\n", (
int)connection );
991 common->
Error(
"SetPortalState: bad portal number %i", portal );
994 if ( old == blockTypes ) {
1001 for (
int i = 0 ;
i < NUM_PORTAL_ATTRIBUTES ;
i++ ) {
1002 if ( ( old ^ blockTypes ) & ( 1 <<
i ) ) {
1022 if ( portal == 0 ) {
1027 common->
Error(
"GetPortalState: bad portal number %i", portal );
const idMaterial * lightShader
void SetPortalState(qhandle_t portal, int blockingBits)
const idVec3 & GetOrigin(void) const
const idVec3 & Normal(void) const
void FlowViewThroughPortals(const idVec3 origin, int numPlanes, const idPlane *planes)
areaReference_t lightRefs
void FloodViewThroughArea_r(const idVec3 origin, int areaNum, const struct portalStack_s *ps)
idRenderLightLocal * fogLight
idBounds & IntersectSelf(const idBounds &a)
float Distance(const idVec3 &v) const
void AddAreaEntityRefs(int areaNum, const struct portalStack_s *ps)
void FlowLightThroughPortals(idRenderLightLocal *light)
void FindViewLightsAndEntities(void)
bool CullLightByPortals(const idRenderLightLocal *light, const struct portalStack_s *ps)
void Union(const idScreenRect &rect)
struct portalStack_s portalStack_t
GLclampf GLclampf GLclampf alpha
void AddAreaLightRefs(int areaNum, const struct portalStack_s *ps)
idVec3 Cross(const idVec3 &a) const
const int MAX_PORTAL_PLANES
viewLight_t * R_SetLightDefViewLight(idRenderLightLocal *light)
areaNumRef_t * FloodFrustumAreas(const idFrustum &frustum, areaNumRef_t *areas)
void EvaluateRegisters(float *regs, const float entityParms[MAX_ENTITY_SHADER_PARMS], const struct viewDef_s *view, idSoundEmitter *soundEmitter=NULL) const
bool ProjectionBounds(const idBounds &bounds, idBounds &projectionBounds) const
idCVar r_skipSuppress("r_skipSuppress","0", CVAR_RENDERER|CVAR_BOOL,"ignore the per-view suppressions")
bool R_CullLocalBox(const idBounds &bounds, const float modelMatrix[16], int numPlanes, const idPlane *planes)
float GetNearDistance(void) const
float shaderParms[MAX_ENTITY_SHADER_PARMS]
bool LightCastsShadows() const
qhandle_t FindPortal(const idBounds &b) const
struct viewLight_s * viewLights
int NumPortals(void) const
doublePortal_t * doublePortals
bool AddPoint(const idVec3 &v)
GLfloat GLfloat GLfloat v2
struct areaNumRef_s * next
virtual int WriteInt(const int value)
void AddPoint(float x, float y)
int GetNumPoints(void) const
const float DEFAULT_FOG_DISTANCE
GLubyte GLubyte GLubyte GLubyte w
const shaderStage_t * GetStage(const int index) const
viewEntity_t identitySpace
int PlaneSide(const idPlane &plane, const float epsilon=ON_EPSILON) const
idCVar r_useLightCulling("r_useLightCulling","3", CVAR_RENDERER|CVAR_INTEGER,"0 = none, 1 = box, 2 = exact clip of polyhedron faces, 3 = also areas", 0, 3, idCmdSystem::ArgCompletion_Integer< 0, 3 >)
int GetInteger(void) const
areaNumRef_t * FloodFrustumAreas_r(const idFrustum &frustum, const int areaNum, const idBounds &bounds, areaNumRef_t *areas)
const struct portalStack_s * next
void Intersect(const idScreenRect &rect)
idCVar r_usePortals("r_usePortals","1", CVAR_RENDERER|CVAR_BOOL," 1 = use portals to perform area culling, otherwise draw everything")
bool PortalIsFoggedOut(const portal_t *p)
bool CullEntityByPortals(const idRenderEntityLocal *entity, const struct portalStack_s *ps)
idCVar r_singleEntity("r_singleEntity","-1", CVAR_RENDERER|CVAR_INTEGER,"suppress all but one entity")
void R_GlobalToNormalizedDeviceCoordinates(const idVec3 &global, idVec3 &ndc)
bool AreasAreConnected(int areaNum1, int areaNum2, portalConnection_t connection)
GLubyte GLubyte GLubyte a
virtual void Printf(const char *fmt,...) id_attribute((format(printf
idCVar r_singleLight("r_singleLight","-1", CVAR_RENDERER|CVAR_INTEGER,"suppress all but one light")
struct portal_s * portals[2]
float Normalize(bool fixDegenerate=true)
idBlockAlloc< areaNumRef_t, 1024 > areaNumRefAllocator
int Side(const idVec3 &v, const float epsilon=0.0f) const
srfTriangles_t * frustumTris
void FloodConnectedAreas(portalArea_t *area, int portalAttributeIndex)
GLdouble GLdouble GLdouble r
const int GetNumRegisters() const
struct viewEntity_s * viewEntitys
idPlane portalPlanes[MAX_PORTAL_PLANES+1]
int connectedAreaNum[NUM_PORTAL_ATTRIBUTES]
void R_FreeEntityDefFadedDecals(idRenderEntityLocal *def, int time)
bool IntersectsBounds(const idBounds &a) const
portalArea_t * portalAreas
void FloodLightThroughArea_r(idRenderLightLocal *light, int areaNum, const struct portalStack_s *ps)
virtual int PointInArea(const idVec3 &point) const
void BuildConnectedAreas_r(int areaNum)
float modelViewMatrix[16]
idWinding * frustumWindings[6]
int suppressSurfaceInViewID
idRenderEntityLocal * entity
int GetPortalState(qhandle_t portal)
areaReference_t entityRefs
void * R_FrameAlloc(int bytes)
idScreenRect ScreenRectFromWinding(const idWinding *w, viewEntity_t *space)
void AddLightRefToArea(idRenderLightLocal *light, portalArea_t *area)
viewEntity_t * R_SetEntityDefViewEntity(idRenderEntityLocal *def)
struct areaReference_s * areaNext
idRenderLightLocal * light
idVec3 initialViewAreaOrigin
void BuildConnectedAreas(void)
struct doublePortal_s * doublePortal
void R_LocalPointToGlobal(const float modelMatrix[16], const idVec3 &in, idVec3 &out)
idSoundEmitter * referenceSound
virtual void Error(const char *fmt,...) id_attribute((format(printf
float GetFarDistance(void) const
void AddAreaRefs(int areaNum, const struct portalStack_s *ps)
idScreenRect * areaScreenRect
bool ClipInPlace(const idPlane &plane, const float epsilon=ON_EPSILON, const bool keepOn=false)
idCVar r_singleArea("r_singleArea","0", CVAR_RENDERER|CVAR_BOOL,"only draw the portal area the view is actually in")
idCVar r_useEntityCulling("r_useEntityCulling","1", CVAR_RENDERER|CVAR_BOOL,"0 = none, 1 = box")
void FitThroughPoint(const idVec3 &p)