[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21281] branches/soc-2009-yukishiro/source /blender: fix light rotation
Jingyuan Huang
jingyuan.huang at gmail.com
Wed Jul 1 07:57:27 CEST 2009
Revision: 21281
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21281
Author: yukishiro
Date: 2009-07-01 07:57:27 +0200 (Wed, 01 Jul 2009)
Log Message:
-----------
fix light rotation
Modified Paths:
--------------
branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_light.c
branches/soc-2009-yukishiro/source/blender/sh/SH_api.h
branches/soc-2009-yukishiro/source/blender/sh/intern/compute.c
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-07-01 04:38:53 UTC (rev 21280)
+++ branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_light.c 2009-07-01 05:57:27 UTC (rev 21281)
@@ -578,6 +578,7 @@
static int light_paint_rotate_modal(bContext *C, wmOperator *op, wmEvent *event)
{
RotateOperation *rop= op->customdata;
+ RegionView3D *rv3d = rop->rv3d;
LightEnv *env= CTX_data_scene(C)->lightenv;
switch(event->type) {
@@ -596,7 +597,7 @@
while (si > 1.0) si -= 2.0;
rvec[0] = si * M_PI;
- SH_rotateLightEnv(env, rvec);
+ SH_rotateLightEnv(env, rvec, rv3d->viewmat, rv3d->viewinv);
calctrackballvec(&rop->ar->winrct, event->x, event->y, rop->trackvec);
WM_event_add_notifier(C, NC_LIGHTENV|ND_SH_RESULT, NULL);
Modified: branches/soc-2009-yukishiro/source/blender/sh/SH_api.h
===================================================================
--- branches/soc-2009-yukishiro/source/blender/sh/SH_api.h 2009-07-01 04:38:53 UTC (rev 21280)
+++ branches/soc-2009-yukishiro/source/blender/sh/SH_api.h 2009-07-01 05:57:27 UTC (rev 21281)
@@ -42,7 +42,7 @@
void SH_computeMeshCoefficients(struct Scene *scene, struct Object *ob, unsigned int customdata_mask);
void SH_computeLightCoefficients(struct LightEnv *env);
-void SH_rotateLightEnv(struct LightEnv *env, float quat[4]);
+void SH_rotateLightEnv(struct LightEnv *env, float quat[4], float viewmat[][4], float viewinv[][4]);
void SH_reconstructLightProbe(struct LightEnv *env, struct ImBuf *ibuf);
void SH_lightProbePreview(struct LightEnv *env, int width, int height,
Modified: branches/soc-2009-yukishiro/source/blender/sh/intern/compute.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/sh/intern/compute.c 2009-07-01 04:38:53 UTC (rev 21280)
+++ branches/soc-2009-yukishiro/source/blender/sh/intern/compute.c 2009-07-01 05:57:27 UTC (rev 21281)
@@ -769,46 +769,49 @@
float s = sin(theta);
mat[0][0] = c + (1-c) * x * x;
- mat[0][1] = (1-c) * x * y + z * s;
- mat[0][2] = (1-c) * x * z - y * s;
- mat[1][0] = (1-c) * y * x - z * s;
+ mat[1][0] = (1-c) * x * y + z * s;
+ mat[2][0] = (1-c) * x * z - y * s;
+ mat[0][1] = (1-c) * y * x - z * s;
mat[1][1] = c + (1-c) * y * y;
- mat[1][2] = (1-c) * y * z + x * s;
- mat[2][0] = (1-c) * z * x + y * s;
- mat[2][1] = (1-c) * z * y - x * s;
+ mat[2][1] = (1-c) * y * z + x * s;
+ mat[0][2] = (1-c) * z * x + y * s;
+ mat[1][2] = (1-c) * z * y - x * s;
mat[2][2] = c + (1-c) * z * z;
-
}
-static void matrix_to_eul(float mat[][3], float eul[3])
+static void matrix_to_eul(float mat[][4], float eul[3])
{
if (mat[2][2] > 0.9999) {
- eul[0] = atan2(mat[0][1], mat[1][1]);
+ eul[0] = atan2(mat[1][0], mat[1][1]);
eul[1] = eul[2] = 0.0;
}
else if (mat[2][2] < -0.9999) {
- eul[0] = atan2(mat[0][1], mat[1][1]);
+ eul[0] = atan2(mat[1][0], mat[1][1]);
eul[1] = M_PI;
eul[2] = 0.0;
}
else {
- eul[0] = atan2(mat[2][1], mat[2][0]);
+ eul[0] = atan2(mat[1][2], mat[0][2]);
eul[1] = acos(mat[2][2]);
- eul[2] = atan2(mat[1][2], -mat[0][2]);
+ eul[2] = atan2(mat[2][1], -mat[2][0]);
}
}
-void SH_rotateLightEnv(LightEnv *env, float *rvec)
+void SH_rotateLightEnv(LightEnv *env, float *rvec, float viewmat[][4], float viewinv[][4])
{
int deg, l, m, n;
float eul[3];
- float mat[3][3];
+ float mat[3][3], tmat[4][4], fmat[4][4];
float new_coeffs[25][3];
ShWigner wigner;
// rotation vec to euler
rotvec_to_matrix(rvec, mat);
- matrix_to_eul(mat, eul);
+
+ Mat4MulMat43(tmat, viewinv, mat); // m1 = m3 * m2
+ Mat4MulMat4(fmat, viewmat, tmat); // m1 = m2 * m3
+
+ matrix_to_eul(fmat, eul);
// create wigner
deg = env->degree;
More information about the Bf-blender-cvs
mailing list