[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz ./TODO gfx/libcoords/Coords.cxx gfx/libcoor...
From: |
Asko Soukka |
Subject: |
[Gzz-commits] gzz ./TODO gfx/libcoords/Coords.cxx gfx/libcoor... |
Date: |
Tue, 29 Oct 2002 05:27:03 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Asko Soukka <address@hidden> 02/10/29 05:27:03
Modified files:
. : TODO
gfx/libcoords : Coords.cxx Coords.hxx
gzz/gfx/gl : GLVobCoorder.java
Added files:
gfx/demo/opengl: culltest.py
Log message:
CullingCoordsys
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/TODO.diff?tr1=1.333&tr2=1.334&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcoords/Coords.cxx.diff?tr1=1.42&tr2=1.43&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcoords/Coords.hxx.diff?tr1=1.18&tr2=1.19&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/opengl/culltest.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/GLVobCoorder.java.diff?tr1=1.45&tr2=1.46&r1=text&r2=text
Patches:
Index: gzz/TODO
diff -u gzz/TODO:1.333 gzz/TODO:1.334
--- gzz/TODO:1.333 Tue Oct 29 02:30:58 2002
+++ gzz/TODO Tue Oct 29 05:27:03 2002
@@ -102,12 +102,15 @@
- porting: make sure all demos etc. work with plain mesa
humppake:
- CullinCoordsys
- - tests for distorted coordsystems
- another version with distinct test and parent coordsystems
eg. cull(parent, test, clip)
- learn to use UMLdoc.
- more about PEG1018 - generalizing VobVanishingClient
+ new PEG from bubbleview, with some sketches
+ - Try to fix: JVM crashes when PaperQuads dicing >= 7.425...?
+ Unexpected Signal: 11 occurred at PC=0x50C65F4D
+ Function=_ZN11Renderables9PaperQuad10render
+ ImplIN6Coords8CoordSysEEEvRT_S5_+0x807
- rethink interfaces between PlainVanishing and VobScene
- new PEG, UML (learn to generate UML)
- correct implementation of LollipopCellVobFactor needs
Index: gzz/gfx/libcoords/Coords.cxx
diff -u gzz/gfx/libcoords/Coords.cxx:1.42 gzz/gfx/libcoords/Coords.cxx:1.43
--- gzz/gfx/libcoords/Coords.cxx:1.42 Tue Oct 22 08:01:20 2002
+++ gzz/gfx/libcoords/Coords.cxx Tue Oct 29 05:27:03 2002
@@ -1,10 +1,12 @@
#include "libutil/Debug.hxx"
#include "libfisheye/Fisheye.hxx"
#include "Coords.hxx"
+#include <GL/gl.h>
namespace Coords {
DBGVAR(dbg, "Coords.general");
DBGVAR(dbg_buoy, "Coords.buoy");
+ DBGVAR(dbg_cull, "Coords.culling");
// The (STL-like) concept of transform:
// enum { NParams = n };
@@ -648,7 +650,11 @@
* @return true if the given rectangles intersect
*/
bool parallelRectIntersect(ZPt &p1, ZPt &p2, ZPt &p3, ZPt &p4) {
- return (p2.x > p3.x) && (p4.x > p1.x) && (p2.y > p3.y) && (p4.y >
p1.y);
+ DBG(dbg_cull) << "called CullingCoordsys::parallellRectIntersect\n";
+ DBG(dbg_cull) << "(" << p1.x << "," << p1.y << "), (" << p2.x << ","
<< p2.y << ") <=> ("
+ << p3.x << "," << p3.y << "), (" << p4.x << "," << p4.y
<< ")\n";
+
+ return (p2.x > p3.x) && (p4.x > p1.x) && (p2.y > p3.y) && (p4.y >
p1.y);
}
/** Finds the bounding box of coordsys' unit square after
* transformation. Assumes linear coordsys and transforms only
@@ -658,10 +664,11 @@
* @param p2 "upper right corner"
*/
void findBoundingBox(CoordSys *cs, ZPt &p1, ZPt &p2) {
+ DBG(dbg_cull) << "called CullingCoordsys::findBoundingBox\n";
int i, j;
float x1, y1, x2, y2;
- for (i=0; i<=1; i++) {
- for (j=0; j<=1; j++) {
+ for (i=0; i<=1; i+=1) {
+ for (j=0; j<=1; j+=1) {
if (i==0 && j==0) {
/** Initializing. */
ZPt tmpPt = cs->transform(ZPt(i, j, 0));
@@ -688,16 +695,29 @@
* @param p2 "upper right corner"
*/
void findDistortedBoundingBox(CoordSys *cs, ZPt &p1, ZPt &p2) {
- double i;
+ DBG(dbg_cull) << "called CullingCoordsys::findDistortedBoundingBox\n";
+ double i, step_x, step_y;
float x1, y1, x2, y2;
+ int check_dist;
+
/** Initializing. */
+ check_dist = 30; // XXX
+
ZPt o = cs->transform(ZPt(0, 0, 0));
- x1 = o.x; y1 = o.y;
- x2 = o.x; y2 = o.y;
-
+ ZPt u = cs->transform(ZPt(1, 1, 0));
+
+ if (fabs(o.x - u.x) / check_dist > 1) step_x = 1/(fabs(o.x - u.x) /
check_dist);
+ else step_x = 1;
+ if (fabs(o.y - u.y) / check_dist > 1) step_y = 1/(fabs(o.y - u.y) /
check_dist);
+ else step_y = 1;
+ DBG(dbg_cull) << "Step_X: " << step_x << " Step_Y: " << step_y <<
"\n";
+
+ x1 = u.x; y1 = u.y;
+ x2 = u.x; y2 = u.y;
+
/** Sweeps the unit square's vertices. */
/** Vertice (0,0) -> (1,0). */
- for (i=0.1; i <= 1.0; i+=0.1) {
+ for (i=0; i < 1.0; i+=step_x) {
ZPt tmpPt = cs->transform(ZPt(i, 0, 0));
if (tmpPt.x < x1) x1 = tmpPt.x;
else if (tmpPt.x > x2) x2 = tmpPt.x;
@@ -706,7 +726,7 @@
}
/** Vertice (0,0) -> (0,1). */
- for (i=0.1; i <= 1.0; i+=0.1) {
+ for (i=step_y; i < 1.0; i+=step_y) {
ZPt tmpPt = cs->transform(ZPt(0, i, 0));
if (tmpPt.x < x1) x1 = tmpPt.x;
else if (tmpPt.x > x2) x2 = tmpPt.x;
@@ -715,7 +735,7 @@
}
/** Vertice (0,1) -> (1,1) */
- for (i=0.1; i >= 1.0; i+=0.1) {
+ for (i=0; i < 1.0; i+=step_x) {
ZPt tmpPt = cs->transform(ZPt(i, 1, 0));
if (tmpPt.x < x1) x1 = tmpPt.x;
else if (tmpPt.x > x2) x2 = tmpPt.x;
@@ -724,7 +744,7 @@
}
/** Vertice (1,0) -> (1,1) */
- for (i=0.1; i < 1.0; i+=0.1) {
+ for (i=0; i < 1.0; i+=step_y) {
ZPt tmpPt = cs->transform(ZPt(1, i, 0));
if (tmpPt.x < x1) x1 = tmpPt.x;
else if (tmpPt.x > x2) x2 = tmpPt.x;
@@ -740,49 +760,55 @@
CullingCoordSys(CoordSys *parent, CoordSys *clip)
: CoordSys(parent), clipSuper(clip) { }
virtual void setSuper(CoordSys **super) {
+ DBG(dbg_cull) << "called CullingCoordsys::setSuper\n";
CoordSys::setSuper(super);
this->clipSuper = super[1];
}
enum { NParams = 0, NPrevious = 2, NParents = 2 };
virtual void setParams(float *params) { }
virtual CoordSys *createInverse() {
- return new ConcatCoordSys(super->getInverse(),
clipSuper->getInverse());
+ DBG(dbg_cull) << "called CullingCoordsys::createInverse\n";
+ return super->getInverse();
}
virtual void vertex(const ZPt &p) const {
+ DBG(dbg_cull) << "called CullingCoordsys::vertex\n";
super->vertex(p);
- clipSuper->vertex(p);
}
virtual ZPt transform(const ZPt &p) const {
- return super->transform(p);
+ DBG(dbg_cull) << "called CullingCoordsys::transform\n";
+ return super->transform(p);
}
virtual float nonlinearity(const ZPt &p, float radius) {
+ DBG(dbg_cull) << "called CullingCoordsys::nonlinearity\n";
float n1 = super->nonlinearity(p, radius);
float n2 = clipSuper->nonlinearity(super->transform(p), radius);
return (n1 > n2 ? n1 : n2);
}
virtual bool canPerformGL() {
- return super->canPerformGL() && clipSuper->canPerformGL();
+ DBG(dbg_cull) << "called CullingCoordsys::canPerformGL\n";
+ return super->canPerformGL();
}
virtual bool performGL() {
- if(!super->performGL()) return false;
- return clipSuper->performGL();
+ DBG(dbg_cull) << "called CullingCoordsys::performGL\n";
+ return super->performGL();
}
/** Cullin coordsys' shouldBeDrawn() returns false if and only if
* it's sure that its parents' unit squares do not intersect.
*/
virtual bool shouldBeDrawn() {
+ DBG(dbg_cull) << "called CullingCoordsys::shouldBeDrawn\n";
/** Lower left and upper right points of bounding boxes for
* parents' unit squares (after transformation).
*/
ZPt p1, p2, p3, p4;
if (super->nonlinearity(ZPt(0.5, 0.5, 0), 1/sqrt(2)) != 0)
- findDistortedBoundingBox(super, p1, p2);
+ findDistortedBoundingBox(super, p1, p2);
else findBoundingBox(super, p1, p2);
if (clipSuper->nonlinearity(ZPt(0.5, 0.5, 0), 1/sqrt(2)) != 0)
- findDistortedBoundingBox(clipSuper, p3, p4);
- else findDistortedBoundingBox(clipSuper, p3, p4);
+ findDistortedBoundingBox(clipSuper, p3, p4);
+ else findBoundingBox(clipSuper, p3, p4);
return (parallelRectIntersect(p1, p2, p3, p4));
}
@@ -822,7 +848,10 @@
extern SomeFactory* facs[];
- /* This mustn't change without changing GLVobCoorder2 as well.
+ /** Factories for different coordsys types.
+ * These factories are currently used form CoordSet::create and
+ * they return a pointer to new coordsys created with "new".
+ * Array facs[] mustn't change without changing GLVobCoorder as well.
*/
SomeFactory* facs[] = {
0,
@@ -836,6 +865,7 @@
new DerTransFactory<BuoyOnCircleCoords>(), // 7
new NoTransFactory<ConcatCoordSys>(), // 8
new DerTransFactory<NadirOriginCoords>(), // 9
+ new NoTransFactory<CullingCoordSys>(), // 10
0
};
@@ -998,10 +1028,19 @@
}
DBG(dbg) << "CS assigned "<<tp<<"\n";
+ /** Finally, creates a new coordsys of demanded type and sets
its parents and
+ * params. If the initialized coordsys (according to its
initialized attributes)
+ * decides not to be drawn, it will be deleted and replaced
with the NULL pointer.
+ */
CoordSys *c = create(tp);
cs[i] = c;
c->setSuper(prev);
c->setParams(&(params[0]) + parind);
+ if (!cs[i]->shouldBeDrawn()) {
+ DBG(dbg) << "CS should not be drawn... freeing it with
delete.\n";
+ delete cs[i]; // Must be deleted, because created with "new"
in factories.
+ cs[i] = NULL;
+ }
}
nextInd:;
}
Index: gzz/gfx/libcoords/Coords.hxx
diff -u gzz/gfx/libcoords/Coords.hxx:1.18 gzz/gfx/libcoords/Coords.hxx:1.19
--- gzz/gfx/libcoords/Coords.hxx:1.18 Wed Oct 23 02:13:04 2002
+++ gzz/gfx/libcoords/Coords.hxx Tue Oct 29 05:27:03 2002
@@ -172,7 +172,7 @@
* systems.
* @param inds1 Array of length ninds,
* containing descriptions of coordinate systems.
- * 1) type code
+ * 1) type code, see Coords.cxx for current codes
* 2) parent and determining coordinate systems,
* as many as the type code requires (usually 1 or 2)
* 3) an index to the points1 array, where the parameters
Index: gzz/gzz/gfx/gl/GLVobCoorder.java
diff -u gzz/gzz/gfx/gl/GLVobCoorder.java:1.45
gzz/gzz/gfx/gl/GLVobCoorder.java:1.46
--- gzz/gzz/gfx/gl/GLVobCoorder.java:1.45 Mon Oct 28 13:37:27 2002
+++ gzz/gzz/gfx/gl/GLVobCoorder.java Tue Oct 29 05:27:03 2002
@@ -29,7 +29,7 @@
import gzz.client.gl.*;
public class GLVobCoorder extends AffineVobCoorder {
-public static final String rcsid = "$Id: GLVobCoorder.java,v 1.45 2002/10/28
18:37:27 tjl Exp $";
+public static final String rcsid = "$Id: GLVobCoorder.java,v 1.46 2002/10/29
10:27:03 humppake Exp $";
public static boolean dbg = false;
private static void pa(String s) { System.err.println(s); }
@@ -225,7 +225,7 @@
public int concat(int parent, int child) {
int paramInd = nfloats;
- inds[ninds+0] = 8;
+ inds[ninds+0] = 8; // concat
inds[ninds+1] = parent;
inds[ninds+2] = child;
inds[ninds+3] = paramInd;
@@ -235,6 +235,18 @@
return was;
}
+ public int cull(int parent, int clip) {
+ int paramInd = nfloats;
+ inds[ninds+0] = 10; // culling
+ inds[ninds+1] = parent;
+ inds[ninds+2] = clip;
+ inds[ninds+3] = paramInd;
+
+ int was = ninds;
+ ninds += 4;
+ return was;
+ }
+
public void dump() {
pa("GLVobCoorder: ");
for(int i=0; i<ninds; i++) {
@@ -308,3 +320,5 @@
}
+
+