[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21173] branches/soc-2009-yukishiro/source /blender: fix one bug in light rotation, but it is still wrong
Jingyuan Huang
jingyuan.huang at gmail.com
Fri Jun 26 21:17:08 CEST 2009
Revision: 21173
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21173
Author: yukishiro
Date: 2009-06-26 21:17:08 +0200 (Fri, 26 Jun 2009)
Log Message:
-----------
fix one bug in light rotation, but it is still wrong
Modified Paths:
--------------
branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c
branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_light.c
branches/soc-2009-yukishiro/source/blender/sh/intern/compute.c
Modified: branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c 2009-06-26 15:48:09 UTC (rev 21172)
+++ branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c 2009-06-26 19:17:08 UTC (rev 21173)
@@ -54,7 +54,7 @@
// TODO: simple function to return value for 3 channels. needs improvement
void def_synthetic(float theta, float phi, float val[3], void *data)
{
- if (theta < M_PI / 6) {
+ if (theta < M_PI / 12) {
val[0] = val[1] = val[2] = 1.0;
}
else {
Modified: branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_light.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_light.c 2009-06-26 15:48:09 UTC (rev 21172)
+++ branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_light.c 2009-06-26 19:17:08 UTC (rev 21173)
@@ -695,9 +695,8 @@
/************************ light paint rotation ************************/
typedef struct RotateOperation {
ARegion *ar;
+ RegionView3D *rv3d;
float trackvec[3];
- float quat[4];
- int origx, origy, oldx, oldy;
int origkey;
} RotateOperation;
@@ -723,6 +722,7 @@
{
float phi, si, q1[4], dvec[3], newvec[3];
calctrackballvec(&rop->ar->winrct, event->x, event->y, newvec);
+
VecSubf(dvec, newvec, rop->trackvec);
si= sqrt(dvec[0]*dvec[0]+ dvec[1]*dvec[1]+ dvec[2]*dvec[2]);
@@ -732,16 +732,17 @@
Normalize(q1+1);
while (si > 1.0) si -= 2.0;
- phi = si * M_PI / 10.0;
+ phi = si * M_PI / 2.0;
si= sin(phi);
q1[0]= cos(phi);
q1[1]*= si;
q1[2]*= si;
q1[3]*= si;
+
SH_rotateLightEnv(env, q1);
- QuatMul(rop->quat, q1, rop->quat);
+ calctrackballvec(&rop->ar->winrct, event->x, event->y, rop->trackvec);
WM_event_add_notifier(C, NC_LIGHTENV|ND_SH_RESULT, NULL);
}
@@ -759,11 +760,9 @@
RotateOperation *rop;
op->customdata = rop = MEM_callocN(sizeof(RotateOperation), "LightROP");
- rop->ar= CTX_wm_region(C);
- rop->origx= rop->oldx= event->x;
- rop->origy= rop->oldy= event->y;
+ rop->ar = CTX_wm_region(C);
+ rop->rv3d = rop->ar->regiondata;
rop->origkey= event->type;
- QuatOne(rop->quat);
calctrackballvec(&rop->ar->winrct, event->x, event->y, rop->trackvec);
Modified: branches/soc-2009-yukishiro/source/blender/sh/intern/compute.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/sh/intern/compute.c 2009-06-26 15:48:09 UTC (rev 21172)
+++ branches/soc-2009-yukishiro/source/blender/sh/intern/compute.c 2009-06-26 19:17:08 UTC (rev 21173)
@@ -190,7 +190,7 @@
static void eval_real_wigner(ShWigner w, float beta, int degree)
{
float c = cos(beta), s = sin(beta);
- int l,m,n, signl, signm, signlm, signmn;
+ int l, m, n, signl, signm, signlm, signmn;
// Degree 0...
w[0][0][0] = 1;
@@ -694,11 +694,16 @@
void SH_rotateLightEnv(LightEnv *env, float *quat)
{
int deg, l, m, n;
- float eul[3];
+ float q[3], eul[3];
float new_coeffs[25][3];
ShWigner wigner;
- QuatToEul(quat, eul);
+ // XXX
+ q[0]= quat[0];
+ q[1]= quat[2];
+ q[2]= quat[1];
+ q[3]= quat[3];
+ QuatToEul(q, eul);
// create wigner
deg = env->degree;
@@ -707,9 +712,9 @@
premultiply_wigner(wigner, eul[0], deg);
// compute new coeffs
+ memset(new_coeffs, 0, 75 * sizeof(float));
for (l = 0; l <= deg; l++) {
for (m=-l; m<=l; m++) {
- v3_new_vec(0, 0, 0, new_coeffs[l*l+l+m]);
for (n=-l; n<=l; n++) {
new_coeffs[l*l+l+m][0] += wigner[l][m][n] * env->shcoeffs[l*l+l+n][0];
new_coeffs[l*l+l+m][1] += wigner[l][m][n] * env->shcoeffs[l*l+l+n][1];
@@ -718,7 +723,7 @@
}
}
- memcpy(env->shcoeffs, new_coeffs, (deg+1) * (deg+1) * sizeof(float));
+ memcpy(env->shcoeffs, new_coeffs, 75 * sizeof(float));
free_ShWigner(wigner);
}
More information about the Bf-blender-cvs
mailing list