[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21588] branches/soc-2009-yukishiro: add a reset button
Jingyuan Huang
jingyuan.huang at gmail.com
Tue Jul 14 23:18:23 CEST 2009
Revision: 21588
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21588
Author: yukishiro
Date: 2009-07-14 23:18:14 +0200 (Tue, 14 Jul 2009)
Log Message:
-----------
add a reset button
Modified Paths:
--------------
branches/soc-2009-yukishiro/release/ui/buttons_lightenv.py
branches/soc-2009-yukishiro/source/blender/blenkernel/BKE_lightenv.h
branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c
branches/soc-2009-yukishiro/source/blender/editors/space_buttons/buttons_intern.h
branches/soc-2009-yukishiro/source/blender/editors/space_buttons/buttons_ops.c
branches/soc-2009-yukishiro/source/blender/editors/space_buttons/space_buttons.c
branches/soc-2009-yukishiro/source/blender/editors/space_view3d/space_view3d.c
Modified: branches/soc-2009-yukishiro/release/ui/buttons_lightenv.py
===================================================================
--- branches/soc-2009-yukishiro/release/ui/buttons_lightenv.py 2009-07-14 21:00:15 UTC (rev 21587)
+++ branches/soc-2009-yukishiro/release/ui/buttons_lightenv.py 2009-07-14 21:18:14 UTC (rev 21588)
@@ -16,7 +16,7 @@
def draw(self, context):
layout = self.layout
- lightenv = context.lightenv
+ lightenv = context.lightenv
layout.template_preview(lightenv)
@@ -51,7 +51,8 @@
row.itemR(lightenv, "num_samples", text="# Samples")
row = layout.row()
- row.itemO("PAINT_OT_light_paint_recompute", text="Recompute LightEnv", icon='ICON_LIGHTENV')
+ row.itemO("PAINT_OT_light_paint_recompute", text="Recompute LightEnv")
+ row.itemO("LIGHTENV_OT_reset", text="Reset LightEnv")
class LIGHT_PT_save(LightButtonsPanel):
@@ -71,20 +72,20 @@
class LIGHT_PT_probe_image(LightButtonsPanel):
- __idname__= "LIGHT_PT_probe_image"
- __label__ = "Probe Image"
+ __idname__= "LIGHT_PT_probe_image"
+ __label__ = "Probe Image"
def poll(self, context):
lightenv = context.lightenv
return (lightenv and lightenv.type == 'PROBE')
- def draw(self, context):
- layout = self.layout
+ def draw(self, context):
+ layout = self.layout
split = layout.split(percentage=0.65)
-
- lightenv = context.lightenv
- scene = context.scene
- #split.template_ID(context, lightenv, "probe_image", new="IMAGE_OT_open")
+
+ lightenv = context.lightenv
+ scene = context.scene
+ #split.template_ID(context, lightenv, "probe_image", new="IMAGE_OT_open")
layout.itemR(lightenv, "probe_image")
Modified: branches/soc-2009-yukishiro/source/blender/blenkernel/BKE_lightenv.h
===================================================================
--- branches/soc-2009-yukishiro/source/blender/blenkernel/BKE_lightenv.h 2009-07-14 21:00:15 UTC (rev 21587)
+++ branches/soc-2009-yukishiro/source/blender/blenkernel/BKE_lightenv.h 2009-07-14 21:18:14 UTC (rev 21588)
@@ -43,12 +43,13 @@
void free_lightenv(struct LightEnv *env);
struct LightEnv* add_lightenv(char *name);
struct LightEnv* copy_lightenv(struct LightEnv *env);
-void save_lightenv(struct LightEnv *env, char *image_name, int imtype);
+void reset_lightenv(struct LightEnv *env);
void update_light_func(struct LightEnv *env);
void load_probe_image(struct LightEnv *env, char *image_name);
void update_probe_image(struct LightEnv *env);
+void save_lightenv(struct LightEnv *env, char *image_name, int imtype);
#ifdef __cplusplus
}
Modified: branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c 2009-07-14 21:00:15 UTC (rev 21587)
+++ branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c 2009-07-14 21:18:14 UTC (rev 21588)
@@ -80,6 +80,18 @@
}
}
+
+static void init(LightEnv *env)
+{
+ env->type = LE_DEFAULT;
+ env->light_func = def_synthetic;
+ env->degree = 2;
+ env->num_samples = 10;
+ env->output_width = env->output_height = 512;
+ SH_computeLightCoefficients(env);
+}
+
+
void probe_value(float i, float j, float val[3], void *data)
{
ImBuf *ibuf = (ImBuf*)data;
@@ -142,12 +154,7 @@
LightEnv *env;
env= alloc_libblock(&G.main->lightenv, ID_LE, name);
- env->type = LE_DEFAULT;
- env->light_func = def_synthetic;
- env->degree = 2;
- env->num_samples = 10;
- env->output_width = env->output_height = 512;
- SH_computeLightCoefficients(env);
+ init(env);
return env;
}
@@ -173,3 +180,9 @@
return new_env;
}
+
+void reset_lightenv(LightEnv *env)
+{
+ memset(env->shcoeffs, 0, sizeof(float) * 75);
+ init(env);
+}
Modified: branches/soc-2009-yukishiro/source/blender/editors/space_buttons/buttons_intern.h
===================================================================
--- branches/soc-2009-yukishiro/source/blender/editors/space_buttons/buttons_intern.h 2009-07-14 21:00:15 UTC (rev 21587)
+++ branches/soc-2009-yukishiro/source/blender/editors/space_buttons/buttons_intern.h 2009-07-14 21:18:14 UTC (rev 21588)
@@ -71,6 +71,7 @@
void TEXTURE_OT_new(struct wmOperatorType *ot);
void WORLD_OT_new(struct wmOperatorType *ot);
void LIGHTENV_OT_new(struct wmOperatorType *ot);
+void LIGHTENV_OT_reset(struct wmOperatorType *ot);
void OBJECT_OT_particle_system_add(struct wmOperatorType *ot);
void OBJECT_OT_particle_system_remove(struct wmOperatorType *ot);
Modified: branches/soc-2009-yukishiro/source/blender/editors/space_buttons/buttons_ops.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/editors/space_buttons/buttons_ops.c 2009-07-14 21:00:15 UTC (rev 21587)
+++ branches/soc-2009-yukishiro/source/blender/editors/space_buttons/buttons_ops.c 2009-07-14 21:18:14 UTC (rev 21588)
@@ -450,7 +450,34 @@
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
+/*********************** reset lightenv operator ************************/
+static int reset_lightenv_exec(bContext *C, wmOperator *op)
+{
+ LightEnv *env = CTX_data_pointer_get_type(C, "lightenv", &RNA_LightEnv).data;
+
+ if (env) {
+ reset_lightenv(env);
+ WM_event_add_notifier(C, NC_LIGHTENV|NA_EDITED, env);
+ }
+
+ return OPERATOR_FINISHED;
+}
+
+void LIGHTENV_OT_reset(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Reset LightEnv";
+ ot->idname= "LIGHTENV_OT_reset";
+
+ /* api callbacks */
+ ot->exec= reset_lightenv_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+
/********************** particle system slot operators *********************/
static int particle_system_add_exec(bContext *C, wmOperator *op)
Modified: branches/soc-2009-yukishiro/source/blender/editors/space_buttons/space_buttons.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/editors/space_buttons/space_buttons.c 2009-07-14 21:00:15 UTC (rev 21587)
+++ branches/soc-2009-yukishiro/source/blender/editors/space_buttons/space_buttons.c 2009-07-14 21:18:14 UTC (rev 21588)
@@ -222,6 +222,7 @@
WM_operatortype_append(TEXTURE_OT_new);
WM_operatortype_append(WORLD_OT_new);
WM_operatortype_append(LIGHTENV_OT_new);
+ WM_operatortype_append(LIGHTENV_OT_reset);
WM_operatortype_append(OBJECT_OT_particle_system_add);
WM_operatortype_append(OBJECT_OT_particle_system_remove);
Modified: branches/soc-2009-yukishiro/source/blender/editors/space_view3d/space_view3d.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/editors/space_view3d/space_view3d.c 2009-07-14 21:00:15 UTC (rev 21587)
+++ branches/soc-2009-yukishiro/source/blender/editors/space_view3d/space_view3d.c 2009-07-14 21:18:14 UTC (rev 21588)
@@ -481,6 +481,7 @@
rv3d = ar->regiondata;
switch(wmn->action) {
+ case NA_EDITED:
case NA_ADDED:
rv3d->rflag |= RV3D_RECALC_MCOL;
break;
More information about the Bf-blender-cvs
mailing list