summaryrefslogtreecommitdiff
path: root/rubik.c
diff options
context:
space:
mode:
Diffstat (limited to 'rubik.c')
-rw-r--r--rubik.c43
1 files changed, 20 insertions, 23 deletions
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);