]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
finally managed to fix the r_shadow_portallight bug (had to reverse portal handling...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 20 Sep 2003 07:34:52 +0000 (07:34 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 20 Sep 2003 07:34:52 +0000 (07:34 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3479 d7cf8633-e32d-0410-b094-e92efae38249

gl_rsurf.c
model_brush.c
portals.c
portals.h
r_shadow.c
todo
winding.c

index 7bc9d736b3115eee5c9c1302a966671ad9c75a33..38d17b1119f18e5ee762fe1696ee80d3a78129c6 100644 (file)
@@ -857,7 +857,7 @@ static void RSurfShader_Water_Callback(const void *calldata1, int calldata2)
                if (gl_textureshader && r_watershader.integer)
                {
                        GL_ActiveTexture (0);
-                       qglTexEnvi (GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_2D);       
+                       qglTexEnvi (GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_2D);
                        GL_ActiveTexture (1);
                        qglTexEnvi (GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_2D);
                        qglTexEnvi (GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_OFFSET_TEXTURE_2D_NV);
@@ -1549,7 +1549,7 @@ static void R_DrawPortal_Callback(const void *calldata1, int calldata2)
                         ((i & 0x0038) >> 3) * (1.0f / 7.0f) * r_colorscale,
                         ((i & 0x01C0) >> 6) * (1.0f / 7.0f) * r_colorscale,
                         0.125f);
-       if (PlaneDiff(r_origin, (&portal->plane)) > 0)
+       if (PlaneDiff(r_origin, (&portal->plane)) < 0)
        {
                for (i = portal->numpoints - 1, v = varray_vertex3f;i >= 0;i--, v += 3)
                        VectorCopy(portal->points[i].position, v);
index d6a220eabc12215bbf94a8ef803769854b23a87a..2c577105f03366f44b7394e414e6ac32b46f27a6 100644 (file)
@@ -2308,9 +2308,9 @@ static void Mod_Q1BSP_RecursiveNodePortals(mnode_t *node)
        // create the new portal by generating a polygon for the node plane,
        // and clipping it by all of the other portals(which came from nodes above this one)
        nodeportal = AllocPortal();
-       nodeportal->plane = *node->plane;
+       nodeportal->plane = *plane;
 
-       nodeportalwinding = Winding_NewFromPlane(node->plane->normal[0], node->plane->normal[1], node->plane->normal[2], node->plane->dist);
+       nodeportalwinding = Winding_NewFromPlane(nodeportal->plane.normal[0], nodeportal->plane.normal[1], nodeportal->plane.normal[2], nodeportal->plane.dist);
        side = 0;       // shut up compiler warning
        for (portal = (portal_t *)node->portals;portal;portal = portal->next[side])
        {
index ba7de15d6b59d475aadd7187f7ff33a34e266b77..725374b1544ef80dc23207496d0104bb8ea46751 100644 (file)
--- a/portals.c
+++ b/portals.c
@@ -323,7 +323,8 @@ typedef struct portalrecursioninfo_s
 {
        int exact;
        int numfrustumplanes;
-       float nradius;
+       vec3_t boxmins;
+       vec3_t boxmaxs;
        qbyte *surfacemark;
        qbyte *leafmark;
        model_t *model;
@@ -336,6 +337,7 @@ portalrecursioninfo_t;
 void Portal_RecursiveFlow_ExactMarkSurfaces(portalrecursioninfo_t *info, int *mark, int nummarksurfaces, int firstclipplane, int numclipplanes)
 {
        int i, j, *elements;
+       vec3_t trimins, trimaxs;
        msurface_t *surf;
        surfmesh_t *surfmesh;
        for (i = 0;i < nummarksurfaces;i++, mark++)
@@ -367,9 +369,18 @@ void Portal_RecursiveFlow_ExactMarkSurfaces(portalrecursioninfo_t *info, int *ma
                                                VectorCopy((surfmesh->vertex3f + elements[0] * 3), trianglepoints[0]);
                                                VectorCopy((surfmesh->vertex3f + elements[1] * 3), trianglepoints[1]);
                                                VectorCopy((surfmesh->vertex3f + elements[2] * 3), trianglepoints[2]);
-                                               if (PointInfrontOfTriangle(info->eye, trianglepoints[0], trianglepoints[1], trianglepoints[2])
-                                                && Portal_PortalThroughPortalPlanes(&portalplanes[firstclipplane], numclipplanes, trianglepoints[0], 3, &portaltemppoints2[0][0], 256) >= 3)
-                                                       break;
+                                               if (PointInfrontOfTriangle(info->eye, trianglepoints[0], trianglepoints[1], trianglepoints[2]))
+                                               {
+                                                       trimins[0] = min(trianglepoints[0][0], min(trianglepoints[1][0], trianglepoints[2][0]));
+                                                       trimaxs[0] = max(trianglepoints[0][0], max(trianglepoints[1][0], trianglepoints[2][0]));
+                                                       trimins[1] = min(trianglepoints[0][1], min(trianglepoints[1][1], trianglepoints[2][1]));
+                                                       trimaxs[1] = max(trianglepoints[0][1], max(trianglepoints[1][1], trianglepoints[2][1]));
+                                                       trimins[2] = min(trianglepoints[0][2], min(trianglepoints[1][2], trianglepoints[2][2]));
+                                                       trimaxs[2] = max(trianglepoints[0][2], max(trianglepoints[1][2], trianglepoints[2][2]));
+                                                       if (BoxesOverlap(trimins, trimaxs, info->boxmins, info->boxmaxs))
+                                                               if (Portal_PortalThroughPortalPlanes(&portalplanes[firstclipplane], numclipplanes, trianglepoints[0], 3, &portaltemppoints2[0][0], 256) >= 3)
+                                                                       break;
+                                               }
                                        }
                                        if (j < surfmesh->numtriangles)
                                                break;
@@ -412,9 +423,9 @@ void Portal_RecursiveFlow (portalrecursioninfo_t *info, mleaf_t *leaf, int first
        // follow portals into other leafs
        for (p = leaf->portals;p;p = p->next)
        {
-               // only flow through portals facing away from the viewer
+               // only flow through portals facing the viewer
                dist = PlaneDiff(info->eye, (&p->plane));
-               if (dist < 0 && dist >= info->nradius)
+               if (dist < 0 && BoxesOverlap(p->past->mins, p->past->maxs, info->boxmins, info->boxmaxs))
                {
                        newpoints = Portal_PortalThroughPortalPlanes(&portalplanes[firstclipplane], numclipplanes, (float *) p->points, p->numpoints, &portaltemppoints2[0][0], 256);
                        if (newpoints < 3)
@@ -433,8 +444,8 @@ void Portal_RecursiveFlow (portalrecursioninfo_t *info, mleaf_t *leaf, int first
                                newplanes = &portalplanes[firstclipplane + numclipplanes];
                                for (prev = newpoints - 1, i = 0;i < newpoints;prev = i, i++)
                                {
-                                       VectorSubtract(info->eye, portaltemppoints2[i], v1);
-                                       VectorSubtract(portaltemppoints2[prev], portaltemppoints2[i], v2);
+                                       VectorSubtract(portaltemppoints2[prev], portaltemppoints2[i], v1);
+                                       VectorSubtract(info->eye, portaltemppoints2[i], v2);
                                        CrossProduct(v1, v2, newplanes[i].normal);
                                        VectorNormalizeFast(newplanes[i].normal);
                                        newplanes[i].dist = DotProduct(info->eye, newplanes[i].normal);
@@ -470,7 +481,7 @@ void Portal_RecursiveFindLeafForFlow(portalrecursioninfo_t *info, mnode_t *node)
        }
 }
 
-void Portal_Visibility(model_t *model, const vec3_t eye, qbyte *leafmark, qbyte *surfacemark, const mplane_t *frustumplanes, int numfrustumplanes, int exact, float radius, float *updateleafsmins, float *updateleafsmaxs)
+void Portal_Visibility(model_t *model, const vec3_t eye, qbyte *leafmark, qbyte *surfacemark, const mplane_t *frustumplanes, int numfrustumplanes, int exact, const float *boxmins, const float *boxmaxs, float *updateleafsmins, float *updateleafsmaxs)
 {
        int i;
        portalrecursioninfo_t info;
@@ -500,7 +511,8 @@ void Portal_Visibility(model_t *model, const vec3_t eye, qbyte *leafmark, qbyte
        ranoutofportalplanes = false;
        ranoutofportals = false;
 
-       info.nradius = -radius;
+       VectorCopy(boxmins, info.boxmins);
+       VectorCopy(boxmaxs, info.boxmaxs);
        info.exact = exact;
        info.surfacemark = surfacemark;
        info.leafmark = leafmark;
index 928447324389b6251a388488d2f555b45914072f..6e96ce01807b4645e24e7b4c993975f9b3d4877a 100644 (file)
--- a/portals.h
+++ b/portals.h
@@ -4,7 +4,7 @@
 
 int Portal_CheckPolygon(model_t *model, vec3_t eye, float *polypoints, int numpoints);
 int Portal_CheckBox(model_t *model, vec3_t eye, vec3_t a, vec3_t b);
-void Portal_Visibility(model_t *model, const vec3_t eye, qbyte *leafmark, qbyte *surfacemark, const mplane_t *frustumplanes, int numfrustumplanes, int exact, float radius, float *updateleafsmins, float *updateleafsmaxs);
+void Portal_Visibility(model_t *model, const vec3_t eye, qbyte *leafmark, qbyte *surfacemark, const mplane_t *frustumplanes, int numfrustumplanes, int exact, const float *boxmins, const float *boxmaxs, float *updateleafsmins, float *updateleafsmaxs);
 
 #endif
 
index 160d4cca8f6fbc9ae0d96ba03b5db3fe1276f210..453d0a497c4dee7b1398e7fe94929460a4c426db 100644 (file)
@@ -1760,7 +1760,7 @@ void R_Shadow_NewWorldLight(vec3_t origin, float radius, vec3_t color, int style
                        //byteleafpvs = Mem_Alloc(tempmempool, cl.worldmodel->brushq1.numleafs);
                        bytesurfacepvs = Mem_Alloc(tempmempool, cl.worldmodel->brushq1.numsurfaces);
 
-                       Portal_Visibility(cl.worldmodel, e->origin, NULL/*byteleafpvs*/, bytesurfacepvs, NULL, 0, true, RadiusFromBoundsAndOrigin(e->mins, e->maxs, e->origin), e->mins, e->maxs);
+                       Portal_Visibility(cl.worldmodel, e->origin, NULL/*byteleafpvs*/, bytesurfacepvs, NULL, 0, true, mins, maxs, e->mins, e->maxs);
 
                        /*
                        for (i = 0, leaf = cl.worldmodel->brushq1.leafs;i < cl.worldmodel->brushq1.numleafs;i++, leaf++)
diff --git a/todo b/todo
index 0eeeef5b527a6475664dd123104a1524abc2d5fa..601e4d1e4a6dc129e64ca6b9190187c071221ce7 100644 (file)
--- a/todo
+++ b/todo
@@ -12,6 +12,8 @@
 -n darkplaces: server is starting before the "port" cvar is set by commandline and scripts? (yummyluv)
 -n darkplaces: typing ip in join game menu should show 'trying' and 'no response' after a while, or 'no network' if networking is not initialized (yummyluv)
 -n dpmod: make grapple off-hand (joe hill)
+0 darkplaces: make a getattachmentvectors qc builtin (Supajoe)
+0 darkplaces: add _reflect textures which filter use of skybox as a cubemap reflection (FrikaC)
 0 darkplaces: ability to disable fopen builtin access to read /, read data/, write data/, or disable fopen builtin entirely
 0 darkplaces: add DP_GFX_QUAKE3MODELTAGS, DP_GFX_SKINFILES, and any other new extensions to the wiki
 0 darkplaces: add DP_LITSUPPORT extension and document it
index 441bc73349c337add126f2a466ce7f67f082a3fe..24409026f64b3493613c852de1af6dd0aa1214ed 100644 (file)
--- a/winding.c
+++ b/winding.c
@@ -94,6 +94,16 @@ winding_t *Winding_NewFromPlane(double normalx, double normaly, double normalz,
        VectorSubtract(org, vright, w->points[3]);
        VectorSubtract(w->points[3], vup, w->points[3]);
 
+#if 0
+       {
+               double n[3];
+               TriangleNormal(w->points[0], w->points[1], w->points[2], n);
+               VectorNormalize(n);
+               if (fabs(DotProduct(n, normal) - 1) > 0.01f)
+                       Con_Printf("%.0f %.0f %.0f (%.0f %.0f %.0f, %.0f %.0f %.0f) != %.0f %.0f %.0f (%.0f %.0f %.0f, %.0f %.0f %.0f, %.0f %.0f %.0f, %.0f %.0f %.0f)\n", normal[0], normal[1], normal[2], vright[0], vright[1], vright[2], vup[0], vup[1], vup[2], n[0], n[1], n[2], w->points[0][0], w->points[0][1], w->points[0][2], w->points[1][0], w->points[1][1], w->points[1][2], w->points[2][0], w->points[2][1], w->points[2][2], w->points[3][0], w->points[3][1], w->points[3][2]);
+       }
+#endif
+
        w->numpoints = 4;
 
        return w;