Skip to content
Snippets Groups Projects
Commit 460ece6c authored by slevy's avatar slevy
Browse files

If only one of -T and -F transforms given, invert it to find the other.

And, in partiview version, make sure to *use* o2d/d2o if provided!
parent 8a65903e
No related branches found
No related tags found
No related merge requests found
...@@ -197,6 +197,20 @@ void windup( struct warpstuff *ws, Point *out, CONST Point *in ) ...@@ -197,6 +197,20 @@ void windup( struct warpstuff *ws, Point *out, CONST Point *in )
out->x[2] = x*s + z*c; out->x[2] = x*s + z*c;
} }
void dvtfmpoint( Point *dst, CONST Point *src, CONST double T[16] )
{
int i;
for(i = 0; i < 3; i++)
dst->x[i] = src->x[0]*T[i] + src->x[1]*T[i+4] + src->x[2]*T[i+8] + T[i+12];
}
void windup_o2d( struct warpstuff *ws, Point *out, CONST Point *in ) {
Point tin, tout;
dvtfmpoint( &tin, in, ws->o2d );
windup( ws, &tout, &tin );
dvtfmpoint( out, &tout, ws->d2o );
}
void warpspecks( struct warpstuff *ws, void warpspecks( struct warpstuff *ws,
struct stuff *st, struct stuff *st,
...@@ -212,7 +226,10 @@ void warpspecks( struct warpstuff *ws, ...@@ -212,7 +226,10 @@ void warpspecks( struct warpstuff *ws,
osp = osl->specks; osp = osl->specks;
sp = sl->specks; sp = sl->specks;
for(i = 0; i < n; i++) { for(i = 0; i < n; i++) {
windup( ws, &sp->p, &osp->p ); if(ws->has_o2d)
windup_o2d( ws, &sp->p, &osp->p );
else
windup( ws, &sp->p, &osp->p );
osp = NextSpeck(osp, osl, 1); osp = NextSpeck(osp, osl, 1);
sp = NextSpeck(sp, sl, 1); sp = NextSpeck(sp, sl, 1);
} }
...@@ -354,6 +371,27 @@ float fastsin2pi( float v ) { ...@@ -354,6 +371,27 @@ float fastsin2pi( float v ) {
return sintbl[i] + (v - i)*(sintbl[i+1]-sintbl[i]); return sintbl[i] + (v - i)*(sintbl[i+1]-sintbl[i]);
} }
void deucinv( double dst[16], CONST double src[16] )
{
int i, j;
double s = src[0]*src[0] + src[1]*src[1] + src[2]*src[2];
Point trans;
double t[16];
if(src == dst) {
memcpy( t, src, sizeof(t) );
src = t;
}
for(i = 0; i < 3; i++) {
for(j = 0; j < 3; j++)
dst[i*4+j] = src[j*4+i] / s;
dst[i*4+3] = 0;
}
for(i = 0; i < 3; i++)
dst[3*4+i] = -(src[3*4+0]*dst[0*4+i] + src[3*4+1]*dst[1*4+i] + src[3*4+2]*dst[2*4+i]);
dst[3*4+3] = 1;
}
#ifndef STANDALONE #ifndef STANDALONE
int warp_parse_args( struct dyndata *dd, struct stuff *st, int argc, char **argv ) int warp_parse_args( struct dyndata *dd, struct stuff *st, int argc, char **argv )
...@@ -441,8 +479,16 @@ warp_get_parti( struct dyndata *dd, struct stuff *st, double realtime ) ...@@ -441,8 +479,16 @@ warp_get_parti( struct dyndata *dd, struct stuff *st, double realtime )
ws->tfrac = warpfrac(ws, realtime * 30); ws->tfrac = warpfrac(ws, realtime * 30);
if(ws->has_zerotime) if(ws->has_zerotime)
ws->tfrac -= warpfrac(ws, ws->zerotime); ws->tfrac -= warpfrac(ws, ws->zerotime);
if(ws->has_trange && ws->period0 != 0) if(ws->has_trange && ws->period0 != 0)
ws->tfrac *= (ws->tto - ws->tfrom) / ws->period0; ws->tfrac *= (ws->tto - ws->tfrom) / ws->period0;
if(ws->has_o2d && !ws->has_d2o) {
deucinv( ws->d2o, ws->o2d );
ws->has_d2o = -1;
} else if(!ws->has_o2d && ws->has_d2o) {
deucinv( ws->o2d, ws->d2o );
ws->has_o2d = -1;
}
if(getenv("WDBG")) printf("%g %g %g # rt frac frac(rt)\n", realtime, ws->tfrac, warpfrac(ws, realtime*30)); if(getenv("WDBG")) printf("%g %g %g # rt frac frac(rt)\n", realtime, ws->tfrac, warpfrac(ws, realtime*30));
...@@ -571,7 +617,6 @@ void dwindup( struct warpstuff *ws, float *xyzout, float *dxyzout, CONST float * ...@@ -571,7 +617,6 @@ void dwindup( struct warpstuff *ws, float *xyzout, float *dxyzout, CONST float *
dxyzout[2] = dtheta * (x*c - z*s); dxyzout[2] = dtheta * (x*c - z*s);
} }
void dwindup_o2d( struct warpstuff *ws, float *xyzout, float *dxyzout, CONST float *xyz ) void dwindup_o2d( struct warpstuff *ws, float *xyzout, float *dxyzout, CONST float *xyz )
{ {
float v[3], w[3], dw[3]; float v[3], w[3], dw[3];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment