summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mikos <metastability@opencompositing.org>2008-01-27 12:27:02 +1030
committerDavid Mikos <metastability@opencompositing.org>2008-01-27 12:27:02 +1030
commitb6f81794236e48cf3b1abff8fa93f1771f37eb6d (patch)
treeef253c97622c9a260e800082c7df18e3c171d537
parent384587f960f8a6a70394286acb8ad655e877b144 (diff)
downloadrubik-b6f81794236e48cf3b1abff8fa93f1771f37eb6d.tar.gz
rubik-b6f81794236e48cf3b1abff8fa93f1771f37eb6d.tar.bz2
Possibly work better with multiple monitors. Default settings change.
-rw-r--r--rubik-internal.h21
-rw-r--r--rubik.c43
-rw-r--r--rubik.xml.in2
-rw-r--r--util.c9
4 files changed, 31 insertions, 44 deletions
diff --git a/rubik-internal.h b/rubik-internal.h
index 8005657..6758d36 100644
--- a/rubik-internal.h
+++ b/rubik-internal.h
@@ -138,14 +138,16 @@ typedef struct _RubikScreen
faceRec *faces;
- int numDesktopWindows;
+ int hsize;
+ float distance; //perpendicular distance to wall from centre
+ float radius; //radius on which the hSize points lie
+
+ float speedFactor; // multiply rotation speed by this value
+
}
RubikScreen;
typedef struct _RubikWindow{
- float x, y, z;
- Bool rotated;
-
DrawWindowGeometryProc drawWindowGeometry;
}
RubikWindow;
@@ -153,7 +155,7 @@ RubikWindow;
void rubikGetRotation( CompScreen *s, float *x, float *v );
-void initializeWorldVariables(int, float);
+void initializeWorldVariables(CompScreen *s);
void initFaces( CompScreen *s);
void updateSpeedFactor(float);
@@ -163,26 +165,17 @@ void updateSpeedFactor(float);
float randf(float); //random float
float minimum(float,float); //my compiler at home didn't have min or fminf!
float maximum(float,float); //nor did it have max or fmaxf!
-float symmDistr(void); //symmetric distribution
void setColor(float *, float, float, float, float, float, float);
void setSpecifiedColor (float *, int);
void rotateClockwise (squareRec * square);
void rotateAnticlockwise (squareRec * square);
-//maybe define a struct for these values
-float speedFactor; // global variable (fish/crab speeds multiplied by this value)
-float radius;//radius on which the hSize points lie
-float distance;//perpendicular distance to wall from centre
-
//All calculations that matter with angles are done clockwise from top.
//I think of it as x=radius, y=0 being the top (towards 1st desktop from above view)
//and the z coordinate as height.
-int hSize; // horizontal desktop size
-float q; // equal to float version of hSize (replace with hSizef some time)
-
int vStrips;
int currentVStrip;
diff --git a/rubik.c b/rubik.c
index 12fb455..6b0e5ce 100644
--- a/rubik.c
+++ b/rubik.c
@@ -49,7 +49,6 @@ initRubik (CompScreen *s)
{
RUBIK_SCREEN (s);
- CUBE_SCREEN (s);
rs->tempTransform = malloc (sizeof(CompTransform));
vStrips = rubikGetNumberStrips(s);
@@ -83,10 +82,8 @@ initRubik (CompScreen *s)
rotationAxis = NRAND(1);
rs->w = NULL;
- rs->numDesktopWindows = 0;
- speedFactor = rubikGetSpeedFactor(s);
- initializeWorldVariables(s->hsize, cs->distance);
+ initializeWorldVariables(s);
rs->faces = malloc(6*sizeof(faceRec));
@@ -109,14 +106,17 @@ initRubik (CompScreen *s)
}
void
-initializeWorldVariables(int hs, float perpDistCentreToWall)
-{ //precalculate some values
+initializeWorldVariables(CompScreen *s)
+{
+ RUBIK_SCREEN (s);
+ CUBE_SCREEN (s);
+
+ rs->speedFactor = rubikGetSpeedFactor(s);
- hSize = hs;
- q = (float) hSize;
+ rs->hsize = s->hsize * cs->nOutput;
- distance = perpDistCentreToWall;
- radius = perpDistCentreToWall/sinf(PI*(0.5-1/q));
+ rs->distance = cs->distance;
+ rs->radius = cs->distance/sinf(PI*(0.5f-1.0f/rs->hsize));
}
void
@@ -201,7 +201,8 @@ rubikSpeedFactorOptionChange (CompScreen *s,
CompOption *opt,
RubikScreenOptions num)
{
- speedFactor = rubikGetSpeedFactor(s);
+ RUBIK_SCREEN (s);
+ rs->speedFactor = rubikGetSpeedFactor(s);
}
static void
@@ -229,7 +230,7 @@ static void rubikPaintInside (CompScreen *s,
RUBIK_SCREEN (s);
CUBE_SCREEN (s);
- if (hSize!=s->hsize) updateRubik (s);
+ if (rs->hsize!=s->hsize) updateRubik (s);
/*static const float mat_shininess[] = { 60.0 };
@@ -404,7 +405,7 @@ static void rubikPaintInside (CompScreen *s,
else if (!rubikGetDesktopCaps(s) && square->side>=4)
continue;
else {
- //float winX = WIN_REAL_X(w) + WIN_REAL_W(w)/2.0+((screen->x+screenCounter-1)%hSize)*w->screen->width;
+ //float winX = WIN_REAL_X(w) + WIN_REAL_W(w)/2.0+((screen->x+screenCounter-1)%rs->hsize)*w->screen->width;
//float screenW = w->screen->width;
//printf ("%i, %i\n", ((int) (winX/screenW)), w->screen->x);
@@ -725,13 +726,13 @@ rubikPreparePaintScreen (CompScreen *s,
//rotationAxis=2; //TESTING
//currentStripDirection=-1; //TESTING
- if (hSize!=4) rs->initiated = FALSE;
+ if (rs->hsize!=4) rs->initiated = FALSE;
int i;
if (rs->initiated) {
if (rubikGetRotateAllAxes(s)) {
i= currentHStrip;
- float increment = speedFactor;
+ float increment = rs->speedFactor;
rs->psi[i] += currentStripDirection*increment;
currentStripCounter +=increment;
@@ -902,7 +903,7 @@ rubikPreparePaintScreen (CompScreen *s,
}
else {
i= currentVStrip;
- float increment = 2*speedFactor;
+ float increment = 2*rs->speedFactor;
rs->th[i] += currentStripDirection*increment;
currentStripCounter +=increment;
@@ -1178,7 +1179,7 @@ static Bool RubikPaintWindow(CompWindow *w, const WindowPaintAttrib *attrib,
RUBIK_SCREEN(w->screen);
CUBE_SCREEN (w->screen);
- RUBIK_WINDOW(w);
+ //RUBIK_WINDOW(w);
int i;
@@ -1252,7 +1253,7 @@ static Bool RubikPaintWindow(CompWindow *w, const WindowPaintAttrib *attrib,
matrixTranslate(&wTransform,
(WIN_REAL_X(w) + WIN_REAL_W(w)/2.0),
(WIN_REAL_Y(w) + WIN_REAL_H(w)/2.0),
- -distance*w->screen->width);
+ -rs->distance*w->screen->width);
//matrixRotate(&wTransform, rs->psi, 0.0, 0.0, 1.0);
@@ -1264,7 +1265,7 @@ static Bool RubikPaintWindow(CompWindow *w, const WindowPaintAttrib *attrib,
matrixTranslate(&wTransform,
-(WIN_REAL_X(w) + WIN_REAL_W(w)/2.0),
-(WIN_REAL_Y(w) + WIN_REAL_H(w)/2.0),
- distance*w->screen->width);
+ rs->distance*w->screen->width);
matrixTranslate(&wTransform, 0, 0, 0.005*w->activeNum);
@@ -1331,8 +1332,6 @@ static Bool RubikPaintWindow(CompWindow *w, const WindowPaintAttrib *attrib,
}
}
else {
- rw->z = distance;
-
if (!rs->initiated) {
int i;
for (i=0; i<vStrips; i++) {
@@ -1509,8 +1508,6 @@ rubikInitWindow(CompPlugin *p, CompWindow *w){
if (!rw)
return FALSE;
- rw->rotated = FALSE;
-
w->base.privates[rs->windowPrivateIndex].ptr = rw;
//WRAP (rw, w, drawWindowGeometry, RubikDrawWindowGeometry);
diff --git a/rubik.xml.in b/rubik.xml.in
index 98cba1b..6bf7c07 100644
--- a/rubik.xml.in
+++ b/rubik.xml.in
@@ -42,7 +42,7 @@
<option name="rotate_all_axes" type="bool">
<short>Rotate around all axes</short>
<long>Rotate Rubik's cube around all axes (convert windows to pixmaps also).</long>
- <default>false</default>
+ <default>true</default>
</option>
<option name="enable_on_manual_rotate" type="bool">
<short>On manual rotate</short>
diff --git a/util.c b/util.c
index 025a912..278e192 100644
--- a/util.c
+++ b/util.c
@@ -9,22 +9,19 @@ randf(float x)
{ //return random number in range [0,x)
return rand()/(((double)RAND_MAX + 1) / x);
}
+
float
minimum(float x, float y)
{
return ((x) < (y) ? (x) : (y));
}
+
float
maximum(float x, float y)
{
return ((x) > (y) ? (x) : (y));
}
-float
-symmDistr()
-{ //returns number in range [-1, 1] with bias towards 0, symmetric about 0.
- float x = 2*randf(1)-1;
- return x*(1-cbrt(1-fabsf(x)));
-}
+
void
setColor(float* color, float r, float g, float b, float a,
float randomOffset, float randomness)