From 7245d935eb3e297e87b57eab6f23a97eb07415d7 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 6 May 2010 01:38:17 +0000 Subject: Tweak for dfelinto, logic ui --- source/blender/editors/space_logic/logic_window.c | 16 ++++++++++------ source/blender/editors/space_logic/space_logic.c | 3 +++ source/blender/makesrna/intern/rna_object.c | 1 + 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index b0362cb1980..34203d8c761 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -3651,8 +3651,13 @@ static void draw_actuator_message(uiLayout *layout, PointerRNA *ptr) static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) { uiLayout *split, *row, *col, *subcol; + Object *ob = (Object *)ptr->id.data; + PointerRNA settings_ptr; + + RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); + uiItemR(layout, ptr, "mode", 0, NULL, 0); - + switch (RNA_enum_get(ptr, "mode")) { case ACT_OBJECT_NORMAL: split = uiLayoutSplit(layout, 0.9, 0); @@ -3662,11 +3667,10 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) split = uiLayoutSplit(layout, 0.9, 0); uiItemR(split, ptr, "rot", 0, NULL, 0); uiItemR(split, ptr, "local_rotation", UI_ITEM_R_TOGGLE, NULL, 0); - - // Matt, how to check for ob->gameflag here? Do we need to pass the obj through the drawing function only for that? -// if ((ob->gameflag & OB_DYNAMIC)==0) -// break; - + + if (RNA_enum_get(&settings_ptr, "physics_type") != OB_BODY_TYPE_DYNAMIC) + break; + split = uiLayoutSplit(layout, 0.9, 0); uiItemR(split, ptr, "force", 0, NULL, 0); uiItemR(split, ptr, "local_force", UI_ITEM_R_TOGGLE, NULL, 0); diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c index 5a969be5916..89eff3beb0c 100644 --- a/source/blender/editors/space_logic/space_logic.c +++ b/source/blender/editors/space_logic/space_logic.c @@ -195,6 +195,9 @@ static void logic_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ switch(wmn->category) { + case NC_LOGIC: + ED_region_tag_redraw(ar); + break; case NC_SCENE: switch(wmn->data) { case ND_FRAME: diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 9a67c7fbf17..23184af93ff 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1128,6 +1128,7 @@ static void rna_def_object_game_settings(BlenderRNA *brna) RNA_def_property_enum_items(prop, body_type_items); RNA_def_property_enum_funcs(prop, "rna_GameObjectSettings_physics_type_get", "rna_GameObjectSettings_physics_type_set", NULL); RNA_def_property_ui_text(prop, "Physics Type", "Selects the type of physical representation"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "actor", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_ACTOR); -- cgit v1.2.3 From 13efa685db362692b55af3bfb37bc45b5fbf4a3d Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 6 May 2010 02:58:36 +0000 Subject: rna float set function example for dfelinto --- source/blender/makesrna/intern/rna_actuator.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 4254f4280f8..d86189141b0 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -109,6 +109,16 @@ static void rna_Actuator_type_update(Main *bmain, Scene *scene, PointerRNA *ptr) init_actuator(act); } +static void rna_ObjectActuator_integralcoefficient_set(struct PointerRNA *ptr, float value) +{ + bActuator *act = (bActuator*)ptr->data; + bObjectActuator *oa = act->data; + + oa->forcerot[1] = value; + oa->forcerot[0] = 60.0f*oa->forcerot[1]; +} + + #else void rna_def_actuator(BlenderRNA *brna) @@ -181,6 +191,7 @@ static void rna_def_object_actuator(BlenderRNA *brna) prop= RNA_def_property(srna, "integral_coefficient", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "forcerot[1]"); RNA_def_property_ui_range(prop, 0.0, 3.0, 0.1, 0.01); + RNA_def_property_float_funcs(prop, NULL, "rna_ObjectActuator_integralcoefficient_set", NULL); RNA_def_property_ui_text(prop, "Integral Coefficient", "Low value (0.01) for slow response, high value (0.5) for fast response"); RNA_def_property_update(prop, NC_LOGIC, NULL); -- cgit v1.2.3 From e364ede7b92b4046e89bcf6a7e4defc014ecc282 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 6 May 2010 03:15:14 +0000 Subject: Fix [#22246] Invisible objects on 3D-View (patch included) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified patch by Teppo Känsälä, thanks for finding the issue! --- source/blender/blenloader/intern/readfile.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 06290a5ac83..42a3aebea2d 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -10748,6 +10748,27 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } /* sequencer changes */ } + + if (main->versionfile <= 251) { /* 2.5.1 had no subversions */ + bScreen *sc; + + /* Blender 2.5.2 - subversion 0 introduced a new setting: V3D_RENDER_OVERRIDE. + * This bit was used in the past for V3D_TRANSFORM_SNAP, which is now deprecated. + * Here we clear it for old files so they don't come in with V3D_RENDER_OVERRIDE set, + * which would cause cameras, lamps, etc to become invisible */ + for(sc= main->screen.first; sc; sc= sc->id.next) { + ScrArea *sa; + for(sa= sc->areabase.first; sa; sa= sa->next) { + SpaceLink *sl; + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if(sl->spacetype==SPACE_VIEW3D) { + View3D* v3d = (View3D *)sl; + v3d->flag2 &= ~V3D_RENDER_OVERRIDE; + } + } + } + } + } if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 1)) { Brush *brush; -- cgit v1.2.3 From b88656d7f1766dcd14cc8df5fa80fe4809926430 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Thu, 6 May 2010 03:26:46 +0000 Subject: Logic UI: more actuators: armature, motion, edit object (ui) and 2dfilter (layout fix) --- source/blender/editors/space_logic/logic_window.c | 121 ++++++++++++++++++---- source/blender/makesrna/intern/rna_actuator.c | 6 +- 2 files changed, 106 insertions(+), 21 deletions(-) diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 34203d8c761..8c52add4485 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -3549,7 +3549,38 @@ static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr) static void draw_actuator_armature(uiLayout *layout, PointerRNA *ptr) { - //XXXACTUATOR + uiLayout *row; + uiItemR(layout, ptr, "mode", 0, NULL, 0); + switch (RNA_enum_get(ptr, "mode")) + { + case ACT_ARM_RUN: + break; + case ACT_ARM_ENABLE: + row = uiLayoutRow(layout, 1); + uiItemR(row, ptr, "bone", 0, NULL, 0); + uiItemR(row, ptr, "constraint", 0, NULL, 0); + break; + case ACT_ARM_DISABLE: + row = uiLayoutRow(layout, 1); + uiItemR(row, ptr, "bone", 0, NULL, 0); + uiItemR(row, ptr, "constraint", 0, NULL, 0); + break; + case ACT_ARM_SETTARGET: + row = uiLayoutRow(layout, 1); + uiItemR(row, ptr, "bone", 0, NULL, 0); + uiItemR(row, ptr, "constraint", 0, NULL, 0); + + uiItemR(layout, ptr, "target", 0, NULL, 0); + uiItemR(layout, ptr, "secondary_target", 0, NULL, 0); + break; + case ACT_ARM_SETWEIGHT: + row = uiLayoutRow(layout, 1); + uiItemR(row, ptr, "bone", 0, NULL, 0); + uiItemR(row, ptr, "constraint", 0, NULL, 0); + + uiItemR(layout, ptr, "weight", 0, NULL, 0); + break; + } } static void draw_actuator_camera(uiLayout *layout, PointerRNA *ptr) @@ -3573,7 +3604,48 @@ static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr) static void draw_actuator_edit_object(uiLayout *layout, PointerRNA *ptr) { - //XXXACTUATOR + uiLayout *row, *split, *subsplit; + uiItemR(layout, ptr, "mode", 0, NULL, 0); + + switch (RNA_enum_get(ptr, "mode")) + { + case ACT_EDOB_ADD_OBJECT: + row = uiLayoutRow(layout, 0); + uiItemR(row, ptr, "object", 0, NULL, 0); + uiItemR(row, ptr, "time", 0, NULL, 0); + + split = uiLayoutSplit(layout, 0.9, 0); + row = uiLayoutRow(split, 0); + uiItemR(row, ptr, "linear_velocity", 0, NULL, 0); + uiItemR(split, ptr, "local_linear_velocity", UI_ITEM_R_TOGGLE, NULL, 0); + + split = uiLayoutSplit(layout, 0.9, 0); + row = uiLayoutRow(split, 0); + uiItemR(row, ptr, "angular_velocity", 0, NULL, 0); + uiItemR(split, ptr, "local_angular_velocity", UI_ITEM_R_TOGGLE, NULL, 0); + break; + case ACT_EDOB_END_OBJECT: + break; + case ACT_EDOB_REPLACE_MESH: + split = uiLayoutSplit(layout, 0.6, 0); + uiItemR(split, ptr, "mesh", 0, NULL, 0); + row = uiLayoutRow(split, 0); + uiItemR(row, ptr, "replace_display_mesh", UI_ITEM_R_TOGGLE, NULL, 0); + uiItemR(row, ptr, "replace_physics_mesh", UI_ITEM_R_TOGGLE, NULL, 0); + break; + case ACT_EDOB_TRACK_TO: + split = uiLayoutSplit(layout, 0.5, 0); + uiItemR(split, ptr, "track_object", 0, NULL, 0); + subsplit = uiLayoutSplit(split, 0.7, 0); + uiItemR(subsplit, ptr, "time", 0, NULL, 0); + uiItemR(subsplit, ptr, "enable_3d_tracking", UI_ITEM_R_TOGGLE, NULL, 0); + break; + case ACT_EDOB_DYNAMICS: + uiItemR(layout, ptr, "dynamic_operation", 0, NULL, 0); + if (RNA_enum_get(ptr, "dynamic_operation") == ACT_EDOB_SET_MASS) + uiItemR(layout, ptr, "mass", 0, NULL, 0); + break; + } } static void draw_actuator_filter_2d(uiLayout *layout, PointerRNA *ptr) @@ -3661,32 +3733,39 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) switch (RNA_enum_get(ptr, "mode")) { case ACT_OBJECT_NORMAL: split = uiLayoutSplit(layout, 0.9, 0); - uiItemR(split, ptr, "loc", 0, NULL, 0); + row = uiLayoutRow(split, 0); + uiItemR(row, ptr, "loc", 0, NULL, 0); uiItemR(split, ptr, "local_location", UI_ITEM_R_TOGGLE, NULL, 0); split = uiLayoutSplit(layout, 0.9, 0); - uiItemR(split, ptr, "rot", 0, NULL, 0); + row = uiLayoutRow(split, 0); + uiItemR(row, ptr, "rot", 0, NULL, 0); uiItemR(split, ptr, "local_rotation", UI_ITEM_R_TOGGLE, NULL, 0); if (RNA_enum_get(&settings_ptr, "physics_type") != OB_BODY_TYPE_DYNAMIC) break; + uiItemL(layout, "Dynamic Object Settings:", 0); split = uiLayoutSplit(layout, 0.9, 0); - uiItemR(split, ptr, "force", 0, NULL, 0); + row = uiLayoutRow(split, 0); + uiItemR(row, ptr, "force", 0, NULL, 0); uiItemR(split, ptr, "local_force", UI_ITEM_R_TOGGLE, NULL, 0); split = uiLayoutSplit(layout, 0.9, 0); - uiItemR(split, ptr, "torque", 0, NULL, 0); + row = uiLayoutRow(split, 0); + uiItemR(row, ptr, "torque", 0, NULL, 0); uiItemR(split, ptr, "local_torque", UI_ITEM_R_TOGGLE, NULL, 0); split = uiLayoutSplit(layout, 0.9, 0); - uiItemR(split, ptr, "linear_velocity", 0, NULL, 0); row = uiLayoutRow(split, 0); + uiItemR(row, ptr, "linear_velocity", 0, NULL, 0); + row = uiLayoutRow(split, 1); uiItemR(row, ptr, "local_linear_velocity", UI_ITEM_R_TOGGLE, NULL, 0); uiItemR(row, ptr, "add_linear_velocity", UI_ITEM_R_TOGGLE, NULL, 0); split = uiLayoutSplit(layout, 0.9, 0); - uiItemR(split, ptr, "angular_velocity", 0, NULL, 0); + row = uiLayoutRow(split, 0); + uiItemR(row, ptr, "angular_velocity", 0, NULL, 0); uiItemR(split, ptr, "local_angular_velocity", UI_ITEM_R_TOGGLE, NULL, 0); uiItemR(layout, ptr, "damping", 0, NULL, 0); @@ -3695,32 +3774,38 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) uiItemR(layout, ptr, "reference_object", 0, NULL, 0); split = uiLayoutSplit(layout, 0.9, 0); - uiItemR(split, ptr, "linear_velocity", 0, NULL, 0); + row = uiLayoutRow(split, 0); + uiItemR(row, ptr, "linear_velocity", 0, NULL, 0); + uiItemR(split, ptr, "local_linear_velocity", UI_ITEM_R_TOGGLE, NULL, 0); - col = uiLayoutColumn(layout, 0); - uiItemR(col, ptr, "servo_limit_x", 0, NULL, 0); + row = uiLayoutRow(layout, 0); + col = uiLayoutColumn(row, 0); + uiItemR(col, ptr, "servo_limit_x", UI_ITEM_R_TOGGLE, NULL, 0); subcol = uiLayoutColumn(col, 0); uiLayoutSetActive(subcol, RNA_boolean_get(ptr, "servo_limit_x")==1); uiItemR(subcol, ptr, "force_max_x", 0, NULL, 0); uiItemR(subcol, ptr, "force_min_x", 0, NULL, 0); - col = uiLayoutColumn(layout, 0); - uiItemR(col, ptr, "servo_limit_y", 0, NULL, 0); + col = uiLayoutColumn(row, 0); + uiItemR(col, ptr, "servo_limit_y", UI_ITEM_R_TOGGLE, NULL, 0); subcol = uiLayoutColumn(col, 0); uiLayoutSetActive(subcol, RNA_boolean_get(ptr, "servo_limit_y")==1); uiItemR(subcol, ptr, "force_max_y", 0, NULL, 0); uiItemR(subcol, ptr, "force_min_y", 0, NULL, 0); - col = uiLayoutColumn(layout, 0); - uiItemR(col, ptr, "servo_limit_z", 0, NULL, 0); + col = uiLayoutColumn(row, 0); + uiItemR(col, ptr, "servo_limit_z", UI_ITEM_R_TOGGLE, NULL, 0); subcol = uiLayoutColumn(col, 0); uiLayoutSetActive(subcol, RNA_boolean_get(ptr, "servo_limit_z")==1); uiItemR(subcol, ptr, "force_max_z", 0, NULL, 0); uiItemR(subcol, ptr, "force_min_z", 0, NULL, 0); - uiItemR(col, ptr, "proportional_coefficient", 0, NULL, 0); - uiItemR(col, ptr, "integral_coefficient", 0, NULL, 0); - uiItemR(col, ptr, "derivate_coefficient", 0, NULL, 0); + //XXXACTUATOR missing labels from original 2.49 ui (e.g. Servo, Min, Max, Fast) + + col = uiLayoutColumn(layout, 1); + uiItemR(col, ptr, "proportional_coefficient", UI_ITEM_R_SLIDER, NULL, 0); + uiItemR(col, ptr, "integral_coefficient", UI_ITEM_R_SLIDER, NULL, 0); + uiItemR(col, ptr, "derivate_coefficient", UI_ITEM_R_SLIDER, NULL, 0); break; } } diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index d86189141b0..266e912fd52 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -154,7 +154,7 @@ static void rna_def_object_actuator(BlenderRNA *brna) PropertyRNA* prop; static EnumPropertyItem prop_type_items[] ={ - {ACT_OBJECT_NORMAL, "OBJECT_NORMAL", 0, "Simple motion", ""}, + {ACT_OBJECT_NORMAL, "OBJECT_NORMAL", 0, "Simple Motion", ""}, {ACT_OBJECT_SERVO, "OBJECT_SERVO", 0, "Servo Control", ""}, {0, NULL, 0, NULL, NULL}}; @@ -1238,7 +1238,7 @@ static void rna_def_armature_actuator(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Armature Actuator", "Actuator to .."); RNA_def_struct_sdna_from(srna, "bArmatureActuator", "data"); - prop= RNA_def_property(srna, "contraint_type", PROP_ENUM, PROP_NONE); + prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "type"); RNA_def_property_enum_items(prop, prop_type_items); RNA_def_property_ui_text(prop, "Constraint Type", ""); @@ -1252,7 +1252,7 @@ static void rna_def_armature_actuator(BlenderRNA *brna) /* XXX eventually move to a datablock pointer. However datablocking this may be a problem we would need to update the value whenever the armature changes. */ - prop= RNA_def_property(srna, "contraint", PROP_STRING, PROP_NONE); + prop= RNA_def_property(srna, "constraint", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "constraint"); RNA_def_property_ui_text(prop, "Constraint", "Name of the constraint you want to control"); RNA_def_property_update(prop, NC_LOGIC, NULL); -- cgit v1.2.3 From 16e628023c1a88ebb1df249923c0edfa8fcb654b Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 6 May 2010 03:49:26 +0000 Subject: Fix [#22249] Can enter camera view when there is no camera in scene --- source/blender/editors/space_view3d/view3d_edit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index c7a174626a0..3d039f07a65 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1893,7 +1893,8 @@ static int viewnumpad_exec(bContext *C, wmOperator *op) if(v3d->camera==NULL) { v3d->camera= scene_find_camera(scene); - /*handle_view3d_lock();*/ + if (v3d->camera == NULL) + return OPERATOR_CANCELLED; } rv3d->persp= RV3D_CAMOB; smooth_view(C, NULL, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens); -- cgit v1.2.3 From 600d22fd8fe13776c2f342972bd1a3f4322d3cec Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 6 May 2010 07:19:55 +0000 Subject: Fix [#22256] bpy.ops.sequencer.delete.poll() not working Just about all sequencer operator poll functions were requiring an active sequence editor space type. This wasn't necessary for most of them, and prevented use from scripts, console, etc. --- .../editors/space_sequencer/sequencer_edit.c | 102 ++++++--------------- .../editors/space_sequencer/sequencer_intern.h | 3 + .../editors/space_sequencer/sequencer_select.c | 28 ++---- 3 files changed, 39 insertions(+), 94 deletions(-) diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 11a55ebb421..1154ed02a3e 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -1270,6 +1270,11 @@ static int seq_get_snaplimit(View2D *v2d) #endif /* Operator functions */ +int sequencer_edit_poll(bContext *C) +{ + return (seq_give_editing(CTX_data_scene(C), FALSE) != NULL); +} + /* snap operator*/ static int sequencer_snap_exec(bContext *C, wmOperator *op) @@ -1279,8 +1284,6 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op) Editing *ed= seq_give_editing(scene, FALSE); Sequence *seq; int snap_frame; - - if(ed==NULL) return OPERATOR_CANCELLED; snap_frame= RNA_int_get(op->ptr, "frame"); @@ -1354,8 +1357,7 @@ void SEQUENCER_OT_snap(struct wmOperatorType *ot) /* api callbacks */ ot->invoke= sequencer_snap_invoke; ot->exec= sequencer_snap_exec; - - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1371,9 +1373,6 @@ static int sequencer_mute_exec(bContext *C, wmOperator *op) Sequence *seq; int selected; - if(ed==NULL) - return OPERATOR_CANCELLED; - selected= !RNA_boolean_get(op->ptr, "unselected"); for(seq= ed->seqbasep->first; seq; seq= seq->next) { @@ -1404,8 +1403,7 @@ void SEQUENCER_OT_mute(struct wmOperatorType *ot) /* api callbacks */ ot->exec= sequencer_mute_exec; - - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1422,9 +1420,6 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op) Sequence *seq; int selected; - if(ed==NULL) - return OPERATOR_CANCELLED; - selected= !RNA_boolean_get(op->ptr, "unselected"); for(seq= ed->seqbasep->first; seq; seq= seq->next) { @@ -1449,14 +1444,13 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op) void SEQUENCER_OT_unmute(struct wmOperatorType *ot) { /* identifiers */ - ot->name= "UnMute Strips"; + ot->name= "Un-Mute Strips"; ot->idname= "SEQUENCER_OT_unmute"; - ot->description="UnMute unselected rather than selected strips"; + ot->description="Un-Mute unselected rather than selected strips"; /* api callbacks */ ot->exec= sequencer_unmute_exec; - - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1472,9 +1466,6 @@ static int sequencer_lock_exec(bContext *C, wmOperator *op) Editing *ed= seq_give_editing(scene, FALSE); Sequence *seq; - if(ed==NULL) - return OPERATOR_CANCELLED; - for(seq= ed->seqbasep->first; seq; seq= seq->next) { if (seq->flag & SELECT) { seq->flag |= SEQ_LOCK; @@ -1495,8 +1486,7 @@ void SEQUENCER_OT_lock(struct wmOperatorType *ot) /* api callbacks */ ot->exec= sequencer_lock_exec; - - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1509,9 +1499,6 @@ static int sequencer_unlock_exec(bContext *C, wmOperator *op) Editing *ed= seq_give_editing(scene, FALSE); Sequence *seq; - if(ed==NULL) - return OPERATOR_CANCELLED; - for(seq= ed->seqbasep->first; seq; seq= seq->next) { if (seq->flag & SELECT) { seq->flag &= ~SEQ_LOCK; @@ -1532,8 +1519,7 @@ void SEQUENCER_OT_unlock(struct wmOperatorType *ot) /* api callbacks */ ot->exec= sequencer_unlock_exec; - - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1546,9 +1532,6 @@ static int sequencer_reload_exec(bContext *C, wmOperator *op) Editing *ed= seq_give_editing(scene, FALSE); Sequence *seq; - if(ed==NULL) - return OPERATOR_CANCELLED; - for(seq= ed->seqbasep->first; seq; seq= seq->next) { if(seq->flag & SELECT) { update_changed_seq_and_deps(scene, seq, 0, 1); @@ -1569,8 +1552,7 @@ void SEQUENCER_OT_reload(struct wmOperatorType *ot) /* api callbacks */ ot->exec= sequencer_reload_exec; - - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1581,9 +1563,6 @@ static int sequencer_refresh_all_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Editing *ed= seq_give_editing(scene, FALSE); - - if(ed==NULL) - return OPERATOR_CANCELLED; free_imbuf_seq(scene, &ed->seqbase, FALSE); @@ -1601,8 +1580,7 @@ void SEQUENCER_OT_refresh_all(struct wmOperatorType *ot) /* api callbacks */ ot->exec= sequencer_refresh_all_exec; - - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1623,9 +1601,6 @@ static int sequencer_cut_exec(bContext *C, wmOperator *op) ListBase newlist; int changed; - - if(ed==NULL) - return OPERATOR_CANCELLED; cut_frame= RNA_int_get(op->ptr, "frame"); cut_hard= RNA_enum_get(op->ptr, "type"); @@ -1678,7 +1653,8 @@ static int sequencer_cut_invoke(bContext *C, wmOperator *op, wmEvent *event) int cut_side, cut_frame; cut_frame= CFRA; - cut_side= mouse_frame_side(v2d, event->x - ar->winrct.xmin, cut_frame); + if (ED_operator_sequencer_active(C) && v2d) + cut_side= mouse_frame_side(v2d, event->x - ar->winrct.xmin, cut_frame); RNA_int_set(op->ptr, "frame", cut_frame); RNA_enum_set(op->ptr, "side", cut_side); @@ -1698,8 +1674,7 @@ void SEQUENCER_OT_cut(struct wmOperatorType *ot) /* api callbacks */ ot->invoke= sequencer_cut_invoke; ot->exec= sequencer_cut_exec; - - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1749,7 +1724,6 @@ static int sequencer_add_duplicate_invoke(bContext *C, wmOperator *op, wmEvent * void SEQUENCER_OT_duplicate(wmOperatorType *ot) { - /* identifiers */ ot->name= "Duplicate"; ot->idname= "SEQUENCER_OT_duplicate"; @@ -1758,7 +1732,6 @@ void SEQUENCER_OT_duplicate(wmOperatorType *ot) /* api callbacks */ ot->invoke= sequencer_add_duplicate_invoke; ot->exec= sequencer_add_duplicate_exec; - ot->poll= ED_operator_sequencer_active; /* flags */ @@ -1777,9 +1750,6 @@ static int sequencer_delete_exec(bContext *C, wmOperator *op) MetaStack *ms; int nothingSelected = TRUE; - if(ed==NULL) - return OPERATOR_CANCELLED; - seq=active_seq_get(scene); if (seq && seq->flag & SELECT) { /* avoid a loop since this is likely to be selected */ nothingSelected = FALSE; @@ -1840,8 +1810,7 @@ void SEQUENCER_OT_delete(wmOperatorType *ot) /* api callbacks */ ot->invoke= WM_operator_confirm; ot->exec= sequencer_delete_exec; - - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1932,8 +1901,7 @@ void SEQUENCER_OT_images_separate(wmOperatorType *ot) /* api callbacks */ ot->invoke= WM_operator_props_popup; ot->exec= sequencer_separate_images_exec; - - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1952,9 +1920,6 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *op) Sequence *last_seq= active_seq_get(scene); MetaStack *ms; - if(ed==NULL) - return OPERATOR_CANCELLED; - if(last_seq && last_seq->type==SEQ_META && last_seq->flag & SELECT) { /* Enter Metastrip */ ms= MEM_mallocN(sizeof(MetaStack), "metastack"); @@ -2008,8 +1973,7 @@ void SEQUENCER_OT_meta_toggle(wmOperatorType *ot) /* api callbacks */ ot->exec= sequencer_meta_toggle_exec; - - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -2026,9 +1990,6 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) int channel_max= 1; - if(ed==NULL) - return OPERATOR_CANCELLED; - if(seqbase_isolated_sel_check(ed->seqbasep)==FALSE) { BKE_report(op->reports, RPT_ERROR, "Please select all related strips"); return OPERATOR_CANCELLED; @@ -2081,8 +2042,7 @@ void SEQUENCER_OT_meta_make(wmOperatorType *ot) /* api callbacks */ ot->invoke= WM_operator_confirm; ot->exec= sequencer_meta_make_exec; - - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -2153,8 +2113,7 @@ void SEQUENCER_OT_meta_separate(wmOperatorType *ot) /* api callbacks */ ot->invoke= WM_operator_confirm; ot->exec= sequencer_meta_separate_exec; - - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -2186,7 +2145,6 @@ void SEQUENCER_OT_view_all(wmOperatorType *ot) /* api callbacks */ ot->exec= sequencer_view_all_exec; - ot->poll= ED_operator_sequencer_active; /* flags */ @@ -2253,7 +2211,6 @@ void SEQUENCER_OT_view_all_preview(wmOperatorType *ot) /* api callbacks */ ot->exec= sequencer_view_all_preview_exec; - ot->poll= ED_operator_sequencer_active; /* flags */ @@ -2370,7 +2327,6 @@ void SEQUENCER_OT_view_selected(wmOperatorType *ot) /* api callbacks */ ot->exec= sequencer_view_selected_exec; - ot->poll= ED_operator_sequencer_active; /* flags */ @@ -2456,7 +2412,7 @@ void SEQUENCER_OT_next_edit(wmOperatorType *ot) /* api callbacks */ ot->exec= sequencer_next_edit_exec; - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -2486,7 +2442,7 @@ void SEQUENCER_OT_previous_edit(wmOperatorType *ot) /* api callbacks */ ot->exec= sequencer_previous_edit_exec; - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -2531,7 +2487,6 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op) Sequence *seq, *iseq; int side= RNA_enum_get(op->ptr, "side"); - if(ed==NULL) return OPERATOR_CANCELLED; if(active_seq==NULL) return OPERATOR_CANCELLED; seq = find_next_prev_sequence(scene, active_seq, side, -1); @@ -2591,7 +2546,7 @@ void SEQUENCER_OT_swap(wmOperatorType *ot) /* api callbacks */ ot->exec= sequencer_swap_exec; - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -2641,7 +2596,7 @@ void SEQUENCER_OT_rendersize(wmOperatorType *ot) /* api callbacks */ ot->exec= sequencer_rendersize_exec; - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -2670,9 +2625,6 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op) Editing *ed= seq_give_editing(scene, FALSE); Sequence *seq; - if(ed==NULL) - return OPERATOR_CANCELLED; - seq_free_clipboard(); if(seqbase_isolated_sel_check(ed->seqbasep)==FALSE) { @@ -2700,7 +2652,7 @@ void SEQUENCER_OT_copy(wmOperatorType *ot) /* api callbacks */ ot->exec= sequencer_copy_exec; - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index f591afa1e34..dc2d89293ee 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -67,6 +67,9 @@ int event_to_efftype(int event); int seq_effect_find_selected(struct Scene *scene, struct Sequence *activeseq, int type, struct Sequence **selseq1, struct Sequence **selseq2, struct Sequence **selseq3, char **error_str); struct Sequence *alloc_sequence(struct ListBase *lb, int cfra, int machine); +/* operator helpers */ +int sequencer_edit_poll(struct bContext *C); + /* externs */ extern EnumPropertyItem sequencer_prop_effect_types[]; extern EnumPropertyItem prop_side_types[]; diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index a49394d3a12..a27d6626b13 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -222,9 +222,6 @@ static int sequencer_deselect_exec(bContext *C, wmOperator *op) Sequence *seq; int desel = 0; - if(ed==NULL) - return OPERATOR_CANCELLED; - for(seq= ed->seqbasep->first; seq; seq=seq->next) { if(seq->flag & SEQ_ALLSEL) { desel= 1; @@ -256,8 +253,7 @@ void SEQUENCER_OT_select_all_toggle(struct wmOperatorType *ot) /* api callbacks */ ot->exec= sequencer_deselect_exec; - - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -271,9 +267,6 @@ static int sequencer_select_inverse_exec(bContext *C, wmOperator *op) Editing *ed= seq_give_editing(scene, FALSE); Sequence *seq; - if(ed==NULL) - return OPERATOR_CANCELLED; - for(seq= ed->seqbasep->first; seq; seq=seq->next) { if (seq->flag & SELECT) { seq->flag &= SEQ_DESEL; @@ -298,8 +291,7 @@ void SEQUENCER_OT_select_inverse(struct wmOperatorType *ot) /* api callbacks */ ot->exec= sequencer_select_inverse_exec; - - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -617,7 +609,7 @@ void SEQUENCER_OT_select_more(wmOperatorType *ot) /* api callbacks */ ot->exec= sequencer_select_more_exec; - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -648,7 +640,7 @@ void SEQUENCER_OT_select_less(wmOperatorType *ot) /* api callbacks */ ot->exec= sequencer_select_less_exec; - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -699,7 +691,7 @@ void SEQUENCER_OT_select_linked_pick(wmOperatorType *ot) /* identifiers */ ot->name= "Select pick linked"; ot->idname= "SEQUENCER_OT_select_linked_pick"; - ot->description="DOC_BROKEN"; + ot->description="Select a chain of linked strips nearest to the mouse pointer"; /* api callbacks */ ot->invoke= sequencer_select_linked_pick_invoke; @@ -738,7 +730,7 @@ void SEQUENCER_OT_select_linked(wmOperatorType *ot) /* api callbacks */ ot->exec= sequencer_select_linked_exec; - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -755,8 +747,6 @@ static int sequencer_select_handles_exec(bContext *C, wmOperator *op) Sequence *seq; int sel_side= RNA_enum_get(op->ptr, "side"); - if (ed==NULL) - return OPERATOR_CANCELLED; for(seq= ed->seqbasep->first; seq; seq=seq->next) { if (seq->flag & SELECT) { @@ -786,11 +776,11 @@ void SEQUENCER_OT_select_handles(wmOperatorType *ot) /* identifiers */ ot->name= "Select Handles"; ot->idname= "SEQUENCER_OT_select_handles"; - ot->description="DOC_BROKEN"; + ot->description="Select manipulator handles on the sides of the selected strip"; /* api callbacks */ ot->exec= sequencer_select_handles_exec; - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -827,7 +817,7 @@ void SEQUENCER_OT_select_active_side(wmOperatorType *ot) /* api callbacks */ ot->exec= sequencer_select_active_side_exec; - ot->poll= ED_operator_sequencer_active; + ot->poll= sequencer_edit_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -- cgit v1.2.3 From 52517570f0e5d225143eae7a23c8db8b08de12e6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 6 May 2010 08:30:42 +0000 Subject: python property - object.scene_users Also made this and object.group_users return tuples so it raises an error in this case... ob.scene_users.append(scene) --- release/scripts/modules/bpy_types.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index 5f327050668..6e4596a1109 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -45,21 +45,21 @@ class Object(bpy_types.ID): def children(self): """All the children of this object""" import bpy - return [child for child in bpy.data.objects if child.parent == self] + return tuple(child for child in bpy.data.objects if child.parent == self) @property def group_users(self): """The groups this object is in""" import bpy name = self.name - return [group for group in bpy.data.groups if name in group.objects] + return tuple(group for group in bpy.data.groups if name in group.objects) @property def scene_users(self): """The scenes this object is in""" import bpy name = self.name - return [scene for scene in bpy.data.scenes if name in scene.objects] + return tuple(scene for scene in bpy.data.scenes if name in scene.objects) class _GenericBone: -- cgit v1.2.3 From 1de451ff2d3f03e1a868e9dbbfea81ed578a5c4b Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 6 May 2010 11:28:46 +0000 Subject: Datablocks Viewer Bugfix: Adding Drivers and/or KeyingSet paths from the Datablocks Viewer for array elements was not working. --- source/blender/editors/space_outliner/outliner.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 7d013ef940d..d4283b7b6d3 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -3854,7 +3854,7 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, short m short groupmode= KSP_GROUP_KSNAME; /* check if RNA-property described by this selected element is an animateable prop */ - if ((tselem->type == TSE_RNA_PROPERTY) && RNA_property_animateable(&te->rnaptr, te->directdata)) { + if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) && RNA_property_animateable(&te->rnaptr, te->directdata)) { /* get id + path + index info from the selected element */ tree_element_to_path(soops, te, tselem, &id, &path, &array_index, &flag, &groupmode); @@ -3862,7 +3862,7 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, short m /* only if ID and path were set, should we perform any actions */ if (id && path) { - int arraylen; + int arraylen = 1; /* array checks */ if (flag & KSP_FLAG_WHOLE_ARRAY) { -- cgit v1.2.3 From cbf7d507c54b21140fb3a5334ae7d971096d3497 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 6 May 2010 11:47:10 +0000 Subject: last commit broke linking to scenes from the UI --- release/scripts/ui/space_view3d.py | 4 ++-- source/blender/editors/animation/anim_markers.c | 1 + source/blender/editors/object/object_relations.c | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index 7b78d6c4299..a8fc4eb89af 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -835,8 +835,8 @@ class VIEW3D_MT_make_links(bpy.types.Menu): def draw(self, context): layout = self.layout - layout.operator_menu_enum("object.make_links_scene", "type", text="Objects to Scene...") - layout.operator_menu_enum("marker.make_links_scene", "type", text="Markers to Scene...") + layout.operator_menu_enum("object.make_links_scene", "scene", text="Objects to Scene...") + layout.operator_menu_enum("marker.make_links_scene", "scene", text="Markers to Scene...") layout.operator_enums("object.make_links_data", "type") # inline diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index edad0b724d7..719b46738d3 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -1112,6 +1112,7 @@ static void MARKER_OT_make_links_scene(wmOperatorType *ot) /* properties */ prop= RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", ""); RNA_def_enum_funcs(prop, RNA_scene_itemf); + ot->prop= prop; } diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 939c868e19e..1f970b50716 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1266,6 +1266,7 @@ void OBJECT_OT_make_links_scene(wmOperatorType *ot) /* properties */ prop= RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", ""); RNA_def_enum_funcs(prop, RNA_scene_local_itemf); + ot->prop= prop; } void OBJECT_OT_make_links_data(wmOperatorType *ot) -- cgit v1.2.3 From 092bd9f300d39ae3df353b41dc27ff059ae9b4eb Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Thu, 6 May 2010 12:01:44 +0000 Subject: Logic UI: actuators - action+rna 100%, sound 100%, constraint+rna 50% Notes: 1) I had to pass Context to the draw_actuator_sound in order to access the open_sound_operator uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL); According to Campbell they are better ways to do that (mdef bind for reference). but for now it works. 2) for the record: action actuator is equal to shape actuator (but runs in armature) 3) in Constraint Actuator I think I should unify all the limit_loc_max_, loc_min, ... properties. I was thinking about replacing it with a single limit_loc_max, limit_loc_min, range, distance, and use get/set funcs to find the correct one. --- source/blender/editors/space_logic/logic_window.c | 153 ++++++++- source/blender/makesdna/DNA_actuator_types.h | 1 + source/blender/makesrna/intern/rna_actuator.c | 365 ++++++++++++++++++++-- 3 files changed, 493 insertions(+), 26 deletions(-) diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 8c52add4485..6b24cb06b30 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -3544,7 +3544,32 @@ static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr) static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr) { - //XXXACTUATOR + uiLayout *row; + + row= uiLayoutRow(layout, 0); + uiItemR(row, ptr, "mode", 0, NULL, 0); + uiItemR(row, ptr, "action", 0, NULL, 0); + uiItemR(row, ptr, "continue_last_frame", 0, NULL, 0); + + row= uiLayoutRow(layout, 0); + if((RNA_enum_get(ptr, "mode") == ACT_ACTION_FROM_PROP)) + uiItemR(row, ptr, "property", 0, NULL, 0); + + else { + uiItemR(row, ptr, "frame_start", 0, NULL, 0); + uiItemR(row, ptr, "frame_end", 0, NULL, 0); + } + + row= uiLayoutRow(layout, 0); + uiItemR(row, ptr, "blendin", 0, NULL, 0); + uiItemR(row, ptr, "priority", 0, NULL, 0); + + row= uiLayoutRow(layout, 0); + uiItemR(row, ptr, "frame_property", 0, NULL, 0); + +#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR + uiItemR(row, "stride_length", 0, NULL, 0); +#endif } static void draw_actuator_armature(uiLayout *layout, PointerRNA *ptr) @@ -3599,6 +3624,90 @@ static void draw_actuator_camera(uiLayout *layout, PointerRNA *ptr) static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr) { + uiLayout *row, *subrow, *split; + + uiItemR(layout, ptr, "mode", 0, NULL, 0); + switch (RNA_enum_get(ptr, "mode")) + { + case ACT_CONST_TYPE_LOC: + uiItemR(layout, ptr, "limit", 0, NULL, 0); + + switch(RNA_enum_get(ptr, "limit")){ + case ACT_CONST_LOCX: + row = uiLayoutRow(layout, 1); + uiItemR(row, ptr, "limit_loc_min_x", 0, NULL, 0); + uiItemR(row, ptr, "limit_loc_max_x", 0, NULL, 0); + break; + + case ACT_CONST_LOCY: + row = uiLayoutRow(layout, 1); + uiItemR(row, ptr, "limit_loc_min_y", 0, NULL, 0); + uiItemR(row, ptr, "limit_loc_max_y", 0, NULL, 0); + break; + + case ACT_CONST_LOCZ: + row = uiLayoutRow(layout, 1); + uiItemR(row, ptr, "limit_loc_min_z", 0, NULL, 0); + uiItemR(row, ptr, "limit_loc_max_z", 0, NULL, 0); + break; + } + uiItemR(layout, ptr, "damping", UI_ITEM_R_SLIDER, NULL, 0); + break; + + case ACT_CONST_TYPE_DIST: + uiItemR(layout, ptr, "direction", 0, NULL, 0);//move to the right + if(RNA_enum_get(ptr, "direction")!=0) + uiItemR(layout, ptr, "force_distance", 0, NULL, 0); + + switch(RNA_enum_get(ptr, "direction")){ + case ACT_CONST_DIRPX: + case ACT_CONST_DIRNX: + row = uiLayoutRow(layout, 0); + uiItemR(row, ptr, "range_x", 0, NULL, 0); + subrow = uiLayoutRow(row, 0); + uiLayoutSetActive(subrow, RNA_boolean_get(ptr, "force_distance")==1); + uiItemR(subrow, ptr, "distance_x", 0, NULL, 0); + break; + + case ACT_CONST_DIRPY: + case ACT_CONST_DIRNY: + row = uiLayoutRow(layout, 0); + uiItemR(row, ptr, "range_y", 0, NULL, 0); + subrow = uiLayoutRow(row, 0); + uiLayoutSetActive(subrow, RNA_boolean_get(ptr, "force_distance")==1); + uiItemR(subrow, ptr, "distance_y", 0, NULL, 0); + break; + + case ACT_CONST_DIRPZ: + case ACT_CONST_DIRNZ: + row = uiLayoutRow(layout, 0); + uiItemR(row, ptr, "range_z", 0, NULL, 0); + subrow = uiLayoutRow(row, 0); + uiLayoutSetActive(subrow, RNA_boolean_get(ptr, "force_distance")==1); + uiItemR(subrow, ptr, "distance_z", 0, NULL, 0); + break; + } + uiItemR(layout, ptr, "damping", UI_ITEM_R_SLIDER , NULL, 0); + split = uiLayoutSplit(layout, 0.15, 0); + uiItemR(split, ptr, "detect_material", UI_ITEM_R_TOGGLE, NULL, 0); + + if (RNA_boolean_get(ptr, "detect_material")) + uiItemR(split, ptr, "material", 0, NULL, 0); + else + uiItemR(split, ptr, "property", 0, NULL, 0); + + uiItemR(layout, ptr, "damping_rotation", UI_ITEM_R_SLIDER, NULL, 0); + break; + + case ACT_CONST_TYPE_ORI: + uiItemL(layout, "to be done", 0); + break; + + case ACT_CONST_TYPE_FH: + uiItemL(layout, "to be done", 0); + break; + } + //XXXACTUATOR STILL HAVE TO DO THE RNA } @@ -3951,9 +4060,41 @@ static void draw_actuator_shape_action(uiLayout *layout, PointerRNA *ptr) #endif } -static void draw_actuator_sound(uiLayout *layout, PointerRNA *ptr) +static void draw_actuator_sound(uiLayout *layout, PointerRNA *ptr, bContext *C) { - //XXXACTUATOR + uiLayout *row, *box; + + uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL); + if (!RNA_pointer_get(ptr, "sound").data) + { + uiItemL(layout, "Select a sound from the list or load a new one", 0); + return; + } + uiItemR(layout, ptr, "mode", 0, NULL, 0); + + row = uiLayoutRow(layout, 0); + uiItemR(row, ptr, "volume", 0, NULL, 0); + uiItemR(row, ptr, "pitch", 0, NULL, 0); + + uiItemR(layout, ptr, "enable_sound_3d", UI_ITEM_R_TOGGLE, NULL, 0); + box = uiLayoutBox(layout); + uiLayoutSetActive(box, RNA_boolean_get(ptr, "enable_sound_3d")==1); + + row = uiLayoutRow(box, 0); + uiItemR(row, ptr, "minimum_gain_3d", 0, NULL, 0); + uiItemR(row, ptr, "maximum_gain_3d", 0, NULL, 0); + + row = uiLayoutRow(box, 0); + uiItemR(row, ptr, "reference_distance_3d", 0, NULL, 0); + uiItemR(row, ptr, "max_distance_3d", 0, NULL, 0); + + row = uiLayoutRow(box, 0); + uiItemR(row, ptr, "rolloff_factor_3d", 0, NULL, 0); + uiItemR(row, ptr, "cone_outer_gain_3d", 0, NULL, 0); + + row = uiLayoutRow(box, 0); + uiItemR(row, ptr, "cone_outer_angle_3d", 0, NULL, 0); + uiItemR(row, ptr, "cone_inner_angle_3d", 0, NULL, 0); } static void draw_actuator_state(uiLayout *layout, PointerRNA *ptr) @@ -3971,7 +4112,7 @@ static void draw_actuator_visibility(uiLayout *layout, PointerRNA *ptr) uiItemR(row, ptr, "children", 0, NULL, 0); } -void draw_brick_actuator(uiLayout *layout, PointerRNA *ptr) +void draw_brick_actuator(uiLayout *layout, PointerRNA *ptr, bContext *C) { uiLayout *box; @@ -4027,7 +4168,7 @@ void draw_brick_actuator(uiLayout *layout, PointerRNA *ptr) draw_actuator_shape_action(box, ptr); break; case ACT_SOUND: - draw_actuator_sound(box, ptr); + draw_actuator_sound(box, ptr, C); break; case ACT_STATE: draw_actuator_state(box, ptr); @@ -4287,7 +4428,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) draw_actuator_header(col, &ptr); /* draw the brick contents */ - draw_brick_actuator(col, &ptr); + draw_brick_actuator(col, &ptr, C); } } diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h index e4b17d33dac..923f7f232e0 100644 --- a/source/blender/makesdna/DNA_actuator_types.h +++ b/source/blender/makesdna/DNA_actuator_types.h @@ -351,6 +351,7 @@ typedef struct FreeCamera { #define ACT_PROP_TOGGLE 3 /* constraint flag */ +#define ACT_CONST_NONE 0 #define ACT_CONST_LOCX 1 #define ACT_CONST_LOCY 2 #define ACT_CONST_LOCZ 4 diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 266e912fd52..d99ec78dfb9 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -27,7 +27,7 @@ #include "RNA_define.h" #include "rna_internal.h" - +#include "DNA_object_types.h" #include "DNA_actuator_types.h" #include "DNA_scene_types.h" // for MAXFRAME @@ -54,6 +54,14 @@ EnumPropertyItem actuator_type_items[] ={ {ACT_VISIBILITY, "VISIBILITY", 0, "Visibility", ""}, {0, NULL, 0, NULL, NULL}}; +EnumPropertyItem edit_object_type_items[] ={ + {ACT_EDOB_ADD_OBJECT, "ADDOBJECT", 0, "Add Object", ""}, + {ACT_EDOB_END_OBJECT, "ENDOBJECT", 0, "End Object", ""}, + {ACT_EDOB_REPLACE_MESH, "REPLACEMESH", 0, "Replace Mesh", ""}, + {ACT_EDOB_TRACK_TO, "TRACKTO", 0, "Track to", ""}, + {ACT_EDOB_DYNAMICS, "DYNAMICS", 0, "Dynamics", ""}, + {0, NULL, 0, NULL, NULL} }; + #ifdef RNA_RUNTIME #include "BKE_sca.h" @@ -63,6 +71,8 @@ static StructRNA* rna_Actuator_refine(struct PointerRNA *ptr) bActuator *actuator= (bActuator*)ptr->data; switch(actuator->type) { + case ACT_ACTION: + return &RNA_ActionActuator; case ACT_OBJECT: return &RNA_ObjectActuator; case ACT_IPO: @@ -101,6 +111,18 @@ static StructRNA* rna_Actuator_refine(struct PointerRNA *ptr) return &RNA_Actuator; } } +// +//static StructRNA* rna_ActionActuator_refine(struct PointerRNA *ptr) +//{ +// bActuator *actuator= (bActuator*)ptr->data; +// +// switch(actuator->type) { +// case ACT_ACTION: +// return &RNA_ActionActuator; +// case ACT_SHAPEACTION: +// return &RNA_ShapeActionActuator; +// } +//} static void rna_Actuator_type_update(Main *bmain, Scene *scene, PointerRNA *ptr) { @@ -118,6 +140,64 @@ static void rna_ObjectActuator_integralcoefficient_set(struct PointerRNA *ptr, f oa->forcerot[0] = 60.0f*oa->forcerot[1]; } +static EnumPropertyItem *rna_EditObjectActuator_mode_itemf(bContext *C, PointerRNA *ptr, int *free) +{ + EnumPropertyItem *item= NULL; + Object *ob = (Object *)ptr->id.data; + + int totitem= 0; + if (ob->type!=OB_ARMATURE) + { + RNA_enum_items_add_value(&item, &totitem, edit_object_type_items, ACT_EDOB_REPLACE_MESH); + RNA_enum_items_add_value(&item, &totitem, edit_object_type_items, ACT_EDOB_DYNAMICS); + } + + RNA_enum_items_add_value(&item, &totitem, edit_object_type_items, ACT_EDOB_ADD_OBJECT); + RNA_enum_items_add_value(&item, &totitem, edit_object_type_items, ACT_EDOB_END_OBJECT); + RNA_enum_items_add_value(&item, &totitem, edit_object_type_items, ACT_EDOB_TRACK_TO); + + RNA_enum_item_end(&item, &totitem); + *free= 1; + + return item; +} + +static EnumPropertyItem *rna_Actuator_type_itemf(bContext *C, PointerRNA *ptr, int *free) +{ + EnumPropertyItem *item= NULL; + Object *ob = (Object *)ptr->id.data; + + int totitem= 0; + if (ob->type==OB_ARMATURE) + { + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_ACTION); + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_ARMATURE); + } + else + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_SHAPEACTION); + + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_CAMERA); + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_CONSTRAINT); + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_EDIT_OBJECT); + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_2DFILTER); + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_GAME); + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_IPO); + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_MESSAGE); + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_OBJECT); + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_PARENT); + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_PROPERTY); + + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_RANDOM); + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_SCENE); + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_SOUND); + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_STATE); + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_VISIBILITY); + + RNA_enum_item_end(&item, &totitem); + *free= 1; + + return item; +} #else @@ -136,6 +216,7 @@ void rna_def_actuator(BlenderRNA *brna) prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Actuator_type_itemf"); RNA_def_property_enum_items(prop, actuator_type_items); RNA_def_property_ui_text(prop, "Type", ""); @@ -148,6 +229,87 @@ void rna_def_actuator(BlenderRNA *brna) } +static void rna_def_action_actuator(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem prop_type_items[] ={ + {ACT_ACTION_PLAY, "PLAY", 0, "Play", ""}, + {ACT_ACTION_FLIPPER, "FLIPPER", 0, "Flipper", ""}, + {ACT_ACTION_LOOP_STOP, "LOOPSTOP", 0, "Loop Stop", ""}, + {ACT_ACTION_LOOP_END, "LOOPEND", 0, "Loop End", ""}, + {ACT_ACTION_FROM_PROP, "PROPERTY", 0, "Property", ""}, +#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR + {ACT_ACTION_MOTION, "MOTION", 0, "Displacement", ""}, +#endif + {0, NULL, 0, NULL, NULL}}; + + srna= RNA_def_struct(brna, "ActionActuator", "Actuator"); + RNA_def_struct_ui_text(srna, "Action Actuator", "Actuator to control the object movement"); + RNA_def_struct_sdna_from(srna, "bActionActuator", "data"); +// RNA_def_struct_sdna(srna, "bActionActuator"); +// RNA_def_struct_refine_func(srna, "rna_ActionActuator_refine"); + + prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type"); + RNA_def_property_enum_items(prop, prop_type_items); + RNA_def_property_ui_text(prop, "Action type", "Action playback type"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "act"); + RNA_def_property_struct_type(prop, "Action"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Action", ""); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "continue_last_frame", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "end_reset", 1); + RNA_def_property_ui_text(prop, "Continue", "Restore last frame when switching on/off, otherwise play from the start each time"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "property", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "name"); + RNA_def_property_ui_text(prop, "Property", "Use this property to define the Action position"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "frame_start", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "sta"); + RNA_def_property_range(prop, 0, MAXFRAME); + RNA_def_property_ui_text(prop, "Start frame", ""); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "frame_end", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "end"); + RNA_def_property_range(prop, 0, MAXFRAME); + RNA_def_property_ui_text(prop, "End frame", ""); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "blendin", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 0, 32767); + RNA_def_property_ui_text(prop, "Blendin", "Number of frames of motion blending"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "priority", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "Priority", "Execution priority - lower numbers will override actions with higher numbers. With 2 or more actions at once, the overriding channels must be lower in the stack"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "frame_property", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "frameProp"); + RNA_def_property_ui_text(prop, "Frame Property", "Assign the action's current frame number to this property"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + +#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR + prop= RNA_def_property(srna, "stride_length", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "stridelength"); + RNA_def_property_range(prop, 0.0, 2500.0); + RNA_def_property_ui_text(prop, "Cycle", "Distance covered by a single cycle of the action"); + RNA_def_property_update(prop, NC_LOGIC, NULL); +#endif +} + static void rna_def_object_actuator(BlenderRNA *brna) { StructRNA *srna; @@ -168,7 +330,6 @@ static void rna_def_object_actuator(BlenderRNA *brna) RNA_def_property_enum_items(prop, prop_type_items); RNA_def_property_ui_text(prop, "Motion Type", "Specify the motion system"); RNA_def_property_update(prop, NC_LOGIC, NULL); - // XXX otype = type prop= RNA_def_property(srna, "reference_object", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Object"); @@ -481,7 +642,7 @@ static void rna_def_sound_actuator(BlenderRNA *brna) prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "type"); RNA_def_property_enum_items(prop, prop_type_items); - RNA_def_property_ui_text(prop, "Type", ""); + RNA_def_property_ui_text(prop, "Play Mode", ""); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "volume", PROP_FLOAT, PROP_NONE); @@ -602,7 +763,7 @@ static void rna_def_property_actuator(BlenderRNA *brna) static void rna_def_constraint_actuator(BlenderRNA *brna) { StructRNA *srna; - /*PropertyRNA *prop; + PropertyRNA *prop; static EnumPropertyItem prop_type_items[] ={ {ACT_CONST_TYPE_LOC, "LOC", 0, "Location Constraint", ""}, @@ -610,13 +771,181 @@ static void rna_def_constraint_actuator(BlenderRNA *brna) {ACT_CONST_TYPE_ORI, "ORI", 0, "Orientation Constraint", ""}, {ACT_CONST_TYPE_FH, "FH", 0, "Force Field Constraint", ""}, {0, NULL, 0, NULL, NULL} - };*/ + }; + + static EnumPropertyItem prop_limit_items[] ={ + {ACT_CONST_NONE, "NONE", 0, "None", ""}, + {ACT_CONST_LOCX, "LOCX", 0, "Loc X", ""}, + {ACT_CONST_LOCY, "LOCY", 0, "Loc Y", ""}, + {ACT_CONST_LOCZ, "LOCZ", 0, "Loc Z", ""}, + {0, NULL, 0, NULL, NULL} + }; + + static EnumPropertyItem prop_direction_items[] ={ + {ACT_CONST_NONE, "NONE", 0, "None", ""}, + {ACT_CONST_DIRPX, "DIRPX", 0, "X axis", ""}, + {ACT_CONST_DIRPY, "DIRPY", 0, "Y axis", ""}, + {ACT_CONST_DIRPZ, "DIRPZ", 0, "Z axis", ""}, + {ACT_CONST_DIRNX, "DIRNX", 0, "-X axis", ""}, + {ACT_CONST_DIRNY, "DIRNY", 0, "-Y axis", ""}, + {ACT_CONST_DIRNZ, "DIRNZ", 0, "-Z axis", ""}, + {0, NULL, 0, NULL, NULL} + }; srna= RNA_def_struct(brna, "ConstraintActuator", "Actuator"); - RNA_def_struct_ui_text(srna, "Constraint Actuator", "Actuator to .."); + RNA_def_struct_ui_text(srna, "Constraint Actuator", "Actuator to handle Constraints"); RNA_def_struct_sdna_from(srna, "bConstraintActuator", "data"); - //XXX + prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type"); + RNA_def_property_enum_items(prop, prop_type_items); + RNA_def_property_ui_text(prop, "Constraints Mode", "The type of the constraint"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "limit", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "flag"); + RNA_def_property_enum_items(prop, prop_limit_items); + RNA_def_property_ui_text(prop, "Limit", ""); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "mode"); + RNA_def_property_enum_items(prop, prop_direction_items); + RNA_def_property_ui_text(prop, "Direction", "Set the direction of the ray"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + /* ACT_CONST_TYPE_LOC */ + prop= RNA_def_property(srna, "limit_loc_min_x", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "minloc[0]"); + RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2); + RNA_def_property_ui_text(prop, "Min", ""); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "limit_loc_min_y", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "minloc[1]"); + RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2); + RNA_def_property_ui_text(prop, "Min", ""); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "limit_loc_min_z", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "minloc[2]"); + RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2); + RNA_def_property_ui_text(prop, "Min", ""); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "limit_loc_max_x", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "maxloc[0]"); + RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2); + RNA_def_property_ui_text(prop, "Min", ""); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "limit_loc_max_y", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "maxloc[1]"); + RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2); + RNA_def_property_ui_text(prop, "Min", ""); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "limit_loc_max_z", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "maxloc[2]"); + RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2); + RNA_def_property_ui_text(prop, "Min", ""); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "damping", PROP_INT, PROP_PERCENTAGE); + RNA_def_property_int_sdna(prop, NULL, "damp"); + RNA_def_property_ui_range(prop, 0, 100, 1, 1); + RNA_def_property_ui_text(prop, "Damping", "Damping factor: time constant (in frame) of low pass filter"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + /* ACT_CONST_TYPE_DIST */ + prop= RNA_def_property(srna, "range_x", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "maxloc[0]"); + RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2); + RNA_def_property_ui_text(prop, "Range", ""); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "range_y", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "maxloc[1]"); + RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2); + RNA_def_property_ui_text(prop, "Range", ""); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "range_z", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "maxloc[2]"); + RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2); + RNA_def_property_ui_text(prop, "Range", ""); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "distance_x", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "minloc[0]"); + RNA_def_property_ui_range(prop, 0.f, 2000.f, 1, 2); + RNA_def_property_ui_text(prop, "Distance", "Set the maximum length of ray"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "distance_y", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "minloc[1]"); + RNA_def_property_ui_range(prop, 0.f, 2000.f, 1, 2); + RNA_def_property_ui_text(prop, "Distance", "Set the maximum length of ray"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "distance_z", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "minloc[2]"); + RNA_def_property_ui_range(prop, 0.f, 2000.f, 1, 2); + RNA_def_property_ui_text(prop, "Distance", "Set the maximum length of ray"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + //XXX to use a pointer or add a material lookup + prop= RNA_def_property(srna, "material", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "matprop"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Material", "Ray detects only Objects with this material"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + //XXX add magic property lookup + prop= RNA_def_property(srna, "property", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "matprop"); + RNA_def_property_ui_text(prop, "Property", "Ray detect only Objects with this property"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "time", PROP_INT, PROP_NONE); + RNA_def_property_ui_range(prop, 0, 1000, 1, 2); + RNA_def_property_ui_text(prop, "Time", "Maximum activation time in frame, 0 for unlimited"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "damping_rotation", PROP_INT, PROP_PERCENTAGE); + RNA_def_property_int_sdna(prop, NULL, "rotdamp"); + RNA_def_property_ui_range(prop, 0, 100, 1, 1); + RNA_def_property_ui_text(prop, "rotDamp", "Use a different damping for orientation"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + /* booleans */ + prop= RNA_def_property(srna, "force_distance", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CONST_DISTANCE); + RNA_def_property_ui_text(prop, "Force Distance", "Force distance of object to point of impact of ray"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "local", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CONST_LOCAL); + RNA_def_property_ui_text(prop, "L", "Set ray along object's axis or global axis"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "nomal", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CONST_NORMAL); + RNA_def_property_ui_text(prop, "N", "Set object axis along (local axis) or parallel (global axis) to the normal at hit position"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "persistent", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CONST_PERMANENT); + RNA_def_property_ui_text(prop, "PER", "Persistent actuator: stays active even if ray does not reach target"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + //XXX to use an enum instead of a flag if possible + prop= RNA_def_property(srna, "detect_material", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CONST_MATERIAL); + RNA_def_property_ui_text(prop, "M/P", "Detect material instead of property"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + //XXX to replace all maxloc and minloc by a single one with get/set funcs } static void rna_def_edit_object_actuator(BlenderRNA *brna) @@ -624,19 +953,11 @@ static void rna_def_edit_object_actuator(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem prop_type_items[] ={ - {ACT_EDOB_ADD_OBJECT, "ADDOBJECT", 0, "Add Object", ""}, - {ACT_EDOB_END_OBJECT, "ENDOBJECT", 0, "End Object", ""}, - {ACT_EDOB_REPLACE_MESH, "REPLACEMESH", 0, "Replace Mesh", ""}, - {ACT_EDOB_TRACK_TO, "TRACKTO", 0, "Track to", ""}, - {ACT_EDOB_DYNAMICS, "DYNAMICS", 0, "Dynamics", ""}, - {0, NULL, 0, NULL, NULL} }; - static EnumPropertyItem prop_dyn_items[] ={ {ACT_EDOB_RESTORE_DYN, "RESTOREDYN", 0, "Restore Dynamics", ""}, {ACT_EDOB_SUSPEND_DYN, "SUSPENDDYN", 0, "Suspend Dynamics", ""}, - {ACT_EDOB_ENABLE_RB, "ENABLERIGIDBOBY", 0, "Enable Rigid Body", ""}, - {ACT_EDOB_DISABLE_RB, "DISABLERIGIDBOBY", 0, "Disable Rigid Body", ""}, + {ACT_EDOB_ENABLE_RB, "ENABLERIGIDBODY", 0, "Enable Rigid Body", ""}, + {ACT_EDOB_DISABLE_RB, "DISABLERIGIDBODY", 0, "Disable Rigid Body", ""}, {ACT_EDOB_SET_MASS, "SETMASS", 0, "Set Mass", ""}, {0, NULL, 0, NULL, NULL} }; @@ -646,7 +967,8 @@ static void rna_def_edit_object_actuator(BlenderRNA *brna) prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, prop_type_items); + RNA_def_property_enum_items(prop, edit_object_type_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_EditObjectActuator_mode_itemf"); RNA_def_property_ui_text(prop, "Edit Object", "The mode of the actuator"); RNA_def_property_update(prop, NC_LOGIC, NULL); @@ -1127,9 +1449,11 @@ static void rna_def_shape_action_actuator(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "ShapeActionActuator", "Actuator"); - RNA_def_struct_ui_text(srna, "Shape Action Actuator", "Actuator to .."); + RNA_def_struct_ui_text(srna, "Shape Action Actuator", "Actuator to control shape key animations"); RNA_def_struct_sdna_from(srna, "bActionActuator", "data"); - + //RNA_def_struct_sdna(srna, "bActionActuator"); + //RNA_def_struct_refine_func(srna, "rna_ActionActuator_refine"); + prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "type"); RNA_def_property_enum_items(prop, prop_type_items); @@ -1284,6 +1608,7 @@ void RNA_def_actuator(BlenderRNA *brna) { rna_def_actuator(brna); + rna_def_action_actuator(brna); rna_def_object_actuator(brna); rna_def_ipo_actuator(brna); rna_def_camera_actuator(brna); -- cgit v1.2.3 From bd2f576e0f56f6c9116d6e0318ecfb1ef46a8271 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 6 May 2010 14:43:21 +0000 Subject: rna functions... fcu = action.fcurves.new(data_path, array_index, group) action.fcurves.remove(fcu) --- source/blender/makesrna/intern/rna_action.c | 61 ++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index 127aa191b5c..9b34f8c3278 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -41,6 +41,9 @@ #ifdef RNA_RUNTIME +#include "ED_keyframing.h" +#include "BKE_fcurve.h" + static void rna_ActionGroup_channels_next(CollectionPropertyIterator *iter) { ListBaseIterator *internal= iter->internal; @@ -86,6 +89,32 @@ static void rna_Action_groups_remove(bAction *act, ReportList *reports, bActionG MEM_freeN(agrp); } +static FCurve *rna_Action_fcurve_new(bAction *act, char *data_path, int index, char *group) +{ + if(group && group[0]=='\0') group= NULL; + return verify_fcurve(act, group, data_path, index, 1); +} + +static void rna_Action_fcurve_remove(bAction *act, ReportList *reports, FCurve *fcu) +{ + if(fcu->grp) { + if (BLI_findindex(&act->groups, fcu->grp) == -1) { + BKE_reportf(reports, RPT_ERROR, "FCurve's ActionGroup '%s' not found in action '%s'", fcu->grp->name, act->id.name+2); + return; + } + + action_groups_remove_channel(act, fcu); + } + else { + if(BLI_findindex(&act->curves, fcu) == -1) { + BKE_reportf(reports, RPT_ERROR, "FCurve not found in action '%s'", act->id.name+2); + return; + } + + BLI_remlink(&act->curves, fcu); + free_fcurve(fcu); + } +} #else @@ -291,7 +320,7 @@ static void rna_def_action_groups(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_srna(cprop, "ActionGroups"); srna= RNA_def_struct(brna, "ActionGroups", NULL); RNA_def_struct_sdna(srna, "bAction"); - RNA_def_struct_ui_text(srna, "Action Points", "Collection of action groups"); + RNA_def_struct_ui_text(srna, "Action Groups", "Collection of action groups"); func= RNA_def_function(srna, "add", "rna_Action_groups_add"); RNA_def_function_ui_description(func, "Add a keyframe to the curve."); @@ -309,6 +338,35 @@ static void rna_def_action_groups(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); } +static void rna_def_action_fcurves(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "ActionFCurves"); + srna= RNA_def_struct(brna, "ActionFCurves", NULL); + RNA_def_struct_sdna(srna, "bAction"); + RNA_def_struct_ui_text(srna, "Action FCurves", "Collection of action fcurves"); + + func= RNA_def_function(srna, "new", "rna_Action_fcurve_new"); + RNA_def_function_ui_description(func, "Add a keyframe to the curve."); + parm= RNA_def_string(func, "data_path", "Data Path", 0, "", "FCurve data path to use."); + parm= RNA_def_int(func, "array_index", 0, 0, INT_MAX, "Index", "Array index.", 0, INT_MAX); + parm= RNA_def_string(func, "action_group", "Action Group", 0, "", "Acton group to add this fcurve into."); + + parm= RNA_def_pointer(func, "fcurve", "FCurve", "", "Newly created fcurve"); + RNA_def_function_return(func, parm); + + + func= RNA_def_function(srna, "remove", "rna_Action_fcurve_remove"); + RNA_def_function_ui_description(func, "Remove action group."); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm= RNA_def_pointer(func, "fcurve", "FCurve", "", "FCurve to remove."); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); +} + static void rna_def_action(BlenderRNA *brna) { StructRNA *srna; @@ -323,6 +381,7 @@ static void rna_def_action(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "curves", NULL); RNA_def_property_struct_type(prop, "FCurve"); RNA_def_property_ui_text(prop, "F-Curves", "The individual F-Curves that make up the Action"); + rna_def_action_fcurves(brna, prop); prop= RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "groups", NULL); -- cgit v1.2.3 From 58ca3086d33bb16064b8892e9e6f3172961123d5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 6 May 2010 14:53:27 +0000 Subject: more checks to last commit - dont allow new() to return an existing fcurve. - dont allow creating fcurves with blank paths. --- source/blender/makesrna/intern/rna_action.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index 9b34f8c3278..df0159d22a4 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -89,9 +89,20 @@ static void rna_Action_groups_remove(bAction *act, ReportList *reports, bActionG MEM_freeN(agrp); } -static FCurve *rna_Action_fcurve_new(bAction *act, char *data_path, int index, char *group) +static FCurve *rna_Action_fcurve_new(bAction *act, ReportList *reports, char *data_path, int index, char *group) { if(group && group[0]=='\0') group= NULL; + + if(data_path[0] == '\0') { + BKE_report(reports, RPT_ERROR, "FCurve data path empty, invalid argument"); + return NULL; + } + + /* annoying, check if this exists */ + if(verify_fcurve(act, group, data_path, index, 0)) { + BKE_reportf(reports, RPT_ERROR, "FCurve '%s[%d]' alredy exists in action '%s'", data_path, index, act->id.name+2); + return NULL; + } return verify_fcurve(act, group, data_path, index, 1); } @@ -352,9 +363,10 @@ static void rna_def_action_fcurves(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "new", "rna_Action_fcurve_new"); RNA_def_function_ui_description(func, "Add a keyframe to the curve."); - parm= RNA_def_string(func, "data_path", "Data Path", 0, "", "FCurve data path to use."); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm= RNA_def_string(func, "data_path", "", 0, "Data Path", "FCurve data path to use."); parm= RNA_def_int(func, "array_index", 0, 0, INT_MAX, "Index", "Array index.", 0, INT_MAX); - parm= RNA_def_string(func, "action_group", "Action Group", 0, "", "Acton group to add this fcurve into."); + parm= RNA_def_string(func, "action_group", "", 0, "Action Group", "Acton group to add this fcurve into."); parm= RNA_def_pointer(func, "fcurve", "FCurve", "", "Newly created fcurve"); RNA_def_function_return(func, parm); -- cgit v1.2.3 From 2016bb77b783499977e378f5f8fb36636d9d68fa Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Thu, 6 May 2010 16:06:57 +0000 Subject: Part 1 of making external drop events work. Have to move work to another system, that's why this first step. :) --- source/blender/windowmanager/intern/wm_window.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 150e6db35cb..9bff2af9ac5 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -740,6 +740,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) case GHOST_kEventDraggingDropDone: { wmEvent event= *(win->eventstate); /* copy last state, like mouse coords */ + GHOST_TEventDragnDropData *ddd= GHOST_GetEventData(evt); /* make blender drop event with custom data pointing to wm drags */ event.type= EVT_DROP; @@ -750,8 +751,17 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) /* add drag data to wm for paths: */ /* need icon type, some dropboxes check for that... see filesel code for this */ - // WM_event_start_drag(C, icon, WM_DRAG_PATH, void *poin, 0.0); - /* void poin should point to string, it makes a copy */ + + if(ddd->dataType == GHOST_kDragnDropTypeFilenames) { + GHOST_TStringArray *stra= ddd->data; + int a; + + for(a=0; acount; a++) { + printf("drop file %s\n", stra->strings[a]); + WM_event_start_drag(C, 0, WM_DRAG_PATH, stra->strings[a], 0.0); + /* void poin should point to string, it makes a copy */ + } + } wm_event_add(win, &event); -- cgit v1.2.3 From 0550512388ca3300ecdca888fb1b675e93c79e19 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 6 May 2010 16:37:39 +0000 Subject: make save as copy default for renders, so artists saving with F3 dont end up with many image datablocks pointing to their Desktops --- source/blender/editors/space_image/image_ops.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index d7c33778a8c..1241dbd9f4e 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -964,7 +964,12 @@ static int save_as_invoke(bContext *C, wmOperator *op, wmEvent *event) if(ibuf->name[0]==0) BLI_strncpy(ibuf->name, G.ima, FILE_MAX); - + + /* enable save_copy by default for render results */ + if(ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE) && !RNA_property_is_set(op->ptr, "copy")) { + RNA_boolean_set(op->ptr, "copy", TRUE); + } + // XXX note: we can give default menu enums to operator for this image_filesel(C, op, ibuf->name); -- cgit v1.2.3 From c8a05922882f7638b91ebcb1cd7a4e89cdf16222 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 6 May 2010 17:12:44 +0000 Subject: option to use the linked path or the local path for pointcache. needed for sintels hair to be baked locally. --- release/scripts/ui/properties_object.py | 2 +- release/scripts/ui/properties_physics_common.py | 2 ++ source/blender/blenkernel/intern/pointcache.c | 2 +- source/blender/makesdna/DNA_object_force.h | 2 ++ source/blender/makesrna/intern/rna_object_force.c | 5 +++++ 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/release/scripts/ui/properties_object.py b/release/scripts/ui/properties_object.py index 043a0d2434b..211a7f5c2e9 100644 --- a/release/scripts/ui/properties_object.py +++ b/release/scripts/ui/properties_object.py @@ -156,7 +156,7 @@ class OBJECT_PT_groups(ObjectButtonsPanel): wide_ui = context.region.width > narrowui split = layout.split(percentage=0.8, align=True) - split.operator("object.group_link", text="Link to Group") + split.operator("object.group_link", text="Add to Group") split.operator("object.group_add", text="", icon='ZOOMIN') # XXX, this is bad practice, yes, I wrote it :( - campbell diff --git a/release/scripts/ui/properties_physics_common.py b/release/scripts/ui/properties_physics_common.py index 20073c68989..cad1229a0de 100644 --- a/release/scripts/ui/properties_physics_common.py +++ b/release/scripts/ui/properties_physics_common.py @@ -73,6 +73,8 @@ def point_cache_ui(self, context, cache, enabled, particles, smoke): sub.prop(cache, "disk_cache") col.label(text=cache.info) + sub = col.column() + sub.prop(cache, "use_library_path", "Use Lib Path") layout.separator() diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 25f8dc9bd56..b42ac6fdf49 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1076,7 +1076,7 @@ static int ptcache_path(PTCacheID *pid, char *filename) char file[MAX_PTCACHE_PATH]; /* we dont want the dir, only the file */ char *blendfilename; - blendfilename= (lib)? lib->filename: G.sce; + blendfilename= (lib && (pid->cache->flag & PTCACHE_IGNORE_LIBPATH)==0) ? lib->filename: G.sce; BLI_split_dirfile(blendfilename, NULL, file); i = strlen(file); diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h index ca8b6640226..63a6b8fbe4a 100644 --- a/source/blender/makesdna/DNA_object_force.h +++ b/source/blender/makesdna/DNA_object_force.h @@ -365,6 +365,8 @@ typedef struct SoftBody { #define PTCACHE_FRAMES_SKIPPED 256 #define PTCACHE_EXTERNAL 512 #define PTCACHE_READ_INFO 1024 +/* dont use the filename of the blendfile the data is linked from (write a local cache) */ +#define PTCACHE_IGNORE_LIBPATH 2048 /* PTCACHE_OUTDATED + PTCACHE_FRAMES_SKIPPED */ #define PTCACHE_REDO_NEEDED 258 diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index d7acb427efe..5cb58d50f8f 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -746,6 +746,11 @@ static void rna_def_pointcache(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_EXTERNAL); RNA_def_property_ui_text(prop, "External", "Read cache from an external location"); RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change"); + + prop= RNA_def_property(srna, "use_library_path", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", PTCACHE_IGNORE_LIBPATH); + RNA_def_property_ui_text(prop, "Library Path", "Use this files path when library linked indo another file."); + RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change"); prop= RNA_def_property(srna, "point_cache_list", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_funcs(prop, "rna_Cache_list_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0); -- cgit v1.2.3 From 263cc930061b1926712e4058bc8d04ce7d076681 Mon Sep 17 00:00:00 2001 From: William Reynish Date: Thu, 6 May 2010 17:45:02 +0000 Subject: Make drop images work from external desktop into Blender image window. Still has work todo, like detecting filetype on drop event itself. Ton will continue... --- source/blender/editors/space_image/space_image.c | 2 +- source/blender/windowmanager/intern/wm_window.c | 39 ++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index af35fa4f5a9..3d9f802d0d7 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -537,7 +537,7 @@ void image_keymap(struct wmKeyConfig *keyconf) static int image_drop_poll(bContext *C, wmDrag *drag, wmEvent *event) { if(drag->type==WM_DRAG_PATH) - if(ELEM(drag->icon, ICON_FILE_IMAGE, ICON_FILE_BLANK)) /* rule might not work? */ + if(ELEM3(drag->icon, 0, ICON_FILE_IMAGE, ICON_FILE_BLANK)) /* rule might not work? */ return 1; return 0; } diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 9bff2af9ac5..b4270aa9a94 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -739,15 +739,47 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) } case GHOST_kEventDraggingDropDone: { - wmEvent event= *(win->eventstate); /* copy last state, like mouse coords */ + wmEvent event; GHOST_TEventDragnDropData *ddd= GHOST_GetEventData(evt); + int cx, cy, wx, wy; + + + /* entering window, update mouse pos */ + GHOST_GetCursorPosition(g_system, &wx, &wy); + + GHOST_ScreenToClient(win->ghostwin, wx, wy, &cx, &cy); + win->eventstate->x= cx; + +#if defined(__APPLE__) && defined(GHOST_COCOA) + //Cocoa already uses coordinates with y=0 at bottom + win->eventstate->y= cy; +#else + win->eventstate->y= (win->sizey-1) - cy; +#endif + + event= *(win->eventstate); /* copy last state, like mouse coords */ + + // activate region + event.type= MOUSEMOVE; + event.prevx= event.x; + event.prevy= event.y; + + wm->winactive= win; /* no context change! c->wm->windrawable is drawable, or for area queues */ + win->active= 1; + + wm_event_add(win, &event); + /* make blender drop event with custom data pointing to wm drags */ event.type= EVT_DROP; + event.val= KM_RELEASE; event.custom= EVT_DATA_LISTBASE; event.customdata= &wm->drags; + event.customdatafree= 1; + + wm_event_add(win, &event); - printf("Drop detected\n"); + /* printf("Drop detected\n"); */ /* add drag data to wm for paths: */ /* need icon type, some dropboxes check for that... see filesel code for this */ @@ -760,10 +792,11 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) printf("drop file %s\n", stra->strings[a]); WM_event_start_drag(C, 0, WM_DRAG_PATH, stra->strings[a], 0.0); /* void poin should point to string, it makes a copy */ + break; // only one drop element supported now } } - wm_event_add(win, &event); + break; } -- cgit v1.2.3 From 294e82446a64eb497fd725c84269bccb0510ad86 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 6 May 2010 18:11:01 +0000 Subject: own restrict-render commit broke hide unselected. --- source/blender/editors/object/object_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 662ea4c200c..98a68edae89 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -317,7 +317,7 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "OBJECT_OT_restrictview_clear", HKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_restrictview_set", HKEY, KM_PRESS, 0, 0); - RNA_boolean_set(WM_keymap_add_item(keymap, "OBJECT_OT_restrictview_set", HKEY, KM_PRESS, KM_SHIFT, KM_CTRL)->ptr, "unselected", 1); + RNA_boolean_set(WM_keymap_add_item(keymap, "OBJECT_OT_restrictview_set", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1); /* same as above but for rendering */ WM_keymap_add_item(keymap, "OBJECT_OT_restrictrender_clear", HKEY, KM_PRESS, KM_ALT|KM_CTRL, 0); -- cgit v1.2.3 From c9ca41c6f1dd4734ea6c7566ebd61f82bd41633f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 6 May 2010 18:25:56 +0000 Subject: dont write blender recent file list or save quit.blend when running in background mode. --- source/blender/windowmanager/intern/wm_files.c | 3 ++- source/blender/windowmanager/intern/wm_init_exit.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 30a37301266..c981836a8ed 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -286,7 +286,8 @@ void WM_read_file(bContext *C, char *name, ReportList *reports) if (retval!=0) { G.relbase_valid = 1; - writeBlog(); + if(!G.background) /* assume automated tasks with background, dont write recent file list */ + writeBlog(); } // XXX undo_editmode_clear(); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index add80e9298c..1726b35b0e4 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -317,8 +317,9 @@ void WM_exit(bContext *C) // if (copybuf) MEM_freeN(copybuf); // if (copybufinfo) MEM_freeN(copybufinfo); - - BKE_undo_save_quit(); // saves quit.blend if global undo is on + if (!G.background) { + BKE_undo_save_quit(); // saves quit.blend if global undo is on + } BKE_reset_undo(); ED_file_exit(); /* for fsmenu */ -- cgit v1.2.3 From 6e3812d7bc645b0731cf17a0d7d82d1bdac7d678 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Thu, 6 May 2010 19:12:08 +0000 Subject: Logic UI: constraint actuator+rna 100% (finally !!!) + other fixes/improvements: - s/c/a type enum update function replaced by set function - rna_Sensor_type_itemf and rna_Actuators_type_itemf implemented (but not working ... it was working yesterday before I updated the set func, so need further investigation). Matt, if you have any clue on that ... Roadmap: i) I definitively gotta unify the maxloc, minloc rna properties. the way it's right now (based on 2.49 makes the layout code really clunky ii) - actuator missing - State Actuator (I'll probably need help on that). iii) - sensor missing - collision and ray (they are partly implemented, but the enums are a mess there). iv) - get/set funcs missing (not many) and default values (not many) v) - have more lookup functions for properties and material (I'll definitively need help on that). Eventually will fix (iii, iv and v) changing bge and dna code and doing a subversion/do_version. --- source/blender/editors/space_logic/logic_window.c | 91 +++++++++++++++-- source/blender/makesrna/intern/rna_actuator.c | 118 +++++++++++++++++----- source/blender/makesrna/intern/rna_controller.c | 12 ++- source/blender/makesrna/intern/rna_sensor.c | 49 ++++++++- 4 files changed, 222 insertions(+), 48 deletions(-) diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 6b24cb06b30..9bc8a944fe1 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -3213,10 +3213,14 @@ static void draw_sensor_actuator(uiLayout *layout, PointerRNA *ptr) static void draw_sensor_armature(uiLayout *layout, PointerRNA *ptr) { - uiItemR(layout, ptr, "armature_type", 0, NULL, 0); - uiItemR(layout, ptr, "channel_name", 0, NULL, 0); - uiItemR(layout, ptr, "constraint_name", 0, NULL, 0); - uiItemR(layout, ptr, "value", 0, NULL, 0); + uiLayout *row; + row = uiLayoutRow(layout, 1); + uiItemR(row, ptr, "channel_name", 0, NULL, 0); + uiItemR(row, ptr, "constraint_name", 0, NULL, 0); + + row = uiLayoutRow(layout, 1); + uiItemR(row, ptr, "test_type", 0, NULL, 0); + uiItemR(row, ptr, "value", 0, NULL, 0); } static void draw_sensor_collision(uiLayout *layout, PointerRNA *ptr) @@ -3688,27 +3692,94 @@ static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr) break; } uiItemR(layout, ptr, "damping", UI_ITEM_R_SLIDER , NULL, 0); + split = uiLayoutSplit(layout, 0.15, 0); uiItemR(split, ptr, "detect_material", UI_ITEM_R_TOGGLE, NULL, 0); - if (RNA_boolean_get(ptr, "detect_material")) uiItemR(split, ptr, "material", 0, NULL, 0); else uiItemR(split, ptr, "property", 0, NULL, 0); - uiItemR(layout, ptr, "damping_rotation", UI_ITEM_R_SLIDER, NULL, 0); + split = uiLayoutSplit(layout, 0.15, 0); + uiItemR(split, ptr, "persistent", UI_ITEM_R_TOGGLE, NULL, 0); + + row = uiLayoutRow(split, 1); + uiItemR(row, ptr, "time", 0, NULL, 0); + uiItemR(row, ptr, "damping_rotation", UI_ITEM_R_SLIDER, NULL, 0); break; case ACT_CONST_TYPE_ORI: - uiItemL(layout, "to be done", 0); + uiItemR(layout, ptr, "direction_axis", 0, NULL, 0); + + row=uiLayoutRow(layout, 1); + uiItemR(row, ptr, "damping", UI_ITEM_R_SLIDER , NULL, 0); + uiItemR(row, ptr, "time", 0, NULL, 0); + + row=uiLayoutRow(layout, 0); + uiItemR(row, ptr, "max_rotation", 0, NULL, 0); + + row=uiLayoutRow(layout, 1); + uiItemR(row, ptr, "min_angle", 0, NULL, 0); + uiItemR(row, ptr, "max_angle", 0, NULL, 0); break; case ACT_CONST_TYPE_FH: - uiItemL(layout, "to be done", 0); + split=uiLayoutSplit(layout, 0.75, 0); + row= uiLayoutRow(split, 0); + uiItemR(row, ptr, "fh_damping", UI_ITEM_R_SLIDER , NULL, 0); + switch(RNA_enum_get(ptr, "direction_axis")){ + case ACT_CONST_DIRPX: + case ACT_CONST_DIRNX: + uiItemR(row, ptr, "fh_height_x", 0, NULL, 0); + uiItemR(split, ptr, "fh_paralel_axis", UI_ITEM_R_TOGGLE , NULL, 0); + + row = uiLayoutRow(layout, 0); + uiItemR(row, ptr, "direction_axis", 0, NULL, 0); + split = uiLayoutSplit(row, 0.9, 0); + uiItemR(split, ptr, "spring_x", 0, NULL, 0); + uiItemR(split, ptr, "fh_normal", UI_ITEM_R_TOGGLE , NULL, 0); + break; + + case ACT_CONST_DIRPY: + case ACT_CONST_DIRNY: + uiItemR(row, ptr, "fh_height_y", 0, NULL, 0); + uiItemR(split, ptr, "fh_paralel_axis", UI_ITEM_R_TOGGLE , NULL, 0); + + row = uiLayoutRow(layout, 0); + uiItemR(row, ptr, "direction_axis", 0, NULL, 0); + split = uiLayoutSplit(row, 0.9, 0); + uiItemR(split, ptr, "spring_y", 0, NULL, 0); + uiItemR(split, ptr, "fh_normal", UI_ITEM_R_TOGGLE , NULL, 0); + + default: //ACT_CONST_DIRPZ|ACT_CONST_DIRPZ|ACT_CONST_NONE + uiItemR(row, ptr, "fh_height_z", 0, NULL, 0); + uiItemR(split, ptr, "fh_paralel_axis", UI_ITEM_R_TOGGLE , NULL, 0); + + row = uiLayoutRow(layout, 0); + uiItemR(row, ptr, "direction_axis", 0, NULL, 0); + split = uiLayoutSplit(row, 0.9, 0); + uiItemR(split, ptr, "spring_z", 0, NULL, 0); + uiItemR(split, ptr, "fh_normal", UI_ITEM_R_TOGGLE , NULL, 0); + break; + } + + split = uiLayoutSplit(layout, 0.15, 0); + uiItemR(split, ptr, "detect_material", UI_ITEM_R_TOGGLE, NULL, 0); + if (RNA_boolean_get(ptr, "detect_material")) + uiItemR(split, ptr, "material", 0, NULL, 0); + else + uiItemR(split, ptr, "property", 0, NULL, 0); + + split = uiLayoutSplit(layout, 0.15, 0); + uiItemR(split, ptr, "persistent", UI_ITEM_R_TOGGLE, NULL, 0); + + row = uiLayoutRow(split, 0); + uiItemR(row, ptr, "time", 0, NULL, 0); + uiItemR(row, ptr, "damping_rotation", UI_ITEM_R_SLIDER, NULL, 0); break; } - - //XXXACTUATOR STILL HAVE TO DO THE RNA + //XXXACTUATOR to do: to replace all maxloc and minloc by a single one with get/set funcs + //i.e. remove the switch direction, mode and axis_direction } static void draw_actuator_edit_object(uiLayout *layout, PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index d99ec78dfb9..ab2999129c0 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -111,24 +111,15 @@ static StructRNA* rna_Actuator_refine(struct PointerRNA *ptr) return &RNA_Actuator; } } -// -//static StructRNA* rna_ActionActuator_refine(struct PointerRNA *ptr) -//{ -// bActuator *actuator= (bActuator*)ptr->data; -// -// switch(actuator->type) { -// case ACT_ACTION: -// return &RNA_ActionActuator; -// case ACT_SHAPEACTION: -// return &RNA_ShapeActionActuator; -// } -//} - -static void rna_Actuator_type_update(Main *bmain, Scene *scene, PointerRNA *ptr) + +static void rna_Actuator_type_set(struct PointerRNA *ptr, int value) { bActuator *act= (bActuator *)ptr->data; - - init_actuator(act); + if (value != act->type) + { + act->type = value; + init_actuator(act); + } } static void rna_ObjectActuator_integralcoefficient_set(struct PointerRNA *ptr, float value) @@ -186,7 +177,6 @@ static EnumPropertyItem *rna_Actuator_type_itemf(bContext *C, PointerRNA *ptr, i RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_OBJECT); RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_PARENT); RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_PROPERTY); - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_RANDOM); RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_SCENE); RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_SOUND); @@ -216,17 +206,14 @@ void rna_def_actuator(BlenderRNA *brna) prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Actuator_type_itemf"); RNA_def_property_enum_items(prop, actuator_type_items); + RNA_def_property_enum_funcs(prop, NULL, "rna_Actuator_type_set", "rna_Actuator_type_itemf"); RNA_def_property_ui_text(prop, "Type", ""); - RNA_def_property_update(prop, 0, "rna_Actuator_type_update"); - prop= RNA_def_property(srna, "expanded", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_SHOW); RNA_def_property_ui_text(prop, "Expanded", "Set actuator expanded in the user interface"); RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); - } static void rna_def_action_actuator(BlenderRNA *brna) @@ -248,8 +235,6 @@ static void rna_def_action_actuator(BlenderRNA *brna) srna= RNA_def_struct(brna, "ActionActuator", "Actuator"); RNA_def_struct_ui_text(srna, "Action Actuator", "Actuator to control the object movement"); RNA_def_struct_sdna_from(srna, "bActionActuator", "data"); -// RNA_def_struct_sdna(srna, "bActionActuator"); -// RNA_def_struct_refine_func(srna, "rna_ActionActuator_refine"); prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "type"); @@ -372,7 +357,7 @@ static void rna_def_object_actuator(BlenderRNA *brna) prop= RNA_def_property(srna, "force_min_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "drot[0]"); RNA_def_property_ui_range(prop, -100.0, 100.0, 1.0, 0.1); - RNA_def_property_ui_text(prop, "Max", "Set the lower limit for force"); + RNA_def_property_ui_text(prop, "Min", "Set the lower limit for force"); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "force_max_y", PROP_FLOAT, PROP_NONE); @@ -384,7 +369,7 @@ static void rna_def_object_actuator(BlenderRNA *brna) prop= RNA_def_property(srna, "force_min_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "drot[1]"); RNA_def_property_ui_range(prop, -100.0, 100.0, 1.0, 0.1); - RNA_def_property_ui_text(prop, "Max", "Set the lower limit for force"); + RNA_def_property_ui_text(prop, "Min", "Set the lower limit for force"); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "force_max_z", PROP_FLOAT, PROP_NONE); @@ -396,7 +381,7 @@ static void rna_def_object_actuator(BlenderRNA *brna) prop= RNA_def_property(srna, "force_min_z", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "drot[2]"); RNA_def_property_ui_range(prop, -100.0, 100.0, 1.0, 0.1); - RNA_def_property_ui_text(prop, "Max", "Set the lower limit for force"); + RNA_def_property_ui_text(prop, "Min", "Set the lower limit for force"); RNA_def_property_update(prop, NC_LOGIC, NULL); /* floats 3 Arrays*/ @@ -814,6 +799,12 @@ static void rna_def_constraint_actuator(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Direction", "Set the direction of the ray"); RNA_def_property_update(prop, NC_LOGIC, NULL); + prop= RNA_def_property(srna, "direction_axis", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "mode"); + RNA_def_property_enum_items(prop, prop_direction_items); + RNA_def_property_ui_text(prop, "Direction", "Select the axis to be aligned along the reference direction"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + /* ACT_CONST_TYPE_LOC */ prop= RNA_def_property(srna, "limit_loc_min_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "minloc[0]"); @@ -918,6 +909,69 @@ static void rna_def_constraint_actuator(BlenderRNA *brna) RNA_def_property_ui_text(prop, "rotDamp", "Use a different damping for orientation"); RNA_def_property_update(prop, NC_LOGIC, NULL); + /* ACT_CONST_TYPE_ORI */ + prop= RNA_def_property(srna, "max_rotation", PROP_FLOAT, PROP_TRANSLATION); + RNA_def_property_float_sdna(prop, NULL, "maxrot"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_range(prop, -2000.0, 2000.0, 0.1, 0.001); + RNA_def_property_ui_text(prop, "Reference Direction", "Reference Direction"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "min_angle", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "minloc[0]"); + RNA_def_property_ui_range(prop, 0.0, 180.0, 0.1, 0.01); + RNA_def_property_ui_text(prop, "Min Angle", "Minimum angle (in degree) to maintain with target direction. No correction is done if angle with target direction is between min and max"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "max_angle", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "maxloc[0]"); + RNA_def_property_ui_range(prop, 0.0, 180.0, 0.1, 0.01); + RNA_def_property_ui_text(prop, "Max Angle", "Maximum angle (in degree) allowed with target direction. No correction is done if angle with target direction is between min and max"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + /* ACT_CONST_TYPE_FH */ + prop= RNA_def_property(srna, "fh_damping", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "maxrot[0]"); + RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 1); + RNA_def_property_ui_text(prop, "Damping", "Damping factor of the Fh spring force"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "fh_height_x", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "minloc[0]"); + RNA_def_property_ui_range(prop, 0.01, 2000.0, 0.1, 0.01); + RNA_def_property_ui_text(prop, "Distance", "Height of the Fh area"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "fh_height_y", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "minloc[1]"); + RNA_def_property_ui_range(prop, 0.01, 2000.0, 0.1, 0.01); + RNA_def_property_ui_text(prop, "Distance", "Height of the Fh area"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "fh_height_z", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "minloc[2]"); + RNA_def_property_ui_range(prop, 0.01, 2000.0, 0.1, 0.01); + RNA_def_property_ui_text(prop, "Distance", "Height of the Fh area"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "spring_x", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "maxloc[0]"); + RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 0.01); + RNA_def_property_ui_text(prop, "Fh", "Spring force within the Fh area"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "spring_y", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "maxloc[1]"); + RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 0.01); + RNA_def_property_ui_text(prop, "Fh", "Spring force within the Fh area"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "spring_z", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "maxloc[2]"); + RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 0.01); + RNA_def_property_ui_text(prop, "Fh", "Spring force within the Fh area"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + /* booleans */ prop= RNA_def_property(srna, "force_distance", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CONST_DISTANCE); @@ -945,6 +999,16 @@ static void rna_def_constraint_actuator(BlenderRNA *brna) RNA_def_property_ui_text(prop, "M/P", "Detect material instead of property"); RNA_def_property_update(prop, NC_LOGIC, NULL); + prop= RNA_def_property(srna, "fh_paralel_axis", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CONST_DOROTFH); + RNA_def_property_ui_text(prop, "Rot Fh", "Keep object axis parallel to normal"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "fh_normal", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CONST_NORMAL); + RNA_def_property_ui_text(prop, "N", "Add a horizontal spring force on slopes"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + //XXX to replace all maxloc and minloc by a single one with get/set funcs } @@ -1451,8 +1515,6 @@ static void rna_def_shape_action_actuator(BlenderRNA *brna) srna= RNA_def_struct(brna, "ShapeActionActuator", "Actuator"); RNA_def_struct_ui_text(srna, "Shape Action Actuator", "Actuator to control shape key animations"); RNA_def_struct_sdna_from(srna, "bActionActuator", "data"); - //RNA_def_struct_sdna(srna, "bActionActuator"); - //RNA_def_struct_refine_func(srna, "rna_ActionActuator_refine"); prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "type"); diff --git a/source/blender/makesrna/intern/rna_controller.c b/source/blender/makesrna/intern/rna_controller.c index fe68fbc6b7c..3d44730cf76 100644 --- a/source/blender/makesrna/intern/rna_controller.c +++ b/source/blender/makesrna/intern/rna_controller.c @@ -71,11 +71,14 @@ static struct StructRNA* rna_Controller_refine(struct PointerRNA *ptr) } } -static void rna_Controller_type_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Controller_type_set(struct PointerRNA *ptr, int value) { bController *cont= (bController *)ptr->data; - - init_controller(cont); + if (value != cont->type) + { + cont->type = value; + init_controller(cont); + } } #else @@ -102,11 +105,10 @@ void RNA_def_controller(BlenderRNA *brna) prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_enum_funcs(prop, NULL, "rna_Controller_type_set", NULL); RNA_def_property_enum_items(prop, controller_type_items); RNA_def_property_ui_text(prop, "Type", ""); - RNA_def_property_update(prop, 0, "rna_Controller_type_update"); - prop= RNA_def_property(srna, "expanded", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CONT_SHOW); RNA_def_property_ui_text(prop, "Expanded", "Set controller expanded in the user interface"); diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index 93eec4cbbdd..5a52a779aee 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -29,6 +29,7 @@ #include "rna_internal.h" +#include "DNA_object_types.h" #include "DNA_sensor_types.h" EnumPropertyItem sensor_type_items[] ={ @@ -93,11 +94,49 @@ static StructRNA* rna_Sensor_refine(struct PointerRNA *ptr) } } -static void rna_Sensor_type_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Sensor_type_set(struct PointerRNA *ptr, int value) { bSensor *sens= (bSensor *)ptr->data; + if (value != sens->type) + { + sens->type = value; + init_sensor(sens); + } +} + +static EnumPropertyItem *rna_Sensor_type_itemf(bContext *C, PointerRNA *ptr, int *free) +{ + EnumPropertyItem *item= NULL; + Object *ob = (Object *)ptr->id.data; + + int totitem= 0; + + RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_ACTUATOR); + RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_ALWAYS); + + if (ob->type==OB_ARMATURE) + RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_ARMATURE); + else if(ob->type==OB_MESH){ + RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_COLLISION); + RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_TOUCH); + } + + RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_DELAY); + RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_JOYSTICK); + RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_KEYBOARD); + RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_MESSAGE); + RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_MOUSE); + RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_NEAR); + RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_PROPERTY); + RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_RADAR); + RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_RANDOM); + RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_RAY); +// RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_TOUCH); - init_sensor(sens); + RNA_enum_item_end(&item, &totitem); + *free= 1; + + return item; } #else @@ -119,9 +158,9 @@ static void rna_def_sensor(BlenderRNA *brna) prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_enum_items(prop, sensor_type_items); + RNA_def_property_enum_funcs(prop, NULL, "rna_Sensor_type_set", "rna_Sensor_type_itemf"); RNA_def_property_ui_text(prop, "Type", ""); - RNA_def_property_update(prop, 0, "rna_Sensor_type_update"); - + prop= RNA_def_property(srna, "expanded", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_SHOW); RNA_def_property_ui_text(prop, "Expanded", "Set sensor expanded in the user interface"); @@ -322,7 +361,7 @@ static void rna_def_armature_sensor(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Armature Sensor", "Sensor to detect values and changes in values of IK solver"); RNA_def_struct_sdna_from(srna, "bArmatureSensor", "data"); - prop= RNA_def_property(srna, "armature_type", PROP_ENUM, PROP_NONE); + prop= RNA_def_property(srna, "test_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "type"); RNA_def_property_enum_items(prop, prop_type_items); RNA_def_property_ui_text(prop, "Test Type", "Type of value and test"); -- cgit v1.2.3 From 9610515b22dcf0450aca9c3794700380851753a9 Mon Sep 17 00:00:00 2001 From: Joseph Eagar Date: Thu, 6 May 2010 19:54:43 +0000 Subject: keyframe transform, both through dopesheet/action editor and graph editor, works a bit better with handles. handles now follow keyframes properly in frame snap mode, in situations where they would move (but the keyframe would not) in undesirable ways before. also hopefully fixed vector scope crash in image editor. and disabled snapping to seconds (ever); this can be a seperate option, silently switching to second snapping in frame snapping mode is absolutely evil. also, the action editor draws in hundredth of seconds, not seconds, so it didn't even work. Aligorith: I hope this code is ok, if not feel free to rewrite it. --- source/blender/editors/interface/interface_draw.c | 8 +- source/blender/editors/transform/transform.c | 47 +++++++-- source/blender/editors/transform/transform.h | 5 + .../editors/transform/transform_conversions.c | 112 +++++++++++++++------ .../blender/editors/transform/transform_generics.c | 15 ++- 5 files changed, 142 insertions(+), 45 deletions(-) diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index aa111bffaa9..74324a244de 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1088,8 +1088,12 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti glTranslatef(centerx, centery, 0.f); glScalef(diam, diam, 0.f); - glVertexPointer(2, GL_FLOAT, 0, scopes->vecscope); - glDrawArrays(GL_POINTS, 0, scopes->waveform_tot); + + /*apparently this can sometimes be NULL? - joeedh*/ + if (scopes) { + glVertexPointer(2, GL_FLOAT, 0, scopes->vecscope); + glDrawArrays(GL_POINTS, 0, scopes->waveform_tot); + } glDisableClientState(GL_VERTEX_ARRAY); glPopMatrix(); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 7c98ca44fba..7f0bc6627d2 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -202,17 +202,32 @@ void projectIntView(TransInfo *t, float *vec, int *adr) UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr+1); } - else if(ELEM3(t->spacetype, SPACE_IPO, SPACE_NLA, SPACE_ACTION)) { + else if(t->spacetype == SPACE_ACTION) { + SpaceAction *sact = t->sa->spacedata.first; int out[2] = {0, 0}; - UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], out, out+1); + if (sact->flag & SACTION_DRAWTIME) { + //vec[0] = vec[0]/((t->scene->r.frs_sec / t->scene->r.frs_sec_base)); + + UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1); + } else { + UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1); + } + + adr[0]= out[0]; + adr[1]= out[1]; + } + else if(ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) { + int out[2] = {0, 0}; + + UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1); adr[0]= out[0]; adr[1]= out[1]; } else if(t->spacetype==SPACE_SEQ) { /* XXX not tested yet, but should work */ int out[2] = {0, 0}; - UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], out, out+1); + UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1); adr[0]= out[0]; adr[1]= out[1]; } @@ -5285,12 +5300,12 @@ static short getAnimEdit_DrawTime(TransInfo *t) /* This function is used by Animation Editor specific transform functions to do * the Snap Keyframe to Nearest Frame/Marker */ -static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, AnimData *adt, short autosnap) +static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d, AnimData *adt, short autosnap) { /* snap key to nearest frame? */ if (autosnap == SACTSNAP_FRAME) { const Scene *scene= t->scene; - const short doTime= getAnimEdit_DrawTime(t); + const short doTime= 0; //XXX doesn't work - getAnimEdit_DrawTime(t); const double secf= FPS; double val; @@ -5332,6 +5347,14 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, AnimData *adt, sho else *(td->val)= val; } + + if ((td->flag & TD_MOVEHANDLE1) && td2d->h1) { + td2d->h1[0] = td2d->ih1[0] + *td->val - td->ival; + } + + if ((td->flag & TD_MOVEHANDLE2) && td2d->h2) { + td2d->h2[0] = td2d->ih2[0] + *td->val - td->ival; + } } /* ----------------- Translation ----------------------- */ @@ -5394,6 +5417,7 @@ static void headerTimeTranslate(TransInfo *t, char *str) static void applyTimeTranslate(TransInfo *t, float sval) { TransData *td = t->data; + TransData2D *td2d = t->data2d; Scene *scene = t->scene; int i; @@ -5402,16 +5426,18 @@ static void applyTimeTranslate(TransInfo *t, float sval) const short autosnap= getAnimEdit_SnapMode(t); - float deltax, val; + float deltax, val, valprev; /* it doesn't matter whether we apply to t->data or t->data2d, but t->data2d is more convenient */ - for (i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++, td2d++) { /* it is assumed that td->extra is a pointer to the AnimData, * whose active action is where this keyframe comes from * (this is only valid when not in NLA) */ AnimData *adt= (t->spacetype != SPACE_NLA) ? td->extra : NULL; + valprev = *td->val; + /* check if any need to apply nla-mapping */ if (adt && t->spacetype != SPACE_SEQ) { deltax = t->values[0]; @@ -5441,7 +5467,7 @@ static void applyTimeTranslate(TransInfo *t, float sval) } /* apply nearest snapping */ - doAnimEdit_SnapFrame(t, td, adt, autosnap); + doAnimEdit_SnapFrame(t, td, td2d, adt, autosnap); } } @@ -5652,6 +5678,7 @@ static void headerTimeScale(TransInfo *t, char *str) { static void applyTimeScale(TransInfo *t) { Scene *scene = t->scene; TransData *td = t->data; + TransData2D *td2d = t->data2d; int i; const short autosnap= getAnimEdit_SnapMode(t); @@ -5659,7 +5686,7 @@ static void applyTimeScale(TransInfo *t) { const double secf= FPS; - for (i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++, td2d++) { /* it is assumed that td->extra is a pointer to the AnimData, * whose active action is where this keyframe comes from * (this is only valid when not in NLA) @@ -5685,7 +5712,7 @@ static void applyTimeScale(TransInfo *t) { *(td->val) += startx; /* apply nearest snapping */ - doAnimEdit_SnapFrame(t, td, adt, autosnap); + doAnimEdit_SnapFrame(t, td, td2d, adt, autosnap); } } diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index ef13634a6ae..c1e62eb563c 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -151,6 +151,9 @@ typedef struct TransDataExtension { typedef struct TransData2D { float loc[3]; /* Location of data used to transform (x,y,0) */ float *loc2d; /* Pointer to real 2d location of data */ + + float *h1, *h2; /* Pointer to handle locations, if handles aren't being moved independantly*/ + float ih1[2], ih2[2]; } TransData2D; /* we need to store 2 handles for each transdata incase the other handle wasnt selected */ @@ -427,6 +430,8 @@ typedef struct TransInfo { #define TD_NOTIMESNAP (1 << 14) /* for Graph Editor autosnap, indicates that point should not undergo autosnapping */ #define TD_INTVALUES (1 << 15) /* for Graph Editor - curves that can only have int-values need their keyframes tagged with this */ #define TD_MIRROR_EDGE (1 << 16) /* For editmode mirror, clamp to x = 0 */ +#define TD_MOVEHANDLE1 (1 << 17) /* For fcurve handles, move them along with their keyframes */ +#define TD_MOVEHANDLE2 (1 << 18) /* transsnap->status */ #define SNAP_FORCED 1 diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 0e11058a244..3f9b6df0718 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -2972,9 +2972,8 @@ static int count_fcurve_keys(FCurve *fcu, char side, float cfra) bezt->f1 |= SELECT; bezt->f3 |= SELECT; - /* increment by 3, as there are 3 points (3 * x-coordinates) that need transform */ if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) - count += 3; + count += 1; } } @@ -3023,9 +3022,10 @@ static void TimeToTransData(TransData *td, float *time, AnimData *adt) * The 'side' argument is needed for the extend mode. 'B' = both sides, 'R'/'L' mean only data * on the named side are used. */ -static TransData *FCurveToTransData(TransData *td, FCurve *fcu, AnimData *adt, char side, float cfra) +static TransData *ActionFCurveToTransData(TransData *td, TransData2D **td2dv, FCurve *fcu, AnimData *adt, char side, float cfra) { BezTriple *bezt; + TransData2D *td2d = *td2dv; int i; if (fcu == NULL) @@ -3036,19 +3036,24 @@ static TransData *FCurveToTransData(TransData *td, FCurve *fcu, AnimData *adt, c if (BEZSELECTED(bezt)) { /* only add if on the right 'side' of the current frame */ if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) { - /* each control point needs to be added separetely */ - TimeToTransData(td, bezt->vec[0], adt); - td++; - TimeToTransData(td, bezt->vec[1], adt); - td++; - TimeToTransData(td, bezt->vec[2], adt); + /*set flags to move handles as necassary*/ + td->flag |= TD_MOVEHANDLE1|TD_MOVEHANDLE2; + td2d->h1 = bezt->vec[0]; + td2d->h2 = bezt->vec[2]; + + VECCOPY2D(td2d->ih1, td2d->h1); + VECCOPY2D(td2d->ih2, td2d->h2); + td++; + td2d++; } } } + *td2dv = td2d; + return td; } @@ -3116,6 +3121,7 @@ static void createTransActionData(bContext *C, TransInfo *t) { Scene *scene= t->scene; TransData *td = NULL; + TransData2D *td2d = NULL; tGPFtransdata *tfd = NULL; bAnimContext ac; @@ -3179,7 +3185,9 @@ static void createTransActionData(bContext *C, TransInfo *t) t->total= count; t->data= MEM_callocN(t->total*sizeof(TransData), "TransData(Action Editor)"); + t->data2d= MEM_callocN(t->total*sizeof(TransData2D), "transdata2d"); td= t->data; + td2d = t->data2d; if (ac.datatype == ANIMCONT_GPENCIL) { if (t->mode == TFM_TIME_SLIDE) { @@ -3216,7 +3224,7 @@ static void createTransActionData(bContext *C, TransInfo *t) else cfra = (float)CFRA; - td= FCurveToTransData(td, fcu, adt, t->frame_side, cfra); + td= ActionFCurveToTransData(td, &td2d, fcu, adt, t->frame_side, cfra); //} } @@ -3248,8 +3256,11 @@ static void createTransActionData(bContext *C, TransInfo *t) /* Helper function for createTransGraphEditData, which is reponsible for associating * source data with transform data */ -static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt, float *loc, float *cent, short selected, short ishandle, short intvals) +static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt, BezTriple *bezt, int bi, short selected, short ishandle, short intvals) { + float *loc = bezt->vec[bi]; + float *cent = bezt->vec[1]; + /* New location from td gets dumped onto the old-location of td2d, which then * gets copied to the actual data at td2d->loc2d (bezt->vec[n]) * @@ -3280,7 +3291,17 @@ static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt, VECCOPY(td->center, cent); VECCOPY(td->iloc, td->loc); } - + + if (td->flag & TD_MOVEHANDLE1) { + td2d->h1 = bezt->vec[0]; + VECCOPY2D(td2d->ih1, td2d->h1); + } else td2d->h1 = NULL; + + if (td->flag & TD_MOVEHANDLE2) { + td2d->h2 = bezt->vec[2]; + VECCOPY2D(td2d->ih2, td2d->h2); + } else td2d->h2 = NULL; + memset(td->axismtx, 0, sizeof(td->axismtx)); td->axismtx[2][2] = 1.0f; @@ -3300,7 +3321,7 @@ static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt, td->flag |= TD_NOTIMESNAP; if (intvals) td->flag |= TD_INTVALUES; - + unit_m3(td->mtx); unit_m3(td->smtx); } @@ -3362,11 +3383,11 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) /* F-Curve may not have any keyframes */ if (fcu->bezt == NULL) continue; - + /* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse */ for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) { if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) { - if (sipo->around == V3D_LOCAL) { + if (sipo->around == V3D_LOCAL && !ELEM(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE)) { /* for local-pivot we only need to count the number of selected handles only, so that centerpoints don't * don't get moved wrong */ @@ -3376,7 +3397,15 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) } else if (bezt->f2 & SELECT) count++; // TODO: could this cause problems? } - else { + else if (ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE)) { + /* for 'normal' pivots - just include anything that is selected. + this works a bit differently in translation modes */ + if (bezt->f2 & SELECT) count++; + else { + if (bezt->f1 & SELECT) count++; + if (bezt->f3 & SELECT) count++; + } + } else { /* for 'normal' pivots - just include anything that is selected */ if (bezt->f1 & SELECT) count++; if (bezt->f2 & SELECT) count++; @@ -3429,23 +3458,32 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) TransDataCurveHandleFlags *hdata = NULL; short h1=1, h2=1; - /* only include handles if selected, irrespective of the interpolation modes */ - if (bezt->f1 & SELECT) { - hdata = initTransDataCurveHandles(td, bezt); - bezt_to_transdata(td++, td2d++, adt, bezt->vec[0], bezt->vec[1], 1, 1, intvals); - } - else - h1= 0; - if (bezt->f3 & SELECT) { - if (hdata==NULL) + /* only include handles if selected, irrespective of the interpolation modes. + also, only treat handles specially if the center point isn't selected. */ + if (!ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE) || !(bezt->f2 & SELECT)) { + if (bezt->f1 & SELECT) { hdata = initTransDataCurveHandles(td, bezt); - bezt_to_transdata(td++, td2d++, adt, bezt->vec[2], bezt->vec[1], 1, 1, intvals); + bezt_to_transdata(td++, td2d++, adt, bezt, 0, 1, 1, intvals); + } else + h1= 0; + + if (bezt->f3 & SELECT) { + if (hdata==NULL) + hdata = initTransDataCurveHandles(td, bezt); + bezt_to_transdata(td++, td2d++, adt, bezt, 2, 1, 1, intvals); + } else + h2= 0; } - else - h2= 0; - - /* only include main vert if selected */ + if (bezt->f2 & SELECT) { + /*move handles relative to center*/ + if (ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE)) { + if (bezt->f1 & SELECT) td->flag |= TD_MOVEHANDLE1; + if (bezt->f3 & SELECT) td->flag |= TD_MOVEHANDLE2; + } + + /* only include main vert if selected */ + /* if scaling around individuals centers, do not include keyframes */ if (sipo->around != V3D_LOCAL) { /* if handles were not selected, store their selection status */ @@ -3454,7 +3492,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) hdata = initTransDataCurveHandles(td, bezt); } - bezt_to_transdata(td++, td2d++, adt, bezt->vec[1], bezt->vec[1], 1, 0, intvals); + bezt_to_transdata(td++, td2d++, adt, bezt, 1, 1, 0, intvals); } /* special hack (must be done after initTransDataCurveHandles(), as that stores handle settings to restore...): @@ -3700,7 +3738,7 @@ void flushTransGraphData(TransInfo *t) break; } } - + /* we need to unapply the nla-mapping from the time in some situations */ if (adt) td2d->loc2d[0]= BKE_nla_tweakedit_remap(adt, td2d->loc[0], NLATIME_CONVERT_UNMAP); @@ -3712,6 +3750,16 @@ void flushTransGraphData(TransInfo *t) td2d->loc2d[1]= (float)((int)td2d->loc[1]); else td2d->loc2d[1]= td2d->loc[1]; + + if ((td->flag & TD_MOVEHANDLE1) && td2d->h1) { + td2d->h1[0] = td2d->ih1[0] + td->loc[0] - td->iloc[0]; + td2d->h1[1] = td2d->ih1[1] + td->loc[1] - td->iloc[1]; + } + + if ((td->flag & TD_MOVEHANDLE2) && td2d->h2) { + td2d->h2[0] = td2d->ih2[0] + td->loc[0] - td->iloc[0]; + td2d->h2[1] = td2d->ih2[1] + td->loc[1] - td->iloc[1]; + } } } diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 59961f5812c..99793f4010a 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1167,6 +1167,7 @@ static void restoreElement(TransData *td) { if (td->val) { *td->val = td->ival; } + if (td->ext && (td->flag&TD_NO_EXT)==0) { if (td->ext->rot) { VECCOPY(td->ext->rot, td->ext->irot); @@ -1188,11 +1189,23 @@ static void restoreElement(TransData *td) { void restoreTransObjects(TransInfo *t) { TransData *td; - + TransData2D *td2d; + for (td = t->data; td < t->data + t->total; td++) { restoreElement(td); } + for (td2d=t->data2d; t->data2d && td2d < t->data2d + t->total; td2d++) { + if (td2d->h1) { + td2d->h1[0] = td2d->ih1[0]; + td2d->h1[1] = td2d->ih1[1]; + } + if (td2d->h2) { + td2d->h2[0] = td2d->ih2[0]; + td2d->h2[1] = td2d->ih2[1]; + } + } + unit_m3(t->mat); recalcData(t); -- cgit v1.2.3 From 730ca20c6324b0761846fbd623ecd39bc5573412 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 6 May 2010 21:31:16 +0000 Subject: fix for duplicating cloth which could crash on freeing - effector list wasnt NULL'd on copying a particle system - copying an object would initialize the cloth modifier, then copy it, witout freeing its effector weights created in cloth_init(). --- source/blender/blenkernel/intern/object.c | 3 ++- source/blender/modifiers/intern/MOD_cloth.c | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index baa1caee49b..24c23e5ea41 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1140,12 +1140,13 @@ ParticleSystem *copy_particlesystem(ParticleSystem *psys) } BLI_duplicatelist(&psysn->targets, &psys->targets); - + psysn->pathcache= NULL; psysn->childcache= NULL; psysn->edit= NULL; psysn->frand= NULL; psysn->pdd= NULL; + psysn->effectors= NULL; psysn->pathcachebufs.first = psysn->pathcachebufs.last = NULL; psysn->childcachebufs.first = psysn->childcachebufs.last = NULL; diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c index 865157ce585..5050333cd43 100644 --- a/source/blender/modifiers/intern/MOD_cloth.c +++ b/source/blender/modifiers/intern/MOD_cloth.c @@ -123,15 +123,19 @@ static void copyData(ModifierData *md, ModifierData *target) { ClothModifierData *clmd = (ClothModifierData*) md; ClothModifierData *tclmd = (ClothModifierData*) target; - - if(tclmd->sim_parms) + + if(tclmd->sim_parms) { + if(tclmd->sim_parms->effector_weights) + MEM_freeN(tclmd->sim_parms->effector_weights); MEM_freeN(tclmd->sim_parms); + } + if(tclmd->coll_parms) MEM_freeN(tclmd->coll_parms); BKE_ptcache_free_list(&tclmd->ptcaches); tclmd->point_cache = NULL; - + tclmd->sim_parms = MEM_dupallocN(clmd->sim_parms); if(clmd->sim_parms->effector_weights) tclmd->sim_parms->effector_weights = MEM_dupallocN(clmd->sim_parms->effector_weights); -- cgit v1.2.3 From b28c6d3c149295a367bb8e95df2888bb61db99ba Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 6 May 2010 22:07:03 +0000 Subject: bugfix for own error [#22269] object vector operations (position) not working properly after rev. 28471 double checked other get_index callbacks for the same error. --- source/gameengine/Ketsji/KX_GameObject.cpp | 3 --- source/gameengine/Ketsji/KX_ObjectActuator.cpp | 3 --- 2 files changed, 6 deletions(-) diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index e5fb78daceb..11caa9cd4e2 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1355,12 +1355,9 @@ static int mathutils_kxgameob_vector_set(BaseMathObject *bmo, int subtype) static int mathutils_kxgameob_vector_get_index(BaseMathObject *bmo, int subtype, int index) { - float f[4]; /* lazy, avoid repeteing the case statement */ if(!mathutils_kxgameob_vector_get(bmo, subtype)) return 0; - - bmo->data[index]= f[index]; return 1; } diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index 460e4369c5b..dff95551d70 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -430,12 +430,9 @@ static int mathutils_obactu_vector_set(BaseMathObject *bmo, int subtype) static int mathutils_obactu_vector_get_index(BaseMathObject *bmo, int subtype, int index) { - float f[4]; /* lazy, avoid repeteing the case statement */ if(!mathutils_obactu_vector_get(bmo, subtype)) return 0; - - bmo->data[index]= f[index]; return 1; } -- cgit v1.2.3 From 05e2e92611970689cd224715f594b817c69beae0 Mon Sep 17 00:00:00 2001 From: Toni Alatalo Date: Thu, 6 May 2010 23:47:25 +0000 Subject: Add the option to show also the UVs of other selected objects in image space / uv edit. The code was already there, and the option as a rna bool, but no ui to set it. Matt figured that the View menu in image space next to other uv stuff, which only shows when UVs are edited, is the right place. Works so that when entering editmode for an object to edit UVs, when have also other objects selected and this option on, also the UVs of those other objects are shown in the image view. Liquidape asked this on IRC, and we thought the feat doesn't exist, so I looked out of curiosity in the code as was thinking it would be easy to add. Was surprised to find it there already :) First time that did anything with 2.5, was sure fun enough to search thru the code to figure out how things work. Adding this ui thing proved to be exactly as trivial and nice as it should, and the things under the hood seemed nice, yay! --- release/scripts/ui/space_image.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/release/scripts/ui/space_image.py b/release/scripts/ui/space_image.py index dd07f7b66f8..be7370302ec 100644 --- a/release/scripts/ui/space_image.py +++ b/release/scripts/ui/space_image.py @@ -29,7 +29,7 @@ class IMAGE_MT_view(bpy.types.Menu): layout = self.layout sima = context.space_data - # uv = sima.uv_editor + uv = sima.uv_editor toolsettings = context.tool_settings show_uvedit = sima.show_uvedit @@ -42,6 +42,7 @@ class IMAGE_MT_view(bpy.types.Menu): layout.prop(sima, "update_automatically") if show_uvedit: layout.prop(toolsettings, "uv_local_view") # Numpad / + layout.prop(uv, "draw_other_objects") layout.separator() -- cgit v1.2.3 From 97687969266c5df6ec0d797692dd13576db4bf70 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Fri, 7 May 2010 01:30:12 +0000 Subject: Logic UI: State Actuator done :) all actuators are there now. [and stubs update] (it's a small commit, but couldn't help not doing it ;) --- source/blender/editors/space_logic/logic_window.c | 6 +++- source/blender/makesrna/intern/rna_actuator.c | 34 +++++++++++++++++------ source/blenderplayer/bad_level_call_stubs/stubs.c | 1 + 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 9bc8a944fe1..91a0dd9ee4f 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -4170,7 +4170,11 @@ static void draw_actuator_sound(uiLayout *layout, PointerRNA *ptr, bContext *C) static void draw_actuator_state(uiLayout *layout, PointerRNA *ptr) { - //XXXACTUATOR + uiLayout *split; + split = uiLayoutSplit(layout, 0.35, 0); + uiItemR(split, ptr, "operation", 0, NULL, 0); + + uiTemplateLayers(split, ptr, "state", NULL, NULL, 0); } static void draw_actuator_visibility(uiLayout *layout, PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index ab2999129c0..ff735d35ade 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -131,6 +131,27 @@ static void rna_ObjectActuator_integralcoefficient_set(struct PointerRNA *ptr, f oa->forcerot[0] = 60.0f*oa->forcerot[1]; } +static void rna_StateActuator_state_set(PointerRNA *ptr, const int *values) +{ + bActuator *act = (bActuator*)ptr->data; + bStateActuator *sa = act->data; + + int i, tot= 0; + + /* ensure we always have some state selected */ + for(i=0; imask |= (1<mask &= ~(1< Date: Fri, 7 May 2010 02:01:50 +0000 Subject: Added dynamic enum itemf for add sensor/actuator operators --- source/blender/editors/space_logic/logic_ops.c | 6 ++++-- source/blender/editors/space_logic/logic_window.c | 8 +++---- source/blender/makesrna/RNA_enum_types.h | 6 ++---- source/blender/makesrna/intern/rna_actuator.c | 26 +++++++++++++++-------- source/blender/makesrna/intern/rna_sensor.c | 26 +++++++++++++++-------- 5 files changed, 44 insertions(+), 28 deletions(-) diff --git a/source/blender/editors/space_logic/logic_ops.c b/source/blender/editors/space_logic/logic_ops.c index ee65068e537..3b4915692dd 100644 --- a/source/blender/editors/space_logic/logic_ops.c +++ b/source/blender/editors/space_logic/logic_ops.c @@ -289,7 +289,8 @@ void LOGIC_OT_sensor_add(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - prop= RNA_def_enum(ot->srna, "type", sensor_type_items, SENS_ALWAYS, "Type", "Type of sensor to add"); + prop= RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, SENS_ALWAYS, "Type", "Type of sensor to add"); + RNA_def_enum_funcs(prop, rna_Sensor_type_itemf); } /* ************* Add/Remove Controller Operator ************* */ @@ -474,7 +475,8 @@ void LOGIC_OT_actuator_add(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - prop= RNA_def_enum(ot->srna, "type", actuator_type_items, CONT_LOGIC_AND, "Type", "Type of actuator to add"); + prop= RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, CONT_LOGIC_AND, "Type", "Type of actuator to add"); + RNA_def_enum_funcs(prop, rna_Actuator_type_itemf); } void ED_operatortypes_logic(void) diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 91a0dd9ee4f..90f60dfaad9 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -4313,7 +4313,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) { PointerRNA settings_ptr; row = uiLayoutRow(layout, 0); - RNA_pointer_create(NULL, &RNA_GameObjectSettings, ob, &settings_ptr); + RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); uiItemR(row, &logic_ptr, "controllers_show_initial_state", UI_ITEM_R_NO_BG, "", 0); uiTemplateLayers(row, &settings_ptr, "state", &settings_ptr, "used_state", 0); @@ -4346,7 +4346,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) uiItemS(layout); for(cont= ob->controllers.first; cont; cont=cont->next) { - RNA_pointer_create(&ob->id, &RNA_Controller, cont, &ptr); + RNA_pointer_create((ID *)ob, &RNA_Controller, cont, &ptr); if (!(ob->state & cont->state_mask)) continue; @@ -4421,7 +4421,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) uiItemS(layout); for(sens= ob->sensors.first; sens; sens=sens->next) { - RNA_pointer_create(&ob->id, &RNA_Sensor, sens, &ptr); + RNA_pointer_create((ID *)ob, &RNA_Sensor, sens, &ptr); if ((slogic->scaflag & BUTS_SENS_STATE) || (sens->totlinks == 0) || /* always display sensor without links so that is can be edited */ @@ -4480,7 +4480,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) for(act= ob->actuators.first; act; act=act->next) { - RNA_pointer_create(&ob->id, &RNA_Actuator, act, &ptr); + RNA_pointer_create((ID *)ob, &RNA_Actuator, act, &ptr); if ((slogic->scaflag & BUTS_ACT_STATE) || !(act->flag & ACT_LINKED) || /* always display actuators without links so that is can be edited */ diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index fd96d1d41d7..bb0a1ba2c52 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -75,12 +75,8 @@ extern EnumPropertyItem object_type_items[]; extern EnumPropertyItem object_type_curve_items[]; -extern EnumPropertyItem sensor_type_items[]; - extern EnumPropertyItem controller_type_items[]; -extern EnumPropertyItem actuator_type_items[]; - extern EnumPropertyItem space_type_items[]; extern EnumPropertyItem keymap_propvalue_items[]; @@ -97,6 +93,8 @@ extern EnumPropertyItem viewport_shading_items[]; struct bContext; struct PointerRNA; EnumPropertyItem *rna_TransformOrientation_itemf(struct bContext *C, struct PointerRNA *ptr, int *free); +EnumPropertyItem *rna_Sensor_type_itemf(struct bContext *C, struct PointerRNA *ptr, int *free); +EnumPropertyItem *rna_Actuator_type_itemf(struct bContext *C, struct PointerRNA *ptr, int *free); /* Generic functions, return an enum from library data, index is the position * in the linked list can add more for different types as needed */ diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index ff735d35ade..11995264c94 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -174,19 +174,27 @@ static EnumPropertyItem *rna_EditObjectActuator_mode_itemf(bContext *C, PointerR return item; } -static EnumPropertyItem *rna_Actuator_type_itemf(bContext *C, PointerRNA *ptr, int *free) +EnumPropertyItem *rna_Actuator_type_itemf(bContext *C, PointerRNA *ptr, int *free) { EnumPropertyItem *item= NULL; - Object *ob = (Object *)ptr->id.data; - + Object *ob= NULL; int totitem= 0; - if (ob->type==OB_ARMATURE) - { - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_ACTION); - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_ARMATURE); + + if (ptr->type == &RNA_Actuator) { + ob = (Object *)ptr->id.data; + } else { + /* can't use ob from ptr->id.data because that enum is also used by operators */ + ob = CTX_data_active_object(C); + } + + if (ob != NULL) { + if (ob->type==OB_ARMATURE) { + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_ACTION); + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_ARMATURE); + } else { + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_SHAPEACTION); + } } - else - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_SHAPEACTION); RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_CAMERA); RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_CONSTRAINT); diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index 5a52a779aee..c8407dfced2 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -104,23 +104,31 @@ static void rna_Sensor_type_set(struct PointerRNA *ptr, int value) } } -static EnumPropertyItem *rna_Sensor_type_itemf(bContext *C, PointerRNA *ptr, int *free) +EnumPropertyItem *rna_Sensor_type_itemf(bContext *C, PointerRNA *ptr, int *free) { EnumPropertyItem *item= NULL; - Object *ob = (Object *)ptr->id.data; - + Object *ob=NULL; int totitem= 0; + if (ptr->type == &RNA_Sensor) { + ob = (Object *)ptr->id.data; + } else { + /* can't use ob from ptr->id.data because that enum is also used by operators */ + ob = CTX_data_active_object(C); + } + RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_ACTUATOR); RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_ALWAYS); - if (ob->type==OB_ARMATURE) - RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_ARMATURE); - else if(ob->type==OB_MESH){ - RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_COLLISION); - RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_TOUCH); + if (ob != NULL) { + if (ob->type==OB_ARMATURE) { + RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_ARMATURE); + } else if(ob->type==OB_MESH) { + RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_COLLISION); + RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_TOUCH); + } } - + RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_DELAY); RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_JOYSTICK); RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_KEYBOARD); -- cgit v1.2.3 From d559cf97bb4e21c988aa9a7f7acbcfa5277634bd Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Fri, 7 May 2010 02:37:05 +0000 Subject: Logic UI: small fixes: order of sensor type enum + state actuator showing used states now --- source/blender/editors/space_logic/logic_window.c | 6 +++++- source/blender/makesrna/intern/rna_sensor.c | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 90f60dfaad9..b320d5afad1 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -4171,10 +4171,14 @@ static void draw_actuator_sound(uiLayout *layout, PointerRNA *ptr, bContext *C) static void draw_actuator_state(uiLayout *layout, PointerRNA *ptr) { uiLayout *split; + Object *ob = (Object *)ptr->id.data; + PointerRNA settings_ptr; + RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); + split = uiLayoutSplit(layout, 0.35, 0); uiItemR(split, ptr, "operation", 0, NULL, 0); - uiTemplateLayers(split, ptr, "state", NULL, NULL, 0); + uiTemplateLayers(split, ptr, "state", &settings_ptr, "used_state", 0); } static void draw_actuator_visibility(uiLayout *layout, PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index c8407dfced2..a8524a506bc 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -125,7 +125,6 @@ EnumPropertyItem *rna_Sensor_type_itemf(bContext *C, PointerRNA *ptr, int *free) RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_ARMATURE); } else if(ob->type==OB_MESH) { RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_COLLISION); - RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_TOUCH); } } @@ -139,7 +138,12 @@ EnumPropertyItem *rna_Sensor_type_itemf(bContext *C, PointerRNA *ptr, int *free) RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_RADAR); RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_RANDOM); RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_RAY); -// RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_TOUCH); + + if (ob != NULL) { + if(ob->type==OB_MESH) { + RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_TOUCH); + } + } RNA_enum_item_end(&item, &totitem); *free= 1; -- cgit v1.2.3 From 9084df418d1bbd1fd3cf8f1bf118cbef4d50a4c7 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Fri, 7 May 2010 03:44:34 +0000 Subject: Warning cleanup While I was looking in outliner.c, made some changes to let extra passes display there such as environment (commented out before due to a previous limitation). Also changed outliner object visbility/selectability/renderability toggles to use RNA buttons so you can insert keyframes with RMB menu etc. --- source/blender/blenkernel/intern/colortools.c | 6 +- source/blender/editors/animation/keyframing.c | 10 +++- source/blender/editors/interface/interface_draw.c | 2 +- source/blender/editors/object/object_constraint.c | 2 +- source/blender/editors/render/render_shading.c | 2 +- source/blender/editors/space_outliner/outliner.c | 73 +++++++++++++---------- source/blender/makesdna/DNA_scene_types.h | 36 +++++------ source/blender/makesrna/intern/rna_object.c | 3 + source/blender/python/generic/blf_api.c | 1 - 9 files changed, 77 insertions(+), 58 deletions(-) diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 44a52964f2a..66ebac2e25e 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -939,12 +939,12 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) { int x, y, c, n, nl; double div, divl; - float *rf; - unsigned char *rc; + float *rf=NULL; + unsigned char *rc=NULL; unsigned int *bin_r, *bin_g, *bin_b, *bin_lum; int savedlines, saveline; float rgb[3], ycc[3]; - int ycc_mode; + int ycc_mode=-1; if (scopes->ok == 1 ) return; diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 669a1042998..e7689df9535 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1033,9 +1033,13 @@ static int modify_key_op_poll(bContext *C) if (ELEM(NULL, sa, scene)) return 0; - /* if Outliner, only allow in DataBlocks view */ - if (so && (so->outlinevis != SO_DATABLOCKS)) - return 0; + /* if Outliner, don't allow in some views */ + if (so) { + if (ELEM4(so->outlinevis, SO_GROUPS, SO_LIBRARIES, SO_VERSE_SESSION, SO_VERSE_SESSION)) + return 0; + if (ELEM3(so->outlinevis, SO_SEQUENCE, SO_USERDEF, SO_KEYMAP)) + return 0; + } /* TODO: checks for other space types can be added here */ diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 74324a244de..9c5b4febc40 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -969,7 +969,7 @@ float polar_to_y(float center, float diam, float ampli, float angle) void vectorscope_draw_target(float centerx, float centery, float diam, float r, float g, float b) { float y,u,v; - float tangle, tampli; + float tangle=0.f, tampli; float dangle, dampli, dangle2, dampli2; rgb_to_yuv(r,g,b, &y, &u, &v); diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index d9d04cb3247..c52fd151d83 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -496,7 +496,7 @@ static bConstraint *edit_constraint_property_get(bContext *C, wmOperator *op, Ob char constraint_name[32]; int owner = RNA_enum_get(op->ptr, "owner"); bConstraint *con; - ListBase *list; + ListBase *list=NULL; RNA_string_get(op->ptr, "constraint", constraint_name); diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index efd579735e0..45dbb05064c 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -796,7 +796,7 @@ void TEXTURE_OT_slot_move(wmOperatorType *ot) static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *str, int imtype) { - ImBuf *ibuf; + ImBuf *ibuf=NULL; int dx; int retval; diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index d4283b7b6d3..1affa67a5cc 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -27,6 +27,7 @@ * ***** END GPL LICENSE BLOCK ***** */ +#include #include #include #include @@ -433,13 +434,17 @@ static void outliner_sort(SpaceOops *soops, ListBase *lb) static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, TreeElement *parent, short type, short index); +#define LOG2I(x) (int)(log(x)/log(2.0)) static void outliner_add_passes(SpaceOops *soops, TreeElement *tenla, ID *id, SceneRenderLayer *srl) { TreeStoreElem *tselem= TREESTORE(tenla); TreeElement *te; + + /* log stuff is to convert bitflags (powers of 2) to small integers, + * in order to not overflow short tselem->nr */ - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, SCE_PASS_COMBINED); + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_COMBINED)); te->name= "Combined"; te->directdata= &srl->passflag; @@ -447,73 +452,72 @@ static void outliner_add_passes(SpaceOops *soops, TreeElement *tenla, ID *id, Sc if(tselem->flag & TSE_CLOSED) return; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, SCE_PASS_Z); + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_Z)); te->name= "Z"; te->directdata= &srl->passflag; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, SCE_PASS_VECTOR); + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_VECTOR)); te->name= "Vector"; te->directdata= &srl->passflag; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, SCE_PASS_NORMAL); + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_NORMAL)); te->name= "Normal"; te->directdata= &srl->passflag; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, SCE_PASS_UV); + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_UV)); te->name= "UV"; te->directdata= &srl->passflag; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, SCE_PASS_MIST); + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_MIST)); te->name= "Mist"; te->directdata= &srl->passflag; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, SCE_PASS_INDEXOB); + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDEXOB)); te->name= "Index Object"; te->directdata= &srl->passflag; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, SCE_PASS_RGBA); + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_RGBA)); te->name= "Color"; te->directdata= &srl->passflag; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, SCE_PASS_DIFFUSE); + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_DIFFUSE)); te->name= "Diffuse"; te->directdata= &srl->passflag; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, SCE_PASS_SPEC); + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_SPEC)); te->name= "Specular"; te->directdata= &srl->passflag; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, SCE_PASS_SHADOW); + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_SHADOW)); te->name= "Shadow"; te->directdata= &srl->passflag; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, SCE_PASS_AO); + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_AO)); te->name= "AO"; te->directdata= &srl->passflag; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, SCE_PASS_REFLECT); + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_REFLECT)); te->name= "Reflection"; te->directdata= &srl->passflag; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, SCE_PASS_REFRACT); + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_REFRACT)); te->name= "Refraction"; te->directdata= &srl->passflag; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, SCE_PASS_INDIRECT); + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDIRECT)); te->name= "Indirect"; te->directdata= &srl->passflag; - /* TODO SCE_PASS_ENVIRONMENT/EMIT overflow short.. - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, SCE_PASS_ENVIRONMENT); + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_ENVIRONMENT)); te->name= "Environment"; te->directdata= &srl->passflag; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, SCE_PASS_EMIT); + te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_EMIT)); te->name= "Emit"; - te->directdata= &srl->passflag;*/ + te->directdata= &srl->passflag; } +#undef LOG2I /* special handling of hierarchical non-lib data */ static void outliner_add_bone(SpaceOops *soops, ListBase *lb, ID *id, Bone *curBone, @@ -4977,22 +4981,29 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar if(te->ys+2*OL_H >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { /* objects have toggle-able restriction flags */ if(tselem->type==0 && te->idcode==ID_OB) { + PointerRNA ptr; + ob = (Object *)tselem->id; + RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ptr); uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconButBitS(block, ICONTOG, OB_RESTRICT_VIEW, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, &(ob->restrictflag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_VIEW_OFF, + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, + &ptr, "restrict_view", -1, 0, 0, -1, -1, NULL); uiButSetFunc(bt, restrictbutton_view_cb, scene, ob); - bt= uiDefIconButBitS(block, ICONTOG, OB_RESTRICT_SELECT, 0, ICON_RESTRICT_SELECT_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1, &(ob->restrictflag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); + bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_SELECT_OFF, + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1, + &ptr, "restrict_select", -1, 0, 0, -1, -1, NULL); uiButSetFunc(bt, restrictbutton_sel_cb, scene, ob); - bt= uiDefIconButBitS(block, ICONTOG, OB_RESTRICT_RENDER, 0, ICON_RESTRICT_RENDER_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (short)te->ys, 17, OL_H-1, &(ob->restrictflag), 0, 0, 0, 0, "Restrict/Allow renderability"); + bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_RENDER_OFF, + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (short)te->ys, 17, OL_H-1, + &ptr, "restrict_render", -1, 0, 0, -1, -1, NULL); uiButSetFunc(bt, restrictbutton_rend_cb, scene, ob); uiBlockSetEmboss(block, UI_EMBOSS); + } /* scene render layers and passes have toggle-able flags too! */ else if(tselem->type==TSE_R_LAYER) { @@ -5006,16 +5017,18 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar } else if(tselem->type==TSE_R_PASS) { int *layflag= te->directdata; + int passflag= 1<nr; + uiBlockSetEmboss(block, UI_EMBOSSN); - /* NOTE: tselem->nr is short! */ - bt= uiDefIconButBitI(block, ICONTOG, tselem->nr, 0, ICON_CHECKBOX_HLT-1, + + bt= uiDefIconButBitI(block, ICONTOG, passflag, 0, ICON_CHECKBOX_HLT-1, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, layflag, 0, 0, 0, 0, "Render this Pass"); uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); layflag++; /* is lay_xor */ - if(ELEM8(tselem->nr, SCE_PASS_SPEC, SCE_PASS_SHADOW, SCE_PASS_AO, SCE_PASS_REFLECT, SCE_PASS_REFRACT, SCE_PASS_INDIRECT, SCE_PASS_EMIT, SCE_PASS_ENVIRONMENT)) - bt= uiDefIconButBitI(block, TOG, tselem->nr, 0, (*layflag & tselem->nr)?ICON_DOT:ICON_BLANK1, + if(ELEM8(passflag, SCE_PASS_SPEC, SCE_PASS_SHADOW, SCE_PASS_AO, SCE_PASS_REFLECT, SCE_PASS_REFRACT, SCE_PASS_INDIRECT, SCE_PASS_EMIT, SCE_PASS_ENVIRONMENT)) + bt= uiDefIconButBitI(block, TOG, passflag, 0, (*layflag & passflag)?ICON_DOT:ICON_BLANK1, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1, layflag, 0, 0, 0, 0, "Exclude this Pass from Combined"); uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 44cf1398495..8fe48f7d56a 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -179,24 +179,24 @@ typedef struct SceneRenderLayer { #define SCE_LAY_NEG_ZMASK 0x80000 /* srl->passflag */ -#define SCE_PASS_COMBINED 1 -#define SCE_PASS_Z 2 -#define SCE_PASS_RGBA 4 -#define SCE_PASS_DIFFUSE 8 -#define SCE_PASS_SPEC 16 -#define SCE_PASS_SHADOW 32 -#define SCE_PASS_AO 64 -#define SCE_PASS_REFLECT 128 -#define SCE_PASS_NORMAL 256 -#define SCE_PASS_VECTOR 512 -#define SCE_PASS_REFRACT 1024 -#define SCE_PASS_INDEXOB 2048 -#define SCE_PASS_UV 4096 -#define SCE_PASS_INDIRECT 8192 -#define SCE_PASS_MIST 16384 -#define SCE_PASS_RAYHITS 32768 -#define SCE_PASS_EMIT 65536 -#define SCE_PASS_ENVIRONMENT 131072 +#define SCE_PASS_COMBINED (1<<0) +#define SCE_PASS_Z (1<<1) +#define SCE_PASS_RGBA (1<<2) +#define SCE_PASS_DIFFUSE (1<<3) +#define SCE_PASS_SPEC (1<<4) +#define SCE_PASS_SHADOW (1<<5) +#define SCE_PASS_AO (1<<6) +#define SCE_PASS_REFLECT (1<<7) +#define SCE_PASS_NORMAL (1<<8) +#define SCE_PASS_VECTOR (1<<9) +#define SCE_PASS_REFRACT (1<<10) +#define SCE_PASS_INDEXOB (1<<11) +#define SCE_PASS_UV (1<<12) +#define SCE_PASS_INDIRECT (1<<13) +#define SCE_PASS_MIST (1<<14) +#define SCE_PASS_RAYHITS (1<<15) +#define SCE_PASS_EMIT (1<<16) +#define SCE_PASS_ENVIRONMENT (1<<17) /* note, srl->passflag is treestore element 'nr' in outliner, short still... */ diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 23184af93ff..c16110b4c0a 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1781,16 +1781,19 @@ static void rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "restrict_view", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_VIEW); RNA_def_property_ui_text(prop, "Restrict View", "Restrict visibility in the viewport"); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); prop= RNA_def_property(srna, "restrict_select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_SELECT); RNA_def_property_ui_text(prop, "Restrict Select", "Restrict selection in the viewport"); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 1); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); prop= RNA_def_property(srna, "restrict_render", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_RENDER); RNA_def_property_ui_text(prop, "Restrict Render", "Restrict renderability"); + RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); /* anim */ diff --git a/source/blender/python/generic/blf_api.c b/source/blender/python/generic/blf_api.c index 81c7da15438..a16481d760c 100644 --- a/source/blender/python/generic/blf_api.c +++ b/source/blender/python/generic/blf_api.c @@ -346,7 +346,6 @@ static char py_blf_load_doc[] = static PyObject *py_blf_load(PyObject *self, PyObject *args) { - int fontid = 0; char* filename; if (!PyArg_ParseTuple(args, "s:blf.load", &filename)) -- cgit v1.2.3 From 6bc28e97c102e7dce88c0fbe2379e3c7c4f14b4c Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Fri, 7 May 2010 04:52:10 +0000 Subject: Fix [#22271] N panel Lock icons not changing when pressed --- source/blender/editors/space_view3d/view3d_buttons.c | 14 +++++++------- source/blender/makesrna/intern/rna_object.c | 4 ++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index d159dc487a7..c75b785aa11 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -746,7 +746,7 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) uiItemR(colsub, ptr, "location", 0, "Location", 0); colsub = uiLayoutColumn(split, 1); uiItemL(colsub, "", 0); - uiItemR(colsub, ptr, "lock_location", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY, "", ICON_LOCKED); + uiItemR(colsub, ptr, "lock_location", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY, "", 0); split = uiLayoutSplit(layout, 0.8, 0); @@ -757,10 +757,10 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) colsub = uiLayoutColumn(split, 1); uiItemR(colsub, ptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE, "4L", 0); if (RNA_boolean_get(ptr, "lock_rotations_4d")) - uiItemR(colsub, ptr, "lock_rotation_w", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY, "", ICON_LOCKED); + uiItemR(colsub, ptr, "lock_rotation_w", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY, "", 0); else uiItemL(colsub, "", 0); - uiItemR(colsub, ptr, "lock_rotation", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY, "", ICON_LOCKED); + uiItemR(colsub, ptr, "lock_rotation", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY, "", 0); break; case ROT_MODE_AXISANGLE: /* axis angle */ colsub = uiLayoutColumn(split, 1); @@ -768,17 +768,17 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) colsub = uiLayoutColumn(split, 1); uiItemR(colsub, ptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE, "4L", 0); if (RNA_boolean_get(ptr, "lock_rotations_4d")) - uiItemR(colsub, ptr, "lock_rotation_w", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY, "", ICON_LOCKED); + uiItemR(colsub, ptr, "lock_rotation_w", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY, "", 0); else uiItemL(colsub, "", 0); - uiItemR(colsub, ptr, "lock_rotation", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY, "", ICON_LOCKED); + uiItemR(colsub, ptr, "lock_rotation", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY, "", 0); break; default: /* euler rotations */ colsub = uiLayoutColumn(split, 1); uiItemR(colsub, ptr, "rotation_euler", 0, "Rotation", 0); colsub = uiLayoutColumn(split, 1); uiItemL(colsub, "", 0); - uiItemR(colsub, ptr, "lock_rotation", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY, "", ICON_LOCKED); + uiItemR(colsub, ptr, "lock_rotation", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY, "", 0); break; } uiItemR(layout, ptr, "rotation_mode", 0, "", 0); @@ -788,7 +788,7 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) uiItemR(colsub, ptr, "scale", 0, "Scale", 0); colsub = uiLayoutColumn(split, 1); uiItemL(colsub, "", 0); - uiItemR(colsub, ptr, "lock_scale", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY, "", ICON_LOCKED); + uiItemR(colsub, ptr, "lock_scale", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY, "", 0); if (ptr->type == &RNA_Object) { Object *ob = ptr->data; diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index c16110b4c0a..9972fa01a34 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1651,17 +1651,20 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_LOCX); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Lock Location", "Lock editing of location in the interface"); + RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update"); prop= RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_XYZ); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTX); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation in the interface"); + RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update"); // XXX this is sub-optimal - it really should be included above, but due to technical reasons we can't do this! prop= RNA_def_property(srna, "lock_rotation_w", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTW); + RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); RNA_def_property_ui_text(prop, "Lock Rotation (4D Angle)", "Lock editing of 'angle' component of four-component rotations in the interface"); // XXX this needs a better name prop= RNA_def_property(srna, "lock_rotations_4d", PROP_BOOLEAN, PROP_NONE); @@ -1672,6 +1675,7 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_SCALEX); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale in the interface"); + RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update"); /* matrix */ -- cgit v1.2.3 From 27acb95cad777fa3c3cdaba5af6da79dbe438d11 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Fri, 7 May 2010 07:31:39 +0000 Subject: Logic UI: All Sensors, Controllers and Actuators are ported now... (let's the tests begin) * get/set funcs * unifying rna_props for Constraint Actuator * Collision sensor * Ray sensor * State Actuator * We need icons! at least one for Sensor, one for Controller and one for Actuator * Layout artists: Keyboard sensor really need some help :) The other as well. I mainly copied the layout from 2.49 with some adjustments here and there. * some get/set functions in rna_actuator.c are exactly the same (e.g. rna_ConstraintActuator_range_get, rna_ConstraintActuator_spring_get) and other could be easily distributed. maybe something for later. --- source/blender/editors/space_logic/logic_window.c | 165 ++++------- source/blender/makesrna/intern/rna_actuator.c | 318 +++++++++++++++------- source/blender/makesrna/intern/rna_sensor.c | 37 +-- 3 files changed, 282 insertions(+), 238 deletions(-) diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index b320d5afad1..daeb3df908a 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -3225,21 +3225,21 @@ static void draw_sensor_armature(uiLayout *layout, PointerRNA *ptr) static void draw_sensor_collision(uiLayout *layout, PointerRNA *ptr) { - uiItemL(layout, "Not ported back yet", 0); - //XXXSENSOR - /* // need to solve problems in rna_sensor.c - uiItemR(layout, ptr, "pulse", 0, NULL, 0); - uiItemR(layout, ptr, "collision_type", 0, NULL, 0); + uiLayout *row, *split; + + split = uiLayoutSplit(layout, 0.3, 0); + row = uiLayoutRow(split, 1); + uiItemR(row, ptr, "pulse", UI_ITEM_R_TOGGLE, NULL, 0); + uiItemR(row, ptr, "collision_type", UI_ITEM_R_TOGGLE, NULL, 0); switch (RNA_enum_get(ptr, "collision_type")) { case SENS_COLLISION_PROPERTY: - uiItemR(layout, ptr, "property", 0, NULL, 0); + uiItemR(split, ptr, "property", 0, NULL, 0); break; case SENS_COLLISION_MATERIAL: - uiItemR(layout, ptr, "material", 0, NULL, 0); + uiItemR(split, ptr, "material", 0, NULL, 0); break; } - */ } static void draw_sensor_delay(uiLayout *layout, PointerRNA *ptr) @@ -3296,18 +3296,23 @@ static void draw_sensor_joystick(uiLayout *layout, PointerRNA *ptr) static void draw_sensor_keyboard(uiLayout *layout, PointerRNA *ptr) { - uiLayout *row; - + uiLayout *row, *col; + row = uiLayoutRow(layout, 0); uiItemL(row, "Key:", 0); - uiItemR(row, ptr, "key", UI_ITEM_R_EVENT, "", 0); - uiItemR(layout, ptr, "all_keys", 0, NULL, 0); + col = uiLayoutColumn(row, 0); + uiLayoutSetActive(col, RNA_boolean_get(ptr, "all_keys")==0); + uiItemR(col, ptr, "key", UI_ITEM_R_EVENT, "", 0); + col = uiLayoutColumn(row, 0); + uiItemR(col, ptr, "all_keys", UI_ITEM_R_TOGGLE, NULL, 0); - row = uiLayoutRow(layout, 0); + col = uiLayoutColumn(layout, 0); + uiLayoutSetActive(col, RNA_boolean_get(ptr, "all_keys")==0); + row = uiLayoutRow(col, 0); uiItemL(row, "First Modifier:", 0); uiItemR(row, ptr, "modifier_key", UI_ITEM_R_EVENT, "", 0); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(col, 0); uiItemL(row, "Second Modifier:", 0); uiItemR(row, ptr, "second_modifier_key", UI_ITEM_R_EVENT, "", 0); @@ -3378,20 +3383,22 @@ static void draw_sensor_random(uiLayout *layout, PointerRNA *ptr) static void draw_sensor_ray(uiLayout *layout, PointerRNA *ptr) { - uiItemL(layout, "Not ported back yet", 0); - /* - uiItemR(layout, ptr, "ray_type", 0, NULL, 0); + uiLayout *split, *row; + + split= uiLayoutSplit(layout, 0.3, 0); + uiItemR(split, ptr, "ray_type", UI_ITEM_R_TOGGLE, NULL, 0); switch (RNA_enum_get(ptr, "ray_type")) { case SENS_RAY_PROPERTY: - uiItemR(layout, ptr, "property", 0, NULL, 0); break; + uiItemR(split, ptr, "property", 0, NULL, 0); break; case SENS_RAY_MATERIAL: - uiItemR(layout, ptr, "material", 0, NULL, 0); break; + uiItemR(split, ptr, "material", 0, NULL, 0); break; } - uiItemR(layout, ptr, "x_ray_mode", 0, NULL, 0); - uiItemR(layout, ptr, "range", 0, NULL, 0); - uiItemR(layout, ptr, "axis", 0, NULL, 0); - */ - //XXXSENSOR - same problem as collision. enums badly used by UI code + + split= uiLayoutSplit(layout, 0.3, 0); + uiItemR(split, ptr, "x_ray_mode", UI_ITEM_R_TOGGLE, NULL, 0); + row= uiLayoutRow(split, 0); + uiItemR(row, ptr, "range", 0, NULL, 0); + uiItemR(row, ptr, "axis", 0, NULL, 0); } static void draw_sensor_touch(uiLayout *layout, PointerRNA *ptr) @@ -3636,25 +3643,10 @@ static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr) case ACT_CONST_TYPE_LOC: uiItemR(layout, ptr, "limit", 0, NULL, 0); - switch(RNA_enum_get(ptr, "limit")){ - case ACT_CONST_LOCX: - row = uiLayoutRow(layout, 1); - uiItemR(row, ptr, "limit_loc_min_x", 0, NULL, 0); - uiItemR(row, ptr, "limit_loc_max_x", 0, NULL, 0); - break; - - case ACT_CONST_LOCY: - row = uiLayoutRow(layout, 1); - uiItemR(row, ptr, "limit_loc_min_y", 0, NULL, 0); - uiItemR(row, ptr, "limit_loc_max_y", 0, NULL, 0); - break; + row = uiLayoutRow(layout, 1); + uiItemR(row, ptr, "limit_min", 0, NULL, 0); + uiItemR(row, ptr, "limit_max", 0, NULL, 0); - case ACT_CONST_LOCZ: - row = uiLayoutRow(layout, 1); - uiItemR(row, ptr, "limit_loc_min_z", 0, NULL, 0); - uiItemR(row, ptr, "limit_loc_max_z", 0, NULL, 0); - break; - } uiItemR(layout, ptr, "damping", UI_ITEM_R_SLIDER, NULL, 0); break; @@ -3663,34 +3655,12 @@ static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr) if(RNA_enum_get(ptr, "direction")!=0) uiItemR(layout, ptr, "force_distance", 0, NULL, 0); - switch(RNA_enum_get(ptr, "direction")){ - case ACT_CONST_DIRPX: - case ACT_CONST_DIRNX: - row = uiLayoutRow(layout, 0); - uiItemR(row, ptr, "range_x", 0, NULL, 0); - subrow = uiLayoutRow(row, 0); - uiLayoutSetActive(subrow, RNA_boolean_get(ptr, "force_distance")==1); - uiItemR(subrow, ptr, "distance_x", 0, NULL, 0); - break; - - case ACT_CONST_DIRPY: - case ACT_CONST_DIRNY: - row = uiLayoutRow(layout, 0); - uiItemR(row, ptr, "range_y", 0, NULL, 0); - subrow = uiLayoutRow(row, 0); - uiLayoutSetActive(subrow, RNA_boolean_get(ptr, "force_distance")==1); - uiItemR(subrow, ptr, "distance_y", 0, NULL, 0); - break; + row = uiLayoutRow(layout, 0); + uiItemR(row, ptr, "range", 0, NULL, 0); + subrow = uiLayoutRow(row, 0); + uiLayoutSetActive(subrow, RNA_boolean_get(ptr, "force_distance")==1); + uiItemR(subrow, ptr, "distance", 0, NULL, 0); - case ACT_CONST_DIRPZ: - case ACT_CONST_DIRNZ: - row = uiLayoutRow(layout, 0); - uiItemR(row, ptr, "range_z", 0, NULL, 0); - subrow = uiLayoutRow(row, 0); - uiLayoutSetActive(subrow, RNA_boolean_get(ptr, "force_distance")==1); - uiItemR(subrow, ptr, "distance_z", 0, NULL, 0); - break; - } uiItemR(layout, ptr, "damping", UI_ITEM_R_SLIDER , NULL, 0); split = uiLayoutSplit(layout, 0.15, 0); @@ -3727,41 +3697,15 @@ static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr) split=uiLayoutSplit(layout, 0.75, 0); row= uiLayoutRow(split, 0); uiItemR(row, ptr, "fh_damping", UI_ITEM_R_SLIDER , NULL, 0); - switch(RNA_enum_get(ptr, "direction_axis")){ - case ACT_CONST_DIRPX: - case ACT_CONST_DIRNX: - uiItemR(row, ptr, "fh_height_x", 0, NULL, 0); - uiItemR(split, ptr, "fh_paralel_axis", UI_ITEM_R_TOGGLE , NULL, 0); - - row = uiLayoutRow(layout, 0); - uiItemR(row, ptr, "direction_axis", 0, NULL, 0); - split = uiLayoutSplit(row, 0.9, 0); - uiItemR(split, ptr, "spring_x", 0, NULL, 0); - uiItemR(split, ptr, "fh_normal", UI_ITEM_R_TOGGLE , NULL, 0); - break; - case ACT_CONST_DIRPY: - case ACT_CONST_DIRNY: - uiItemR(row, ptr, "fh_height_y", 0, NULL, 0); - uiItemR(split, ptr, "fh_paralel_axis", UI_ITEM_R_TOGGLE , NULL, 0); - - row = uiLayoutRow(layout, 0); - uiItemR(row, ptr, "direction_axis", 0, NULL, 0); - split = uiLayoutSplit(row, 0.9, 0); - uiItemR(split, ptr, "spring_y", 0, NULL, 0); - uiItemR(split, ptr, "fh_normal", UI_ITEM_R_TOGGLE , NULL, 0); - - default: //ACT_CONST_DIRPZ|ACT_CONST_DIRPZ|ACT_CONST_NONE - uiItemR(row, ptr, "fh_height_z", 0, NULL, 0); - uiItemR(split, ptr, "fh_paralel_axis", UI_ITEM_R_TOGGLE , NULL, 0); - - row = uiLayoutRow(layout, 0); - uiItemR(row, ptr, "direction_axis", 0, NULL, 0); - split = uiLayoutSplit(row, 0.9, 0); - uiItemR(split, ptr, "spring_z", 0, NULL, 0); - uiItemR(split, ptr, "fh_normal", UI_ITEM_R_TOGGLE , NULL, 0); - break; - } + uiItemR(row, ptr, "fh_height", 0, NULL, 0); + uiItemR(split, ptr, "fh_paralel_axis", UI_ITEM_R_TOGGLE , NULL, 0); + + row = uiLayoutRow(layout, 0); + uiItemR(row, ptr, "direction_axis", 0, NULL, 0); + split = uiLayoutSplit(row, 0.9, 0); + uiItemR(split, ptr, "spring", 0, NULL, 0); + uiItemR(split, ptr, "fh_normal", UI_ITEM_R_TOGGLE , NULL, 0); split = uiLayoutSplit(layout, 0.15, 0); uiItemR(split, ptr, "detect_material", UI_ITEM_R_TOGGLE, NULL, 0); @@ -3778,8 +3722,6 @@ static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr) uiItemR(row, ptr, "damping_rotation", UI_ITEM_R_SLIDER, NULL, 0); break; } - //XXXACTUATOR to do: to replace all maxloc and minloc by a single one with get/set funcs - //i.e. remove the switch direction, mode and axis_direction } static void draw_actuator_edit_object(uiLayout *layout, PointerRNA *ptr) @@ -3859,16 +3801,17 @@ static void draw_actuator_game(uiLayout *layout, PointerRNA *ptr) static void draw_actuator_ipo(uiLayout *layout, PointerRNA *ptr) { - uiLayout *row, *col; + uiLayout *row, *subrow, *col; row= uiLayoutRow(layout, 0); uiItemR(row, ptr, "play_type", 0, NULL, 0); - uiItemR(row, ptr, "force", 0, NULL, 0); - uiItemR(row, ptr, "add", 0, NULL, 0); + subrow= uiLayoutRow(row, 1); + uiItemR(subrow, ptr, "force", UI_ITEM_R_TOGGLE, NULL, 0); + uiItemR(subrow, ptr, "add", UI_ITEM_R_TOGGLE, NULL, 0); - col = uiLayoutColumn(row, 0); - uiLayoutSetActive(col, RNA_boolean_get(ptr, "add")); - uiItemR(col, ptr, "local", 0, NULL, 0); + col = uiLayoutColumn(subrow, 0); + uiLayoutSetActive(col, (RNA_boolean_get(ptr, "add") || RNA_boolean_get(ptr, "force"))); + uiItemR(col, ptr, "local", UI_ITEM_R_TOGGLE, NULL, 0); row= uiLayoutRow(layout, 0); if((RNA_enum_get(ptr, "play_type") == ACT_IPO_FROM_PROP)) diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 11995264c94..9c5476b08d9 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -122,6 +122,198 @@ static void rna_Actuator_type_set(struct PointerRNA *ptr, int value) } } +static float rna_ConstraintActuator_limitmin_get(struct PointerRNA *ptr) +{ + bActuator *act = (bActuator*)ptr->data; + bConstraintActuator *ca = act->data; + float *fp; + + if(ca->flag & ACT_CONST_LOCX) fp= ca->minloc; + else if(ca->flag & ACT_CONST_LOCY) fp= ca->minloc+1; + else if(ca->flag & ACT_CONST_LOCZ) fp= ca->minloc+2; + else if(ca->flag & ACT_CONST_ROTX) fp= ca->minrot; + else if(ca->flag & ACT_CONST_ROTY) fp= ca->minrot+1; + else fp= ca->minrot+2; + + return *fp; +} + +static void rna_ConstraintActuator_limitmin_set(struct PointerRNA *ptr, float value) +{ + bActuator *act = (bActuator*)ptr->data; + bConstraintActuator *ca = act->data; + float *fp; + + if(ca->flag & ACT_CONST_LOCX) fp= ca->minloc; + else if(ca->flag & ACT_CONST_LOCY) fp= ca->minloc+1; + else if(ca->flag & ACT_CONST_LOCZ) fp= ca->minloc+2; + else if(ca->flag & ACT_CONST_ROTX) fp= ca->minrot; + else if(ca->flag & ACT_CONST_ROTY) fp= ca->minrot+1; + else fp= ca->minrot+2; + + *fp = value; +} + +static float rna_ConstraintActuator_limitmax_get(struct PointerRNA *ptr) +{ + bActuator *act = (bActuator*)ptr->data; + bConstraintActuator *ca = act->data; + float *fp; + + if(ca->flag & ACT_CONST_LOCX) fp= ca->maxloc; + else if(ca->flag & ACT_CONST_LOCY) fp= ca->maxloc+1; + else if(ca->flag & ACT_CONST_LOCZ) fp= ca->maxloc+2; + else if(ca->flag & ACT_CONST_ROTX) fp= ca->maxrot; + else if(ca->flag & ACT_CONST_ROTY) fp= ca->maxrot+1; + else fp= ca->maxrot+2; + + return *fp; +} + +static void rna_ConstraintActuator_limitmax_set(struct PointerRNA *ptr, float value) +{ + bActuator *act = (bActuator*)ptr->data; + bConstraintActuator *ca = act->data; + float *fp; + + if(ca->flag & ACT_CONST_LOCX) fp= ca->maxloc; + else if(ca->flag & ACT_CONST_LOCY) fp= ca->maxloc+1; + else if(ca->flag & ACT_CONST_LOCZ) fp= ca->maxloc+2; + else if(ca->flag & ACT_CONST_ROTX) fp= ca->maxrot; + else if(ca->flag & ACT_CONST_ROTY) fp= ca->maxrot+1; + else fp= ca->maxrot+2; + + *fp = value; +} + +static float rna_ConstraintActuator_distance_get(struct PointerRNA *ptr) +{ + bActuator *act = (bActuator*)ptr->data; + bConstraintActuator *ca = act->data; + float *fp; + + if(ca->mode & (ACT_CONST_DIRPX|ACT_CONST_DIRNX)) fp= ca->minloc; + else if(ca->mode & (ACT_CONST_DIRPY|ACT_CONST_DIRNY)) fp= ca->minloc+1; + else fp= ca->minloc+2; + + return *fp; +} + +static void rna_ConstraintActuator_distance_set(struct PointerRNA *ptr, float value) +{ + bActuator *act = (bActuator*)ptr->data; + bConstraintActuator *ca = act->data; + float *fp; + + if(ca->mode & (ACT_CONST_DIRPX|ACT_CONST_DIRNX)) fp= ca->minloc; + else if(ca->mode & (ACT_CONST_DIRPY|ACT_CONST_DIRNY)) fp= ca->minloc+1; + else fp= ca->minloc+2; + + *fp = value; +} + +static float rna_ConstraintActuator_range_get(struct PointerRNA *ptr) +{ + bActuator *act = (bActuator*)ptr->data; + bConstraintActuator *ca = act->data; + float *fp; + + if(ca->mode & (ACT_CONST_DIRPX|ACT_CONST_DIRNX)) fp= ca->maxloc; + else if(ca->mode & (ACT_CONST_DIRPY|ACT_CONST_DIRNY)) fp= ca->maxloc+1; + else fp= ca->maxloc+2; + + return *fp; +} + +static void rna_ConstraintActuator_range_set(struct PointerRNA *ptr, float value) +{ + bActuator *act = (bActuator*)ptr->data; + bConstraintActuator *ca = act->data; + float *fp; + + if(ca->mode & (ACT_CONST_DIRPX|ACT_CONST_DIRNX)) fp= ca->maxloc; + else if(ca->mode & (ACT_CONST_DIRPY|ACT_CONST_DIRNY)) fp= ca->maxloc+1; + else fp= ca->maxloc+2; + + *fp = value; +} + +static float rna_ConstraintActuator_fhheight_get(struct PointerRNA *ptr) +{ + bActuator *act = (bActuator*)ptr->data; + bConstraintActuator *ca = act->data; + float *fp; + + if(ca->mode & (ACT_CONST_DIRPX|ACT_CONST_DIRNX)) fp= ca->minloc; + else if(ca->mode & (ACT_CONST_DIRPY|ACT_CONST_DIRNY)) fp= ca->minloc+1; + else fp= ca->minloc+2; + + return *fp; +} + +static void rna_ConstraintActuator_fhheight_set(struct PointerRNA *ptr, float value) +{ + bActuator *act = (bActuator*)ptr->data; + bConstraintActuator *ca = act->data; + float *fp; + + if(ca->mode & (ACT_CONST_DIRPX|ACT_CONST_DIRNX)) fp= ca->minloc; + else if(ca->mode & (ACT_CONST_DIRPY|ACT_CONST_DIRNY)) fp= ca->minloc+1; + else fp= ca->minloc+2; + + *fp = value; +} + +static float rna_ConstraintActuator_spring_get(struct PointerRNA *ptr) +{ + bActuator *act = (bActuator*)ptr->data; + bConstraintActuator *ca = act->data; + float *fp; + + if(ca->mode & (ACT_CONST_DIRPX|ACT_CONST_DIRNX)) fp= ca->maxloc; + else if(ca->mode & (ACT_CONST_DIRPY|ACT_CONST_DIRNY)) fp= ca->maxloc+1; + else fp= ca->maxloc+2; + + return *fp; +} + +static void rna_ConstraintActuator_spring_set(struct PointerRNA *ptr, float value) +{ + bActuator *act = (bActuator*)ptr->data; + bConstraintActuator *ca = act->data; + float *fp; + + if(ca->mode & (ACT_CONST_DIRPX|ACT_CONST_DIRNX)) fp= ca->maxloc; + else if(ca->mode & (ACT_CONST_DIRPY|ACT_CONST_DIRNY)) fp= ca->maxloc+1; + else fp= ca->maxloc+2; + + *fp = value; +} + +static void rna_IpoActuator_add_set(struct PointerRNA *ptr, int value) +{ + bActuator *act = (bActuator *)ptr->data; + bIpoActuator *ia = act->data; + + if(value == 1){ + ia->flag &= ~ACT_IPOFORCE; + ia->flag |= ACT_IPOADD; + }else + ia->flag &= ~ACT_IPOADD; +} + +static void rna_IpoActuator_force_set(struct PointerRNA *ptr, int value) +{ + bActuator *act = (bActuator *)ptr->data; + bIpoActuator *ia = act->data; + + if(value == 1){ + ia->flag &= ~ACT_IPOADD; + ia->flag |= ACT_IPOFORCE; + }else + ia->flag &= ~ACT_IPOFORCE; +} + static void rna_ObjectActuator_integralcoefficient_set(struct PointerRNA *ptr, float value) { bActuator *act = (bActuator*)ptr->data; @@ -555,12 +747,17 @@ static void rna_def_ipo_actuator(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Frame Property", "Assign the action's current frame number to this property"); /* booleans */ + prop= RNA_def_property(srna, "add", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOADD); + RNA_def_property_boolean_funcs(prop, NULL, "rna_IpoActuator_add_set", NULL); + RNA_def_property_ui_text(prop, "Add", "Ipo is added to the current loc/rot/scale in global or local coordinate according to Local flag"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + prop= RNA_def_property(srna, "force", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOFORCE); + RNA_def_property_boolean_funcs(prop, NULL, "rna_IpoActuator_force_set", NULL); RNA_def_property_ui_text(prop, "Force", "Apply IPO as a global or local force depending on the local option (dynamic objects only)"); RNA_def_property_update(prop, NC_LOGIC, NULL); -//XXX logic_window::change_ipo_actuator -// RNA_def_property_boolean_funcs(prop, "rna_Actuator_Ipo_get", "rna_Actuator_Ipo_get", "rna_Actuator_Ipo_range"); prop= RNA_def_property(srna, "local", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOLOCAL); @@ -571,13 +768,6 @@ static void rna_def_ipo_actuator(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOCHILD); RNA_def_property_ui_text(prop, "Child", "Update IPO on all children Objects as well"); RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop= RNA_def_property(srna, "add", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOADD); - RNA_def_property_ui_text(prop, "Add", "Ipo is added to the current loc/rot/scale in global or local coordinate according to Local flag"); - RNA_def_property_update(prop, NC_LOGIC, NULL); -//XXX logic_window::change_ipo_actuator -// RNA_def_property_boolean_funcs(prop, "rna_Actuator_Ipo_get", "rna_Actuator_Ipo_get", "rna_Actuator_Ipo_range"); } static void rna_def_camera_actuator(BlenderRNA *brna) @@ -835,40 +1025,16 @@ static void rna_def_constraint_actuator(BlenderRNA *brna) RNA_def_property_update(prop, NC_LOGIC, NULL); /* ACT_CONST_TYPE_LOC */ - prop= RNA_def_property(srna, "limit_loc_min_x", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "minloc[0]"); - RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2); - RNA_def_property_ui_text(prop, "Min", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop= RNA_def_property(srna, "limit_loc_min_y", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "minloc[1]"); + prop= RNA_def_property(srna, "limit_min", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_funcs(prop, "rna_ConstraintActuator_limitmin_get", "rna_ConstraintActuator_limitmin_set", NULL); RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2); RNA_def_property_ui_text(prop, "Min", ""); RNA_def_property_update(prop, NC_LOGIC, NULL); - prop= RNA_def_property(srna, "limit_loc_min_z", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "minloc[2]"); - RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2); - RNA_def_property_ui_text(prop, "Min", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop= RNA_def_property(srna, "limit_loc_max_x", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "maxloc[0]"); + prop= RNA_def_property(srna, "limit_max", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_funcs(prop, "rna_ConstraintActuator_limitmax_get", "rna_ConstraintActuator_limitmax_set", NULL); RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2); - RNA_def_property_ui_text(prop, "Min", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop= RNA_def_property(srna, "limit_loc_max_y", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "maxloc[1]"); - RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2); - RNA_def_property_ui_text(prop, "Min", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop= RNA_def_property(srna, "limit_loc_max_z", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "maxloc[2]"); - RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2); - RNA_def_property_ui_text(prop, "Min", ""); + RNA_def_property_ui_text(prop, "Max", ""); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "damping", PROP_INT, PROP_PERCENTAGE); @@ -878,39 +1044,15 @@ static void rna_def_constraint_actuator(BlenderRNA *brna) RNA_def_property_update(prop, NC_LOGIC, NULL); /* ACT_CONST_TYPE_DIST */ - prop= RNA_def_property(srna, "range_x", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "maxloc[0]"); - RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2); - RNA_def_property_ui_text(prop, "Range", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop= RNA_def_property(srna, "range_y", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "maxloc[1]"); - RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2); + prop= RNA_def_property(srna, "range", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_funcs(prop, "rna_ConstraintActuator_range_get", "rna_ConstraintActuator_range_set", NULL); + RNA_def_property_ui_range(prop, 0.f, 2000.f, 1, 2); RNA_def_property_ui_text(prop, "Range", ""); RNA_def_property_update(prop, NC_LOGIC, NULL); - prop= RNA_def_property(srna, "range_z", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "maxloc[2]"); + prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_funcs(prop, "rna_ConstraintActuator_distance_get", "rna_ConstraintActuator_distance_set", NULL); RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2); - RNA_def_property_ui_text(prop, "Range", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop= RNA_def_property(srna, "distance_x", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "minloc[0]"); - RNA_def_property_ui_range(prop, 0.f, 2000.f, 1, 2); - RNA_def_property_ui_text(prop, "Distance", "Set the maximum length of ray"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop= RNA_def_property(srna, "distance_y", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "minloc[1]"); - RNA_def_property_ui_range(prop, 0.f, 2000.f, 1, 2); - RNA_def_property_ui_text(prop, "Distance", "Set the maximum length of ray"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop= RNA_def_property(srna, "distance_z", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "minloc[2]"); - RNA_def_property_ui_range(prop, 0.f, 2000.f, 1, 2); RNA_def_property_ui_text(prop, "Distance", "Set the maximum length of ray"); RNA_def_property_update(prop, NC_LOGIC, NULL); @@ -959,46 +1101,22 @@ static void rna_def_constraint_actuator(BlenderRNA *brna) RNA_def_property_update(prop, NC_LOGIC, NULL); /* ACT_CONST_TYPE_FH */ - prop= RNA_def_property(srna, "fh_damping", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "maxrot[0]"); - RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 1); - RNA_def_property_ui_text(prop, "Damping", "Damping factor of the Fh spring force"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop= RNA_def_property(srna, "fh_height_x", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "minloc[0]"); - RNA_def_property_ui_range(prop, 0.01, 2000.0, 0.1, 0.01); - RNA_def_property_ui_text(prop, "Distance", "Height of the Fh area"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop= RNA_def_property(srna, "fh_height_y", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "minloc[1]"); - RNA_def_property_ui_range(prop, 0.01, 2000.0, 0.1, 0.01); - RNA_def_property_ui_text(prop, "Distance", "Height of the Fh area"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop= RNA_def_property(srna, "fh_height_z", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "minloc[2]"); + prop= RNA_def_property(srna, "fh_height", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_funcs(prop, "rna_ConstraintActuator_fhheight_get", "rna_ConstraintActuator_fhheight_set", NULL); RNA_def_property_ui_range(prop, 0.01, 2000.0, 0.1, 0.01); RNA_def_property_ui_text(prop, "Distance", "Height of the Fh area"); RNA_def_property_update(prop, NC_LOGIC, NULL); - prop= RNA_def_property(srna, "spring_x", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "maxloc[0]"); + prop= RNA_def_property(srna, "spring", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_funcs(prop, "rna_ConstraintActuator_spring_get", "rna_ConstraintActuator_spring_set", NULL); RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 0.01); RNA_def_property_ui_text(prop, "Fh", "Spring force within the Fh area"); RNA_def_property_update(prop, NC_LOGIC, NULL); - prop= RNA_def_property(srna, "spring_y", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "maxloc[1]"); - RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 0.01); - RNA_def_property_ui_text(prop, "Fh", "Spring force within the Fh area"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop= RNA_def_property(srna, "spring_z", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "maxloc[2]"); - RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 0.01); - RNA_def_property_ui_text(prop, "Fh", "Spring force within the Fh area"); + prop= RNA_def_property(srna, "fh_damping", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "maxrot[0]"); + RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 1); + RNA_def_property_ui_text(prop, "Damping", "Damping factor of the Fh spring force"); RNA_def_property_update(prop, NC_LOGIC, NULL); /* booleans */ @@ -1037,8 +1155,6 @@ static void rna_def_constraint_actuator(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CONST_NORMAL); RNA_def_property_ui_text(prop, "N", "Add a horizontal spring force on slopes"); RNA_def_property_update(prop, NC_LOGIC, NULL); - - //XXX to replace all maxloc and minloc by a single one with get/set funcs } static void rna_def_edit_object_actuator(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index a8524a506bc..ef9a6b0bba3 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -432,37 +432,27 @@ static void rna_def_collision_sensor(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem prop_type_items[] ={ -// {SENS_COLLISION_PULSE, "PULSE", 0, "Property", ""}, - {SENS_COLLISION_PROPERTY, "PROPERTY", 0, "Property", ""}, - {SENS_COLLISION_MATERIAL, "MATERIAL", 0, "Material", ""}, - {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "CollisionSensor", "Sensor"); RNA_def_struct_ui_text(srna, "Collision Sensor", "Sensor to detect objects colliding with the current object, with more settings than the Touch sensor"); RNA_def_struct_sdna_from(srna, "bCollisionSensor", "data"); - prop= RNA_def_property(srna, "collision_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "mode"); - RNA_def_property_enum_items(prop, prop_type_items); - RNA_def_property_ui_text(prop, "Collision Type", "Toggle collision on material or property"); + prop= RNA_def_property(srna, "pulse", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mode", SENS_COLLISION_PULSE); + RNA_def_property_ui_text(prop, "Pulse", "Changes to the set of colliding objects generates pulse"); - /* - //XXX bad, ugly. pulse in 2.49 is part of the same "enum" of collision type - //to investigate: is pulse exclusive? or it works with mat/prop? - prop= RNA_def_property(srna, "pulse", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "mode"); - RNA_def_property_ui_text(prop, "Property Name", "changes to the set of colliding objects generates pulse"); - */ + prop= RNA_def_property(srna, "collision_type", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mode", SENS_COLLISION_MATERIAL); + RNA_def_property_ui_text(prop, "M/P", "Toggle collision on material or property"); prop= RNA_def_property(srna, "property", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "name"); - RNA_def_property_ui_text(prop, "Property Name", "Only look for Objects with this property"); + RNA_def_property_ui_text(prop, "Property", "Only look for Objects with this property"); //XXX to make a setFunction to create a lookup with all materials in Blend File (not only this object mat.) prop= RNA_def_property(srna, "material", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "materialName"); - RNA_def_property_ui_text(prop, "Material Name", "Only look for Objects with this material"); + RNA_def_property_ui_text(prop, "Material", "Only look for Objects with this material"); /*//XXX either use a datablock look up to store the string name (material) // or to do a doversion and use a material pointer. @@ -535,10 +525,6 @@ static void rna_def_ray_sensor(BlenderRNA *brna) {SENS_RAY_NEG_Y_AXIS, "NEGYAXIS", 0, "-Y axis", ""}, {SENS_RAY_NEG_Z_AXIS, "NEGZAXIS", 0, "-Z axis", ""}, {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem prop_type_items[] ={ - {SENS_RAY_PROPERTY, "PROPERTY", 0, "Property", ""}, - {SENS_RAY_MATERIAL, "MATERIAL", 0, "Material", ""}, - {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "RaySensor", "Sensor"); RNA_def_struct_ui_text(srna, "Ray Sensor", "Sensor to detect intersections with a ray emanating from the current object"); @@ -561,10 +547,9 @@ static void rna_def_ray_sensor(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Material", "Only look for Objects with this material"); */ - prop= RNA_def_property(srna, "ray_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "mode"); - RNA_def_property_enum_items(prop, prop_type_items); - RNA_def_property_ui_text(prop, "Collision Type", "Toggle collision on material or property"); + prop= RNA_def_property(srna, "ray_type", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mode", SENS_COLLISION_MATERIAL); + RNA_def_property_ui_text(prop, "M/P", "Toggle collision on material or property"); prop= RNA_def_property(srna, "x_ray_mode", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", SENS_RAY_XRAY); -- cgit v1.2.3 From 389e590460527ee497fe6426c48fba234490ff74 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 7 May 2010 07:54:25 +0000 Subject: ghash alloc string from render branch svn merge https://svn.blender.org/svnroot/bf-blender/branches/render25 -r28571:28573 svn merge https://svn.blender.org/svnroot/bf-blender/branches/render25 -r28575:28576 --- source/blender/blenkernel/intern/BME_tools.c | 2 +- source/blender/blenkernel/intern/action.c | 2 +- source/blender/blenkernel/intern/depsgraph.c | 2 +- source/blender/blenkernel/intern/icons.c | 2 +- source/blender/blenkernel/intern/nla.c | 2 +- source/blender/blenkernel/intern/softbody.c | 2 +- source/blender/blenlib/BLI_ghash.h | 2 +- source/blender/blenlib/intern/BLI_args.c | 2 +- source/blender/blenlib/intern/BLI_ghash.c | 4 ++-- source/blender/blenlib/intern/pbvh.c | 4 ++-- source/blender/blenloader/intern/readblenentry.c | 2 +- source/blender/editors/armature/editarmature.c | 2 +- source/blender/editors/armature/editarmature_retarget.c | 6 +++--- source/blender/editors/armature/editarmature_sketch.c | 2 +- source/blender/editors/armature/reeb.c | 4 ++-- source/blender/editors/mesh/editmesh_loop.c | 2 +- source/blender/editors/mesh/editmesh_tools.c | 6 +++--- source/blender/editors/mesh/meshtools.c | 2 +- source/blender/editors/sculpt_paint/paint_vertex.c | 2 +- source/blender/editors/transform/transform.c | 4 ++-- source/blender/gpu/intern/gpu_codegen.c | 6 +++--- source/blender/makesrna/intern/rna_access.c | 2 +- source/blender/modifiers/intern/MOD_boolean_util.c | 2 +- source/blender/modifiers/intern/MOD_build.c | 4 ++-- source/blender/modifiers/intern/MOD_mask.c | 12 ++++++------ source/blender/render/intern/source/convertblender.c | 4 ++-- source/blender/render/intern/source/sss.c | 2 +- source/blender/render/intern/source/strand.c | 4 ++-- source/gameengine/Converter/BL_ArmatureObject.cpp | 2 +- 29 files changed, 47 insertions(+), 47 deletions(-) diff --git a/source/blender/blenkernel/intern/BME_tools.c b/source/blender/blenkernel/intern/BME_tools.c index b4919dd8cf3..7d9c9a431f8 100644 --- a/source/blender/blenkernel/intern/BME_tools.c +++ b/source/blender/blenkernel/intern/BME_tools.c @@ -49,7 +49,7 @@ BME_TransData_Head *BME_init_transdata(int bufsize) { BME_TransData_Head *td; td = MEM_callocN(sizeof(BME_TransData_Head), "BMesh transdata header"); - td->gh = BLI_ghash_new(BLI_ghashutil_ptrhash,BLI_ghashutil_ptrcmp); + td->gh = BLI_ghash_new(BLI_ghashutil_ptrhash,BLI_ghashutil_ptrcmp, "BME_init_transdata gh"); td->ma = BLI_memarena_new(bufsize, "BME_TransData arena"); BLI_memarena_use_calloc(td->ma); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index c5705a0f619..50552d33c41 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -549,7 +549,7 @@ void make_pose_channels_hash(bPose *pose) if(!pose->chanhash) { bPoseChannel *pchan; - pose->chanhash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp); + pose->chanhash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "make_pose_chan gh"); for(pchan=pose->chanbase.first; pchan; pchan=pchan->next) BLI_ghash_insert(pose->chanhash, pchan->name, pchan); } diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index f63e28fb464..1e5f276ba95 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -803,7 +803,7 @@ DagNode * dag_add_node (DagForest *forest, void * fob) } if(!forest->nodeHash) - forest->nodeHash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); + forest->nodeHash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "dag_add_node gh"); BLI_ghash_insert(forest->nodeHash, fob, node); } diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index a9582506cee..29314fb4865 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -101,7 +101,7 @@ void BKE_icons_init(int first_dyn_id) gFirstIconId = first_dyn_id; if (!gIcons) - gIcons = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp); + gIcons = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "icons_init gh"); } void BKE_icons_free() diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 902d6b8e9bf..8d2ad49e7bf 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1243,7 +1243,7 @@ void BKE_nlastrip_validate_name (AnimData *adt, NlaStrip *strip) * - this is easier than iterating over all the tracks+strips hierarchy everytime * (and probably faster) */ - gh= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp); + gh= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "nlastrip_validate_name gh"); for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) { for (tstrip= nlt->strips.first; tstrip; tstrip= tstrip->next) { diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index b8274940318..c06e0679a7d 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -3663,7 +3663,7 @@ static void sb_new_scratch(SoftBody *sb) { if (!sb) return; sb->scratch = MEM_callocN(sizeof(SBScratch), "SBScratch"); - sb->scratch->colliderhash = BLI_ghash_new(BLI_ghashutil_ptrhash,BLI_ghashutil_ptrcmp); + sb->scratch->colliderhash = BLI_ghash_new(BLI_ghashutil_ptrhash,BLI_ghashutil_ptrcmp, "sb_new_scratch gh"); sb->scratch->bodyface = NULL; sb->scratch->totface = 0; sb->scratch->aabbmax[0]=sb->scratch->aabbmax[1]=sb->scratch->aabbmax[2] = 1.0e30f; diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h index ca4347f2c6d..92a99c9a3b4 100644 --- a/source/blender/blenlib/BLI_ghash.h +++ b/source/blender/blenlib/BLI_ghash.h @@ -72,7 +72,7 @@ typedef struct GHashIterator { struct Entry *curEntry; } GHashIterator; -GHash* BLI_ghash_new (GHashHashFP hashfp, GHashCmpFP cmpfp); +GHash* BLI_ghash_new (GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info); void BLI_ghash_free (GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp); //BM_INLINE void BLI_ghash_insert (GHash *gh, void *key, void *val); diff --git a/source/blender/blenlib/intern/BLI_args.c b/source/blender/blenlib/intern/BLI_args.c index 1a677499d1f..61ddf8314e5 100644 --- a/source/blender/blenlib/intern/BLI_args.c +++ b/source/blender/blenlib/intern/BLI_args.c @@ -102,7 +102,7 @@ bArgs *BLI_argsInit(int argc, char **argv) { bArgs *ba = MEM_callocN(sizeof(bArgs), "bArgs"); ba->passes = MEM_callocN(sizeof(int) * argc, "bArgs passes"); - ba->items = BLI_ghash_new(keyhash, keycmp); + ba->items = BLI_ghash_new(keyhash, keycmp, "bArgs passes gh"); ba->argc = argc; ba->argv = argv; diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index ee312174cf8..11756ada40e 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -45,8 +45,8 @@ unsigned int hashsizes[]= { /***/ -GHash *BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp) { - GHash *gh= MEM_mallocN(sizeof(*gh), "GHash"); +GHash *BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info) { + GHash *gh= MEM_mallocN(sizeof(*gh), info); gh->hashfp= hashfp; gh->cmpfp= cmpfp; gh->entrypool = BLI_mempool_create(sizeof(Entry), 64, 64, 0); diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c index a189e9fbaf2..8aff062c1d4 100644 --- a/source/blender/blenlib/intern/pbvh.c +++ b/source/blender/blenlib/intern/pbvh.c @@ -303,7 +303,7 @@ static void build_mesh_leaf_node(PBVH *bvh, PBVHNode *node) GHash *map; int i, j, totface; - map = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp); + map = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "build_mesh_leaf_node gh"); node->uniq_verts = node->face_verts = 0; totface= node->totprim; @@ -970,7 +970,7 @@ void BLI_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***gridfaces, int *tot void *face, **faces; int i, tot; - map = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); + map = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "pbvh_get_grid_updates gh"); pbvh_iter_begin(&iter, bvh, NULL, NULL); diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index 0b2d6100964..33827c801f1 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -283,7 +283,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype) LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh) { FileData *fd= (FileData*) bh; - GHash *gathered= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); + GHash *gathered= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "linkable_groups gh"); LinkNode *names= NULL; BHead *bhead; diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index a75379024d8..b0c45616f1c 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -5870,7 +5870,7 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg) ED_armature_to_edit(obedit); - arcBoneMap = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); + arcBoneMap = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "SkeletonFromReebGraph gh"); BLI_markdownSymmetry((BGraph*)rg, rg->nodes.first, scene->toolsettings->skgen_symmetry_limit); diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c index 4be2d23738a..c2e21755f94 100644 --- a/source/blender/editors/armature/editarmature_retarget.c +++ b/source/blender/editors/armature/editarmature_retarget.c @@ -316,8 +316,8 @@ static RigGraph *newRigGraph() rg->head = NULL; - rg->bones_map = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp); - rg->controls_map = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp); + rg->bones_map = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "newRigGraph bones gh"); + rg->controls_map = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "newRigGraph cont gh"); rg->free_arc = RIG_freeRigArc; rg->free_node = NULL; @@ -561,7 +561,7 @@ static RigGraph *cloneRigGraph(RigGraph *src, ListBase *editbones, Object *ob, c RigControl *ctrl; RigGraph *rg; - ptr_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); + ptr_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "cloneRigGraph gh"); rg = newRigGraph(); diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index 521241373d0..907fe50305a 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -168,7 +168,7 @@ void BIF_makeListTemplates(const bContext *C) BLI_ghash_free(TEMPLATES_HASH, NULL, NULL); } - TEMPLATES_HASH = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp); + TEMPLATES_HASH = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "makeListTemplates gh"); TEMPLATES_CURRENT = 0; for ( base = FIRSTBASE; base; base = base->next ) diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c index 8c1171e967b..fd95879f3ec 100644 --- a/source/blender/editors/armature/reeb.c +++ b/source/blender/editors/armature/reeb.c @@ -348,7 +348,7 @@ ReebArc * copyArc(ReebGraph *rg, ReebArc *arc) memcpy(cp_arc->buckets, arc->buckets, sizeof(EmbedBucket) * cp_arc->bcount); /* copy faces map */ - cp_arc->faces = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); + cp_arc->faces = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "copyArc gh"); mergeArcFaces(rg, cp_arc, arc); /* find corresponding head and tail */ @@ -2440,7 +2440,7 @@ ReebEdge * createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2) arc->flag = 0; // clear flag on init arc->symmetry_level = 0; - arc->faces = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); + arc->faces = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "createArc gh"); if (node1->weight <= node2->weight) { diff --git a/source/blender/editors/mesh/editmesh_loop.c b/source/blender/editors/mesh/editmesh_loop.c index 760c911fdee..373a4e60cdb 100644 --- a/source/blender/editors/mesh/editmesh_loop.c +++ b/source/blender/editors/mesh/editmesh_loop.c @@ -660,7 +660,7 @@ static int knife_cut_exec(bContext *C, wmOperator *op) eed->tmp.fp = 0.0; /*the floating point coordinates of verts in screen space will be stored in a hash table according to the vertices pointer*/ - gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); + gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "knife_cut_exec gh"); for(eve=em->verts.first; eve; eve=eve->next){ scr = MEM_mallocN(sizeof(float)*2, "Vertex Screen Coordinates"); VECCOPY(co, eve->co); diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 3555bfc8cad..8cd8688d448 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -2729,7 +2729,7 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float } } - gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); + gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "subdivideedgenum gh"); // If we are knifing, We only need the selected edges that were cut, so deselect if it was not cut if(beauty & B_KNIFE) { @@ -4091,7 +4091,7 @@ useless: // populate the SlideVerts - vertgh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); + vertgh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "EdgeSlide gh"); look = vertlist; while(look) { i=0; @@ -4259,7 +4259,7 @@ useless: for (uvlay_idx=0; uvlay_idxverts.first;ev;ev=ev->next) { ev->tmp.l = 0; diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index a08e08c25c0..b7a63b60318 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -1374,7 +1374,7 @@ int *mesh_get_x_mirror_faces(Object *ob, EditMesh *em) mesh_octree_table(ob, em, NULL, 'e'); - fhash= BLI_ghash_new(mirror_facehash, mirror_facecmp); + fhash= BLI_ghash_new(mirror_facehash, mirror_facecmp, "mirror_facehash gh"); for(a=0, mf=mface; atotface; a++, mf++) BLI_ghash_insert(fhash, mf, mf); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index a3c21a690c1..2650c2e278c 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1260,7 +1260,7 @@ static char *wpaint_make_validmap(Mesh *me, Object *ob) bPose *pose; bPoseChannel *chan; ArmatureModifierData *amd; - GHash *gh = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp); + GHash *gh = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "wpaint_make_validmap gh"); int i = 0, step1=1; /*add all names to a hash table*/ diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 7f0bc6627d2..8ff397a2139 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -4343,7 +4343,7 @@ static int createSlideVerts(TransInfo *t) // populate the SlideVerts - vertgh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); + vertgh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "createSlideVerts gh"); look = vertlist; while(look) { i=0; @@ -4544,7 +4544,7 @@ static int createSlideVerts(TransInfo *t) for (uvlay_idx=0; uvlay_idxverts.first;ev;ev=ev->next) { ev->tmp.l = 0; diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index a3196f5125b..a6250650787 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -352,7 +352,7 @@ static char *gpu_generate_function_prototyps(GHash *hash) GPUFunction *GPU_lookup_function(char *name) { if(!FUNCTION_HASH) { - FUNCTION_HASH = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp); + FUNCTION_HASH = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "GPU_lookup_function gh"); gpu_parse_functions_string(FUNCTION_HASH, datatoc_gpu_shader_material_glsl); /*FUNCTION_PROTOTYPES = gpu_generate_function_prototyps(FUNCTION_HASH); FUNCTION_LIB = GPU_shader_create_lib(datatoc_gpu_shader_material_glsl);*/ @@ -480,8 +480,8 @@ static void codegen_set_unique_ids(ListBase *nodes) GPUOutput *output; int id = 1, texid = 0; - bindhash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); - definehash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); + bindhash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "codegen_set_unique_ids1 gh"); + definehash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "codegen_set_unique_ids2 gh"); for (node=nodes->first; node; node=node->next) { for (input=node->inputs.first; input; input=input->next) { diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index c110b89a818..078b4d995ee 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -64,7 +64,7 @@ void RNA_init() for(srna=BLENDER_RNA.structs.first; srna; srna=srna->cont.next) { if(!srna->cont.prophash) { - srna->cont.prophash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp); + srna->cont.prophash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "RNA_init gh"); for(prop=srna->cont.properties.first; prop; prop=prop->next) if(!(prop->flag & PROP_BUILTIN)) diff --git a/source/blender/modifiers/intern/MOD_boolean_util.c b/source/blender/modifiers/intern/MOD_boolean_util.c index 98f27d7b1b9..11d47bfffb1 100644 --- a/source/blender/modifiers/intern/MOD_boolean_util.c +++ b/source/blender/modifiers/intern/MOD_boolean_util.c @@ -366,7 +366,7 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( // a hash table to remap materials to indices if (mat) { - material_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); + material_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "CSG_mat gh"); *totmat = 0; } diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c index c946665e215..05ef85b818a 100644 --- a/source/blender/modifiers/intern/MOD_build.c +++ b/source/blender/modifiers/intern/MOD_build.c @@ -82,10 +82,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, GHashIterator *hashIter; /* maps vert indices in old mesh to indices in new mesh */ GHash *vertHash = BLI_ghash_new(BLI_ghashutil_inthash, - BLI_ghashutil_intcmp); + BLI_ghashutil_intcmp, "build ve apply gh"); /* maps edge indices in new mesh to indices in old mesh */ GHash *edgeHash = BLI_ghash_new(BLI_ghashutil_inthash, - BLI_ghashutil_intcmp); + BLI_ghashutil_intcmp, "build ed apply gh"); maxVerts = dm->getNumVerts(dm); vertMap = MEM_callocN(sizeof(*vertMap) * maxVerts, diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c index 25781f3dff0..e7f0495a817 100644 --- a/source/blender/modifiers/intern/MOD_mask.c +++ b/source/blender/modifiers/intern/MOD_mask.c @@ -129,8 +129,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, * - vgroups to indicies -> vgroupHash (string, int) * - bones to vgroup indices -> boneHash (index of vgroup, dummy) */ - vgroupHash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp); - boneHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp); + vgroupHash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "mask vgroup gh"); + boneHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask bone gh"); /* build mapping of names of vertex groups to indices */ for (i = 0, def = ob->defbase.first; def; def = def->next, i++) @@ -175,7 +175,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } /* hashes for quickly providing a mapping from old to new - use key=oldindex, value=newindex */ - vertHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp); + vertHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask vert gh"); /* add vertices which exist in vertexgroups into vertHash for filtering */ for (i = 0; i < maxVerts; i++) @@ -224,7 +224,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, return dm; /* hashes for quickly providing a mapping from old to new - use key=oldindex, value=newindex */ - vertHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp); + vertHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask vert2 bh"); /* add vertices which exist in vertexgroup into ghash for filtering */ for (i = 0; i < maxVerts; i++) @@ -258,8 +258,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } /* hashes for quickly providing a mapping from old to new - use key=oldindex, value=newindex */ - edgeHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp); - faceHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp); + edgeHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask ed2 gh"); + faceHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask fa2 gh"); /* loop over edges and faces, and do the same thing to * ensure that they only reference existing verts diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index f6d08db78c7..f6be316dcfd 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -853,7 +853,7 @@ static float *get_object_orco(Render *re, Object *ob) float *orco; if (!re->orco_hash) - re->orco_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); + re->orco_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "get_object_orco gh"); orco = BLI_ghash_lookup(re->orco_hash, ob); @@ -876,7 +876,7 @@ static float *get_object_orco(Render *re, Object *ob) static void set_object_orco(Render *re, void *ob, float *orco) { if (!re->orco_hash) - re->orco_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); + re->orco_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "set_object_orco gh"); BLI_ghash_insert(re->orco_hash, ob, orco); } diff --git a/source/blender/render/intern/source/sss.c b/source/blender/render/intern/source/sss.c index bb5f8e9b8b4..aa285401524 100644 --- a/source/blender/render/intern/source/sss.c +++ b/source/blender/render/intern/source/sss.c @@ -988,7 +988,7 @@ void make_sss_tree(Render *re) { Material *mat; - re->sss_hash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); + re->sss_hash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "make_sss_tree gh"); re->i.infostr= "SSS preprocessing"; re->stats_draw(re->sdh, &re->i); diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c index e3428741473..88d042e7b97 100644 --- a/source/blender/render/intern/source/strand.c +++ b/source/blender/render/intern/source/strand.c @@ -318,8 +318,8 @@ StrandShadeCache *strand_shade_cache_create() StrandShadeCache *cache; cache= MEM_callocN(sizeof(StrandShadeCache), "StrandShadeCache"); - cache->resulthash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); - cache->refcounthash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); + cache->resulthash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "strand_shade_cache_create1 gh"); + cache->refcounthash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "strand_shade_cache_create2 gh"); cache->memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "strand shade cache arena"); return cache; diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index 78f16dd6982..217011517eb 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -93,7 +93,7 @@ void game_copy_pose(bPose **dst, bPose *src, int copy_constraint) BLI_duplicatelist(&out->chanbase, &src->chanbase); /* remap pointers */ - ghash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); + ghash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "game_copy_pose gh"); pchan= (bPoseChannel*)src->chanbase.first; outpchan= (bPoseChannel*)out->chanbase.first; -- cgit v1.2.3 From ba8b63fbd7a780224c68004664ba0ff156bc01f2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 7 May 2010 07:57:15 +0000 Subject: too many args, build error --- source/blender/makesrna/intern/rna_actuator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 9c5476b08d9..5e5ca2cd2b1 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -749,13 +749,13 @@ static void rna_def_ipo_actuator(BlenderRNA *brna) /* booleans */ prop= RNA_def_property(srna, "add", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOADD); - RNA_def_property_boolean_funcs(prop, NULL, "rna_IpoActuator_add_set", NULL); + RNA_def_property_boolean_funcs(prop, NULL, "rna_IpoActuator_add_set"); RNA_def_property_ui_text(prop, "Add", "Ipo is added to the current loc/rot/scale in global or local coordinate according to Local flag"); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "force", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOFORCE); - RNA_def_property_boolean_funcs(prop, NULL, "rna_IpoActuator_force_set", NULL); + RNA_def_property_boolean_funcs(prop, NULL, "rna_IpoActuator_force_set"); RNA_def_property_ui_text(prop, "Force", "Apply IPO as a global or local force depending on the local option (dynamic objects only)"); RNA_def_property_update(prop, NC_LOGIC, NULL); -- cgit v1.2.3 From fbb68188dfdc213cf6653fc1a4573c79abd85527 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Fri, 7 May 2010 08:10:20 +0000 Subject: Restrict keyboard sensor stored events to only what's appropriate per property (normal key, modifier key, etc) --- source/blender/makesrna/intern/rna_sensor.c | 39 ++++++++++++++++++++++----- source/blender/windowmanager/wm_event_types.h | 3 +++ 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index ef9a6b0bba3..edae9ab36b6 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -32,6 +32,8 @@ #include "DNA_object_types.h" #include "DNA_sensor_types.h" +#include "WM_types.h" + EnumPropertyItem sensor_type_items[] ={ {SENS_ACTUATOR, "ACTUATOR", 0, "Actuator", ""}, {SENS_ALWAYS, "ALWAYS", 0, "Always", ""}, @@ -151,6 +153,33 @@ EnumPropertyItem *rna_Sensor_type_itemf(bContext *C, PointerRNA *ptr, int *free) return item; } +static void rna_Sensor_keyboard_key_set(struct PointerRNA *ptr, int value) +{ + bSensor *sens= (bSensor *)ptr->data; + bKeyboardSensor *ks = sens->data; + + if (ISKEYBOARD(value) && !ISKEYMODIFIER(value)) + ks->key = value; +} + +static void rna_Sensor_keyboard_modifier_set(struct PointerRNA *ptr, int value) +{ + bSensor *sens= (bSensor *)ptr->data; + bKeyboardSensor *ks = sens->data; + + if (ISKEYMODIFIER(value)) + ks->qual = value; +} + +static void rna_Sensor_keyboard_modifier2_set(struct PointerRNA *ptr, int value) +{ + bSensor *sens= (bSensor *)ptr->data; + bKeyboardSensor *ks = sens->data; + + if (ISKEYMODIFIER(value)) + ks->qual2 = value; +} + #else static void rna_def_sensor(BlenderRNA *brna) @@ -284,26 +313,22 @@ static void rna_def_keyboard_sensor(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Keyboard Sensor", "Sensor to detect keyboard events"); RNA_def_struct_sdna_from(srna, "bKeyboardSensor", "data"); - /* - prop= RNA_def_property(srna, "key", PROP_INT, PROP_NONE);//XXX need to use another input template - //RNA_def_property_clear_flag(prop, PROP_EDITABLE); // need better range or enum check - RNA_def_property_ui_text(prop, "Key", "Input key code"); - RNA_def_property_range(prop, 0, 255); - */ - prop= RNA_def_property(srna, "key", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "key"); RNA_def_property_enum_items(prop, event_type_items); + RNA_def_property_enum_funcs(prop, NULL, "rna_Sensor_keyboard_key_set", NULL); RNA_def_property_ui_text(prop, "Key", ""); prop= RNA_def_property(srna, "modifier_key", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "qual"); RNA_def_property_enum_items(prop, event_type_items); + RNA_def_property_enum_funcs(prop, NULL, "rna_Sensor_keyboard_modifier_set", NULL); RNA_def_property_ui_text(prop, "Modifier Key", "Modifier key code"); prop= RNA_def_property(srna, "second_modifier_key", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "qual2"); RNA_def_property_enum_items(prop, event_type_items); + RNA_def_property_enum_funcs(prop, NULL, "rna_Sensor_keyboard_modifier2_set", NULL); RNA_def_property_ui_text(prop, "Second Modifier Key", "Modifier key code"); prop= RNA_def_property(srna, "target", PROP_STRING, PROP_NONE); diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index a38e433fe56..7b83e1d4179 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -213,6 +213,9 @@ /* test whether the event is a key on the keyboard */ #define ISKEYBOARD(event) (event >=' ' && event <=320) + /* test whether the event is a modifier key */ +#define ISKEYMODIFIER(event) ((event >= LEFTCTRLKEY && event <= LEFTSHIFTKEY) || event == COMMANDKEY) + /* test whether the event is a mouse button */ #define ISMOUSE(event) (event >= LEFTMOUSE && event <= MOUSEROTATE) -- cgit v1.2.3 From 70a96a1089899f4f1e8541a56303742e1c192845 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 7 May 2010 09:41:26 +0000 Subject: saving multires data didnt get the new filename when the external struct was alredy allocated (making save external fail) --- source/blender/blenkernel/intern/customdata.c | 2 +- source/blender/editors/object/object_modifier.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index a973c33ca54..9ae1c7f05ab 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -2487,9 +2487,9 @@ void CustomData_external_add(CustomData *data, ID *id, int type, int totelem, co if(!external) { external= MEM_callocN(sizeof(CustomDataExternal), "CustomDataExternal"); - BLI_strncpy(external->filename, filename, sizeof(external->filename)); data->external= external; } + BLI_strncpy(external->filename, filename, sizeof(external->filename)); layer->flag |= CD_FLAG_EXTERNAL|CD_FLAG_IN_MEMORY; } diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 47816a5aaec..4cfed57f9c7 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1021,8 +1021,8 @@ static int multires_save_external_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; RNA_string_get(op->ptr, "path", path); - if(G.save_over) - BLI_path_rel(path, G.sce); + + /* BLI_path_rel(path, G.sce); */ /* TODO, relative path operator option */ CustomData_external_add(&me->fdata, &me->id, CD_MDISPS, me->totface, path); CustomData_external_write(&me->fdata, &me->id, CD_MASK_MESH, me->totface, 0); -- cgit v1.2.3 From 8ab5ae6a7843ae6b860cc30d59e39f4a4ddacb21 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 7 May 2010 09:46:54 +0000 Subject: Exr reading error print has a bit more detail now, to debug problems. --- source/blender/render/intern/source/pipeline.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index c578d3ea502..0f4cfb636da 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -927,12 +927,16 @@ static int read_render_result_from_file(char *filename, RenderResult *rr) int rectx, recty; if(IMB_exr_begin_read(exrhandle, filename, &rectx, &recty)==0) { + printf("failed being read %s\n", filename); IMB_exr_close(exrhandle); return 0; } - + if(rr == NULL || rectx!=rr->rectx || recty!=rr->recty) { - printf("error in reading render result\n"); + if(rr) + printf("error in reading render result: dimensions don't match\n"); + else + printf("error in reading render result: NULL result pointer\n"); IMB_exr_close(exrhandle); return 0; } -- cgit v1.2.3 From 9bd3f08b65fe19757029e594dea52f1132dbb48c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 7 May 2010 09:48:40 +0000 Subject: Multires: fix for "failed to read" error message with external displacements. --- source/blender/blenkernel/intern/customdata.c | 4 +- source/blender/blenkernel/intern/multires.c | 53 ++++++++++++++++++--------- 2 files changed, 37 insertions(+), 20 deletions(-) diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 9ae1c7f05ab..69327eccfaf 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -559,7 +559,7 @@ static int layerRead_mdisps(CDataFile *cdf, void *data, int count) d[i].disps = MEM_callocN(sizeof(float)*3*d[i].totdisp, "mdisps read"); if(!cdf_read_data(cdf, d[i].totdisp*3*sizeof(float), d[i].disps)) { - printf("failed to read %d/%d %d\n", i, count, d[i].totdisp); + printf("failed to read multires displacement %d/%d %d\n", i, count, d[i].totdisp); return 0; } } @@ -574,7 +574,7 @@ static int layerWrite_mdisps(CDataFile *cdf, void *data, int count) for(i = 0; i < count; ++i) { if(!cdf_write_data(cdf, d[i].totdisp*3*sizeof(float), d[i].disps)) { - printf("failed to write %d/%d %d\n", i, count, d[i].totdisp); + printf("failed to write multires displacement %d/%d %d\n", i, count, d[i].totdisp); return 0; } } diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 9e95581b211..52c6f9355a3 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -264,6 +264,38 @@ int multiresModifier_reshapeFromDeformMod(MultiresModifierData *mmd, Object *ob, return result; } +static void multires_set_tot_mdisps(Mesh *me, int lvl) +{ + MDisps *mdisps= CustomData_get_layer(&me->fdata, CD_MDISPS); + int i; + + if(mdisps) { + for(i = 0; i < me->totface; i++) { + if(mdisps[i].totdisp == 0) { + int nvert = (me->mface[i].v4)? 4: 3; + mdisps[i].totdisp = multires_grid_tot[lvl]*nvert; + } + } + } +} + +static void multires_reallocate_mdisps(Mesh *me, MDisps *mdisps, int lvl) +{ + int i; + + /* reallocate displacements to be filled in */ + for(i = 0; i < me->totface; ++i) { + int nvert = (me->mface[i].v4)? 4: 3; + int totdisp = multires_grid_tot[lvl]*nvert; + float (*disps)[3] = MEM_callocN(sizeof(float) * 3 * totdisp, "multires disps"); + + if(mdisps[i].disps) + MEM_freeN(mdisps[i].disps); + + mdisps[i].disps = disps; + mdisps[i].totdisp = totdisp; + } +} static void column_vectors_to_mat3(float mat[][3], float v1[3], float v2[3], float v3[3]) { @@ -320,6 +352,7 @@ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int dire int levels = mmd->totlvl - lvl; MDisps *mdisps; + multires_set_tot_mdisps(me, mmd->totlvl); CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); mdisps= CustomData_get_layer(&me->fdata, CD_MDISPS); @@ -393,24 +426,6 @@ static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl return subsurf_make_derived_from_derived(dm, &smd, 0, NULL, 0, 0); } -static void multires_reallocate_mdisps(Mesh *me, MDisps *mdisps, int lvl) -{ - int i; - - /* reallocate displacements to be filled in */ - for(i = 0; i < me->totface; ++i) { - int nvert = (me->mface[i].v4)? 4: 3; - int totdisp = multires_grid_tot[lvl]*nvert; - float (*disps)[3] = MEM_callocN(sizeof(float) * 3 * totdisp, "multires disps"); - - if(mdisps[i].disps) - MEM_freeN(mdisps[i].disps); - - mdisps[i].disps = disps; - mdisps[i].totdisp = totdisp; - } -} - void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int updateblock, int simple) { Mesh *me = ob->data; @@ -615,6 +630,7 @@ static void multiresModifier_update(DerivedMesh *dm) ob = ccgdm->multires.ob; me = ccgdm->multires.ob->data; mmd = ccgdm->multires.mmd; + multires_set_tot_mdisps(me, mmd->totlvl); CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); mdisps = CustomData_get_layer(&me->fdata, CD_MDISPS); @@ -750,6 +766,7 @@ DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, int loca memcpy(subGridData[i], gridData[i], sizeof(DMGridData)*gridSize*gridSize); } + multires_set_tot_mdisps(me, mmd->totlvl); CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); multiresModifier_disp_run(result, ob->data, 0, 0, subGridData, mmd->totlvl); -- cgit v1.2.3 From 1613829e8e821321da99cad4790b7e6a1d90cea8 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 7 May 2010 10:59:48 +0000 Subject: Minor formatting tweaks (killing some "caterpillar if's"... yuck those things are nasty to edit/extend) --- source/blender/editors/object/object_constraint.c | 1 + source/blender/editors/transform/transform.c | 22 +++++++++++++--------- .../editors/transform/transform_conversions.c | 8 ++++++-- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index c52fd151d83..039b18efb39 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -609,6 +609,7 @@ void CONSTRAINT_OT_limitdistance_reset (wmOperatorType *ot) } /* ------------- Child-Of Constraint ------------------ */ + /* ChildOf Constraint - set inverse callback */ static int childof_set_inverse_exec (bContext *C, wmOperator *op) { diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 8ff397a2139..4ae8d5debb6 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -210,7 +210,8 @@ void projectIntView(TransInfo *t, float *vec, int *adr) //vec[0] = vec[0]/((t->scene->r.frs_sec / t->scene->r.frs_sec_base)); UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1); - } else { + } + else { UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1); } @@ -5308,19 +5309,19 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d, const short doTime= 0; //XXX doesn't work - getAnimEdit_DrawTime(t); const double secf= FPS; double val; - + /* convert frame to nla-action time (if needed) */ if (adt) val= BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP); else val= *(td->val); - + /* do the snapping to nearest frame/second */ if (doTime) val= (float)( floor((val/secf) + 0.5f) * secf ); else val= (float)( floor(val+0.5f) ); - + /* convert frame out of nla-action time */ if (adt) *(td->val)= BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP); @@ -5330,28 +5331,31 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d, /* snap key to nearest marker? */ else if (autosnap == SACTSNAP_MARKER) { float val; - + /* convert frame to nla-action time (if needed) */ if (adt) val= BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP); else val= *(td->val); - + /* snap to nearest marker */ // TODO: need some more careful checks for where data comes from val= (float)ED_markers_find_nearest_marker_time(&t->scene->markers, val); - + /* convert frame out of nla-action time */ if (adt) *(td->val)= BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP); else *(td->val)= val; } - + + /* if the handles are to be moved too (as side-effect of keyframes moving, to keep the general effect) + * offset them by the same amount so that the general angles are maintained (i.e. won't change while + * handles are free-to-roam and keyframes are snap-locked) + */ if ((td->flag & TD_MOVEHANDLE1) && td2d->h1) { td2d->h1[0] = td2d->ih1[0] + *td->val - td->ival; } - if ((td->flag & TD_MOVEHANDLE2) && td2d->h2) { td2d->h2[0] = td2d->ih2[0] + *td->val - td->ival; } diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 3f9b6df0718..d1b6838c517 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -3295,12 +3295,16 @@ static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt, if (td->flag & TD_MOVEHANDLE1) { td2d->h1 = bezt->vec[0]; VECCOPY2D(td2d->ih1, td2d->h1); - } else td2d->h1 = NULL; + } + else + td2d->h1 = NULL; if (td->flag & TD_MOVEHANDLE2) { td2d->h2 = bezt->vec[2]; VECCOPY2D(td2d->ih2, td2d->h2); - } else td2d->h2 = NULL; + } + else + td2d->h2 = NULL; memset(td->axismtx, 0, sizeof(td->axismtx)); td->axismtx[2][2] = 1.0f; -- cgit v1.2.3 From 008863daec1249d1f17bc69e1105e336db690d63 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 7 May 2010 15:18:04 +0000 Subject: Merge image related changes from the render branch. This includes the image tile cache code in imbuf, but it is not hooked up to the render engine. Imbuf module: some small refactoring and removing a lot of unused or old code (about 6.5k lines). * Added a ImFileType struct with callbacks to make adding an file format type, or making changes to the API easier. * Move imbuf init/exit code into IMB_init()/IMB_exit() functions. * Increased mipmap levels from 10 to 20, you run into this limit already with a 2k image. * Removed hamx, amiga, anim5 format support. * Removed colormap saving, only simple colormap code now for reading tga. * Removed gen_dynlibtiff.py, editing this is almost as much work as just editing the code directly. * Functions removed that were only used for sequencer plugin API: IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp, IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace, IMB_dit0, IMB_dit2, IMB_cspace * Write metadata info into OpenEXR images. Can be viewed with the command line utility 'exrheader' For the image tile cache code, see this page: http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache --- source/blender/blenkernel/BKE_image.h | 1 - source/blender/blenkernel/intern/blender.c | 2 +- source/blender/blenkernel/intern/bmfont.c | 2 +- source/blender/blenkernel/intern/image.c | 110 +--- source/blender/blenkernel/intern/multires.c | 53 +- source/blender/blenkernel/intern/sequencer.c | 2 +- source/blender/blenkernel/intern/writeavi.c | 5 - source/blender/blenlib/BLI_math_vector.h | 1 + source/blender/blenlib/BLI_path_util.h | 6 +- source/blender/blenlib/BLI_storage.h | 3 + source/blender/blenlib/intern/math_vector_inline.c | 8 + source/blender/blenlib/intern/path_util.c | 18 + source/blender/blenlib/intern/storage.c | 11 + source/blender/blenloader/intern/readfile.c | 2 - source/blender/blenpluginapi/iff.h | 153 +----- source/blender/blenpluginapi/intern/pluginapi.c | 65 +-- source/blender/editors/interface/interface_draw.c | 2 +- source/blender/editors/interface/interface_icons.c | 2 +- source/blender/editors/screen/screendump.c | 2 - source/blender/editors/space_file/filelist.c | 4 +- source/blender/editors/space_file/writeimage.c | 1 - source/blender/editors/space_image/image_buttons.c | 1 - source/blender/imbuf/IMB_imbuf.h | 261 +++------ source/blender/imbuf/IMB_imbuf_types.h | 202 +++---- source/blender/imbuf/IMB_thumbs.h | 2 +- source/blender/imbuf/SConscript | 3 + source/blender/imbuf/intern/IMB_amiga.h | 47 -- source/blender/imbuf/intern/IMB_anim.h | 19 +- source/blender/imbuf/intern/IMB_anim5.h | 20 - source/blender/imbuf/intern/IMB_bitplanes.h | 47 -- source/blender/imbuf/intern/IMB_bmp.h | 47 -- source/blender/imbuf/intern/IMB_cmap.h | 46 -- source/blender/imbuf/intern/IMB_cocoa.h | 43 -- source/blender/imbuf/intern/IMB_divers.h | 45 -- source/blender/imbuf/intern/IMB_dpxcineon.h | 47 -- source/blender/imbuf/intern/IMB_filetype.h | 120 +++++ source/blender/imbuf/intern/IMB_filter.h | 3 + source/blender/imbuf/intern/IMB_ham.h | 45 -- source/blender/imbuf/intern/IMB_hamx.h | 47 -- source/blender/imbuf/intern/IMB_iff.h | 46 -- source/blender/imbuf/intern/IMB_imginfo.h | 85 --- source/blender/imbuf/intern/IMB_iris.h | 46 -- source/blender/imbuf/intern/IMB_jp2.h | 49 -- source/blender/imbuf/intern/IMB_jpeg.h | 49 -- source/blender/imbuf/intern/IMB_metadata.h | 80 +++ source/blender/imbuf/intern/IMB_png.h | 48 -- source/blender/imbuf/intern/IMB_radiance_hdr.h | 42 -- source/blender/imbuf/intern/IMB_targa.h | 48 -- source/blender/imbuf/intern/IMB_tiff.h | 45 -- source/blender/imbuf/intern/allocimbuf.c | 405 ++++++-------- source/blender/imbuf/intern/amiga.c | 540 ------------------- source/blender/imbuf/intern/anim.c | 39 +- source/blender/imbuf/intern/anim5.c | 539 ------------------- source/blender/imbuf/intern/antialias.c | 466 ----------------- source/blender/imbuf/intern/bitplanes.c | 356 ------------- source/blender/imbuf/intern/bmp.c | 8 +- source/blender/imbuf/intern/cache.c | 442 ++++++++++++++++ source/blender/imbuf/intern/cineon/cineon_dpx.c | 4 +- source/blender/imbuf/intern/cmap.c | 580 -------------------- source/blender/imbuf/intern/cspace.c | 176 ------- source/blender/imbuf/intern/data.c | 142 ----- source/blender/imbuf/intern/dds/dds_api.cpp | 6 +- source/blender/imbuf/intern/dds/dds_api.h | 2 +- source/blender/imbuf/intern/dither.c | 130 ----- source/blender/imbuf/intern/divers.c | 80 --- source/blender/imbuf/intern/dynlibtiff.c | 33 +- source/blender/imbuf/intern/dynlibtiff.h | 4 + source/blender/imbuf/intern/filetype.c | 105 ++++ source/blender/imbuf/intern/filter.c | 95 +++- source/blender/imbuf/intern/gen_dynlibtiff.py | 303 ----------- source/blender/imbuf/intern/ham.c | 276 ---------- source/blender/imbuf/intern/hamx.c | 581 --------------------- source/blender/imbuf/intern/iff.c | 224 -------- source/blender/imbuf/intern/imageprocess.c | 2 + source/blender/imbuf/intern/imbuf.h | 95 +--- source/blender/imbuf/intern/imbuf_cocoa.m | 4 +- source/blender/imbuf/intern/imbuf_patch.h | 111 ---- source/blender/imbuf/intern/imginfo.c | 158 ------ source/blender/imbuf/intern/iris.c | 50 +- source/blender/imbuf/intern/jp2.c | 7 +- source/blender/imbuf/intern/jpeg.c | 45 +- source/blender/imbuf/intern/matrix.h | 84 --- source/blender/imbuf/intern/metadata.c | 159 ++++++ source/blender/imbuf/intern/module.c | 40 ++ .../blender/imbuf/intern/openexr/openexr_api.cpp | 34 +- source/blender/imbuf/intern/openexr/openexr_api.h | 2 +- source/blender/imbuf/intern/png.c | 38 +- source/blender/imbuf/intern/radiance_hdr.c | 9 +- source/blender/imbuf/intern/readimage.c | 326 ++++-------- source/blender/imbuf/intern/rectop.c | 1 - source/blender/imbuf/intern/rotate.c | 1 - source/blender/imbuf/intern/scaling.c | 189 ------- source/blender/imbuf/intern/targa.c | 90 ++-- source/blender/imbuf/intern/thumbs.c | 28 +- source/blender/imbuf/intern/tiff.c | 284 ++++++---- source/blender/imbuf/intern/util.c | 120 +---- source/blender/imbuf/intern/writeimage.c | 172 +----- source/blender/makesdna/DNA_image_types.h | 2 +- source/blender/makesrna/intern/rna_image.c | 5 - source/blender/quicktime/apple/qtkit_import.m | 9 +- source/blender/quicktime/apple/quicktime_import.c | 2 + source/blender/windowmanager/intern/wm_init_exit.c | 6 - source/creator/creator.c | 24 +- .../GamePlayer/ghost/GPG_Application.cpp | 5 +- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 6 +- 105 files changed, 2026 insertions(+), 7654 deletions(-) delete mode 100644 source/blender/imbuf/intern/IMB_amiga.h delete mode 100644 source/blender/imbuf/intern/IMB_anim5.h delete mode 100644 source/blender/imbuf/intern/IMB_bitplanes.h delete mode 100644 source/blender/imbuf/intern/IMB_bmp.h delete mode 100644 source/blender/imbuf/intern/IMB_cmap.h delete mode 100644 source/blender/imbuf/intern/IMB_cocoa.h delete mode 100644 source/blender/imbuf/intern/IMB_divers.h delete mode 100644 source/blender/imbuf/intern/IMB_dpxcineon.h create mode 100644 source/blender/imbuf/intern/IMB_filetype.h delete mode 100644 source/blender/imbuf/intern/IMB_ham.h delete mode 100644 source/blender/imbuf/intern/IMB_hamx.h delete mode 100644 source/blender/imbuf/intern/IMB_iff.h delete mode 100644 source/blender/imbuf/intern/IMB_imginfo.h delete mode 100644 source/blender/imbuf/intern/IMB_iris.h delete mode 100644 source/blender/imbuf/intern/IMB_jp2.h delete mode 100644 source/blender/imbuf/intern/IMB_jpeg.h create mode 100644 source/blender/imbuf/intern/IMB_metadata.h delete mode 100644 source/blender/imbuf/intern/IMB_png.h delete mode 100644 source/blender/imbuf/intern/IMB_radiance_hdr.h delete mode 100644 source/blender/imbuf/intern/IMB_targa.h delete mode 100644 source/blender/imbuf/intern/IMB_tiff.h delete mode 100644 source/blender/imbuf/intern/amiga.c delete mode 100644 source/blender/imbuf/intern/anim5.c delete mode 100644 source/blender/imbuf/intern/antialias.c delete mode 100644 source/blender/imbuf/intern/bitplanes.c create mode 100644 source/blender/imbuf/intern/cache.c delete mode 100644 source/blender/imbuf/intern/cmap.c delete mode 100644 source/blender/imbuf/intern/cspace.c delete mode 100644 source/blender/imbuf/intern/data.c delete mode 100644 source/blender/imbuf/intern/dither.c create mode 100644 source/blender/imbuf/intern/filetype.c delete mode 100755 source/blender/imbuf/intern/gen_dynlibtiff.py delete mode 100644 source/blender/imbuf/intern/ham.c delete mode 100644 source/blender/imbuf/intern/hamx.c delete mode 100644 source/blender/imbuf/intern/iff.c delete mode 100644 source/blender/imbuf/intern/imbuf_patch.h delete mode 100644 source/blender/imbuf/intern/imginfo.c delete mode 100644 source/blender/imbuf/intern/matrix.h create mode 100644 source/blender/imbuf/intern/metadata.c create mode 100644 source/blender/imbuf/intern/module.c diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 915f59be01a..7bdb9aaf709 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -55,7 +55,6 @@ int BKE_imtype_is_movie(int imtype); struct anim *openanim(char * name, int flags); -void converttopremul(struct ImBuf *ibuf); void image_de_interlace(struct Image *ima, int odd); void tag_image_time(struct Image *ima); diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 3ccf068d6c8..42c492d3237 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -100,7 +100,7 @@ void free_blender(void) BKE_spacetypes_free(); /* after free main, it uses space callbacks */ - IMB_freeImBufdata(); /* imbuf lib */ + IMB_exit(); free_nodesystem(); } diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c index 1b053b45859..e2a6c04450b 100644 --- a/source/blender/blenkernel/intern/bmfont.c +++ b/source/blender/blenkernel/intern/bmfont.c @@ -174,7 +174,7 @@ void detectBitmapFont(ImBuf *ibuf) unsigned short version; int i; - if (ibuf != NULL) { + if (ibuf != NULL && ibuf->rect != NULL) { // bitmap must have an x size that is a power of two if (is_power_of_two(ibuf->x)) { rect = (unsigned char *) (ibuf->rect + (ibuf->x * (ibuf->y - 1))); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 2c71cc9310a..a377bbed24c 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -92,58 +92,6 @@ /* ******** IMAGE PROCESSING ************* */ -/* used by sequencer and image premul option - IMA_DO_PREMUL */ -void converttopremul(struct ImBuf *ibuf) -{ - int x, y; - - if(ibuf==0) return; - if (ibuf->rect) { - int val; - char *cp; - if(ibuf->depth==24) { /* put alpha at 255 */ - cp= (char *)(ibuf->rect); - for(y=0; yy; y++) { - for(x=0; xx; x++, cp+=4) { - cp[3]= 255; - } - } - } else { - cp= (char *)(ibuf->rect); - for(y=0; yy; y++) { - for(x=0; xx; x++, cp+=4) { - val= cp[3]; - cp[0]= (cp[0]*val)>>8; - cp[1]= (cp[1]*val)>>8; - cp[2]= (cp[2]*val)>>8; - } - } - } - } - if (ibuf->rect_float) { - float val; - float *cp; - if(ibuf->depth==24) { /* put alpha at 1.0 */ - cp= ibuf->rect_float;; - for(y=0; yy; y++) { - for(x=0; xx; x++, cp+=4) { - cp[3]= 1.0; - } - } - } else { - cp= ibuf->rect_float; - for(y=0; yy; y++) { - for(x=0; xx; x++, cp+=4) { - val= cp[3]; - cp[0]= cp[0]*val; - cp[1]= cp[1]*val; - cp[2]= cp[2]*val; - } - } - } - } -} - static void de_interlace_ng(struct ImBuf *ibuf) /* neogeo fields */ { struct ImBuf * tbuf1, * tbuf2; @@ -735,8 +683,6 @@ int BKE_imtype_to_ftype(int imtype) return TGA; else if(imtype==R_RAWTGA) return RAWTGA; - else if(imtype==R_HAMX) - return AN_hamx; #ifdef WITH_OPENJPEG else if(imtype==R_JP2) return JP2; @@ -773,8 +719,6 @@ int BKE_ftype_to_imtype(int ftype) return R_TARGA; else if(ftype & RAWTGA) return R_RAWTGA; - else if(ftype == AN_hamx) - return R_HAMX; #ifdef WITH_OPENJPEG else if(ftype & JP2) return R_JP2; @@ -787,7 +731,6 @@ int BKE_ftype_to_imtype(int ftype) int BKE_imtype_is_movie(int imtype) { switch(imtype) { - case R_MOVIE: case R_AVIRAW: case R_AVIJPEG: case R_AVICODEC: @@ -864,7 +807,7 @@ void BKE_add_image_extension(char *string, int imtype) extension= ".jp2"; } #endif - else { // R_MOVIE, R_AVICODEC, R_AVIRAW, R_AVIJPEG, R_JPEG90, R_QUICKTIME etc + else { // R_AVICODEC, R_AVIRAW, R_AVIJPEG, R_JPEG90, R_QUICKTIME etc if(!( BLI_testextensie(string, ".jpg") || BLI_testextensie(string, ".jpeg"))) extension= ".jpg"; } @@ -1211,15 +1154,15 @@ void BKE_stamp_info(Scene *scene, struct ImBuf *ibuf) /* fill all the data values, no prefix */ stampdata(scene, &stamp_data, 0); - if (stamp_data.file[0]) IMB_imginfo_change_field (ibuf, "File", stamp_data.file); - if (stamp_data.note[0]) IMB_imginfo_change_field (ibuf, "Note", stamp_data.note); - if (stamp_data.date[0]) IMB_imginfo_change_field (ibuf, "Date", stamp_data.date); - if (stamp_data.marker[0]) IMB_imginfo_change_field (ibuf, "Marker", stamp_data.marker); - if (stamp_data.time[0]) IMB_imginfo_change_field (ibuf, "Time", stamp_data.time); - if (stamp_data.frame[0]) IMB_imginfo_change_field (ibuf, "Frame", stamp_data.frame); - if (stamp_data.camera[0]) IMB_imginfo_change_field (ibuf, "Camera", stamp_data.camera); - if (stamp_data.scene[0]) IMB_imginfo_change_field (ibuf, "Scene", stamp_data.scene); - if (stamp_data.strip[0]) IMB_imginfo_change_field (ibuf, "Strip", stamp_data.strip); + if (stamp_data.file[0]) IMB_metadata_change_field (ibuf, "File", stamp_data.file); + if (stamp_data.note[0]) IMB_metadata_change_field (ibuf, "Note", stamp_data.note); + if (stamp_data.date[0]) IMB_metadata_change_field (ibuf, "Date", stamp_data.date); + if (stamp_data.marker[0]) IMB_metadata_change_field (ibuf, "Marker", stamp_data.marker); + if (stamp_data.time[0]) IMB_metadata_change_field (ibuf, "Time", stamp_data.time); + if (stamp_data.frame[0]) IMB_metadata_change_field (ibuf, "Frame", stamp_data.frame); + if (stamp_data.camera[0]) IMB_metadata_change_field (ibuf, "Camera", stamp_data.camera); + if (stamp_data.scene[0]) IMB_metadata_change_field (ibuf, "Scene", stamp_data.scene); + if (stamp_data.strip[0]) IMB_metadata_change_field (ibuf, "Strip", stamp_data.strip); } int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimtype, int quality) @@ -1273,9 +1216,6 @@ int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimt else if(imtype==R_RAWTGA) { ibuf->ftype= RAWTGA; } - else if(imtype==R_HAMX) { - ibuf->ftype= AN_hamx; - } #ifdef WITH_OPENJPEG else if(imtype==R_JP2) { if(quality < 10) quality= 90; @@ -1299,7 +1239,7 @@ int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimt } #endif else { - /* R_JPEG90, R_MOVIE, etc. default we save jpegs */ + /* R_JPEG90, etc. default we save jpegs */ if(quality < 10) quality= 90; ibuf->ftype= JPG|quality; if(ibuf->depth==32) ibuf->depth= 24; /* unsupported feature only confuses other s/w */ @@ -1595,6 +1535,7 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) struct ImBuf *ibuf; unsigned short numlen; char name[FILE_MAX], head[FILE_MAX], tail[FILE_MAX]; + int flag; /* XXX temp stuff? */ if(ima->lastframe != frame) @@ -1611,8 +1552,12 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) else BLI_path_abs(name, G.sce); + flag= IB_rect|IB_multilayer; + if(ima->flag & IMA_DO_PREMUL) + flag |= IB_premul; + /* read ibuf */ - ibuf = IMB_loadiffname(name, IB_rect|IB_multilayer); + ibuf = IMB_loadiffname(name, flag); if(G.f & G_DEBUG) printf("loaded %s\n", name); if (ibuf) { @@ -1632,10 +1577,6 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) image_initialize_after_load(ima, ibuf); image_assign_ibuf(ima, ibuf, 0, frame); #endif - - if(ima->flag & IMA_DO_PREMUL) - converttopremul(ibuf); - } else ima->ok= 0; @@ -1718,7 +1659,7 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame) else BLI_path_abs(str, G.sce); - ima->anim = openanim(str, IB_cmap | IB_rect); + ima->anim = openanim(str, IB_rect); /* let's initialize this user */ if(ima->anim && iuser && iuser->frames==0) @@ -1749,21 +1690,25 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame) return ibuf; } -/* cfra used for # code, Image can only have this # for all its users */ +/* cfra used for # code, Image can only have this # for all its users + * warning, 'iuser' can be NULL */ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) { struct ImBuf *ibuf; char str[FILE_MAX]; - int assign = 0; + int assign = 0, flag; /* always ensure clean ima */ image_free_buffers(ima); /* is there a PackedFile with this image ? */ if (ima->packedfile) { - ibuf = IMB_ibImageFromMemory((int *) ima->packedfile->data, ima->packedfile->size, IB_rect|IB_multilayer); + ibuf = IMB_ibImageFromMemory((unsigned char*)ima->packedfile->data, ima->packedfile->size, IB_rect|IB_multilayer); } else { + flag= IB_rect|IB_multilayer|IB_metadata; + if(ima->flag & IMA_DO_PREMUL) + flag |= IB_premul; /* get the right string */ BLI_strncpy(str, ima->name, sizeof(str)); @@ -1775,7 +1720,7 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) BLI_path_frame(str, cfra, 0); /* read ibuf */ - ibuf = IMB_loadiffname(str, IB_rect|IB_multilayer|IB_imginfo); + ibuf = IMB_loadiffname(str, flag); } if (ibuf) { @@ -1797,9 +1742,6 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) if ((ima->packedfile == NULL) && (G.fileflags & G_AUTOPACK)) ima->packedfile = newPackedFile(NULL, str); } - - if(ima->flag & IMA_DO_PREMUL) - converttopremul(ibuf); } else ima->ok= 0; diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 52c6f9355a3..9e95581b211 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -264,38 +264,6 @@ int multiresModifier_reshapeFromDeformMod(MultiresModifierData *mmd, Object *ob, return result; } -static void multires_set_tot_mdisps(Mesh *me, int lvl) -{ - MDisps *mdisps= CustomData_get_layer(&me->fdata, CD_MDISPS); - int i; - - if(mdisps) { - for(i = 0; i < me->totface; i++) { - if(mdisps[i].totdisp == 0) { - int nvert = (me->mface[i].v4)? 4: 3; - mdisps[i].totdisp = multires_grid_tot[lvl]*nvert; - } - } - } -} - -static void multires_reallocate_mdisps(Mesh *me, MDisps *mdisps, int lvl) -{ - int i; - - /* reallocate displacements to be filled in */ - for(i = 0; i < me->totface; ++i) { - int nvert = (me->mface[i].v4)? 4: 3; - int totdisp = multires_grid_tot[lvl]*nvert; - float (*disps)[3] = MEM_callocN(sizeof(float) * 3 * totdisp, "multires disps"); - - if(mdisps[i].disps) - MEM_freeN(mdisps[i].disps); - - mdisps[i].disps = disps; - mdisps[i].totdisp = totdisp; - } -} static void column_vectors_to_mat3(float mat[][3], float v1[3], float v2[3], float v3[3]) { @@ -352,7 +320,6 @@ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int dire int levels = mmd->totlvl - lvl; MDisps *mdisps; - multires_set_tot_mdisps(me, mmd->totlvl); CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); mdisps= CustomData_get_layer(&me->fdata, CD_MDISPS); @@ -426,6 +393,24 @@ static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl return subsurf_make_derived_from_derived(dm, &smd, 0, NULL, 0, 0); } +static void multires_reallocate_mdisps(Mesh *me, MDisps *mdisps, int lvl) +{ + int i; + + /* reallocate displacements to be filled in */ + for(i = 0; i < me->totface; ++i) { + int nvert = (me->mface[i].v4)? 4: 3; + int totdisp = multires_grid_tot[lvl]*nvert; + float (*disps)[3] = MEM_callocN(sizeof(float) * 3 * totdisp, "multires disps"); + + if(mdisps[i].disps) + MEM_freeN(mdisps[i].disps); + + mdisps[i].disps = disps; + mdisps[i].totdisp = totdisp; + } +} + void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int updateblock, int simple) { Mesh *me = ob->data; @@ -630,7 +615,6 @@ static void multiresModifier_update(DerivedMesh *dm) ob = ccgdm->multires.ob; me = ccgdm->multires.ob->data; mmd = ccgdm->multires.mmd; - multires_set_tot_mdisps(me, mmd->totlvl); CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); mdisps = CustomData_get_layer(&me->fdata, CD_MDISPS); @@ -766,7 +750,6 @@ DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, int loca memcpy(subGridData[i], gridData[i], sizeof(DMGridData)*gridSize*gridSize); } - multires_set_tot_mdisps(me, mmd->totlvl); CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); multiresModifier_disp_run(result, ob->data, 0, 0, subGridData, mmd->totlvl); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index e48c4ea718c..4a9624036ff 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1777,7 +1777,7 @@ static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cf if(seq->flag & SEQ_MAKE_PREMUL) { if(se->ibuf->depth == 32 && se->ibuf->zbuf == 0) { - converttopremul(se->ibuf); + IMB_premultiply_alpha(se->ibuf); } } diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index f4bcb6d412f..00614ef0f4f 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -75,11 +75,6 @@ bMovieHandle *BKE_get_movie_handle(int imtype) mh.get_movie_path = filepath_avi; /* do the platform specific handles */ -#ifdef __sgi - if (imtype == R_MOVIE) { - - } -#endif #if defined(_WIN32) && !defined(FREE_WINDOWS) if (imtype == R_AVICODEC) { //XXX mh.start_movie= start_avi_codec; diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 91e743271d2..02d5fb27dc9 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -71,6 +71,7 @@ MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f); MINLINE void mul_v2_v2(float r[2], const float a[2]); MINLINE void mul_v3_v3(float r[3], const float a[3]); MINLINE void mul_v3_v3v3(float r[3], const float a[3], const float b[3]); +MINLINE void mul_v4_fl(float r[4], float f); MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f); MINLINE void madd_v3_v3v3(float r[3], const float a[3], const float b[3]); diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 45bbd9f60a2..9bdc6c431e8 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -33,11 +33,6 @@ #ifndef BLI_UTIL_H #define BLI_UTIL_H -/* XXX doesn't seem to be used, marded for removal -#define mallocstructN(x,y,name) (x*)MEM_mallocN((y)* sizeof(x),name) -#define callocstructN(x,y,name) (x*)MEM_callocN((y)* sizeof(x),name) -*/ - struct ListBase; struct direntry; @@ -61,6 +56,7 @@ void BLI_join_dirfile(char *string, const char *dir, const char *file); int BKE_rebase_path(char *abs, int abs_size, char *rel, int rel_size, const char *base_dir, const char *src_dir, const char *dest_dir); void BLI_getlastdir(const char* dir, char *last, int maxlen); int BLI_testextensie(const char *str, const char *ext); +int BLI_replace_extension(char *path, int maxlen, const char *ext); void BLI_uniquename(struct ListBase *list, void *vlink, const char defname[], char delim, short name_offs, short len); void BLI_newname(char * name, int add); int BLI_stringdec(const char *string, char *head, char *start, unsigned short *numlen); diff --git a/source/blender/blenlib/BLI_storage.h b/source/blender/blenlib/BLI_storage.h index 61f175cb772..0d9db40fc97 100644 --- a/source/blender/blenlib/BLI_storage.h +++ b/source/blender/blenlib/BLI_storage.h @@ -76,5 +76,8 @@ struct LinkNode *BLI_read_file_as_lines(char *name); */ void BLI_free_file_lines(struct LinkNode *lines); + /* Compare if one was last modified before the other */ +int BLI_file_older(const char *file1, const char *file2); + #endif /* BLI_STORAGE_H */ diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 974832051af..fa8d1a30269 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -188,6 +188,14 @@ MINLINE void mul_v3_v3(float r[3], const float a[3]) r[2] *= a[2]; } +MINLINE void mul_v4_fl(float r[4], float f) +{ + r[0]*= f; + r[1]*= f; + r[2]*= f; + r[3]*= f; +} + MINLINE void madd_v2_v2fl(float r[2], const float a[2], float f) { r[0] += a[0]*f; diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 454663df1ae..85d18d99f96 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -1109,6 +1109,24 @@ int BLI_testextensie(const char *str, const char *ext) return (retval); } +int BLI_replace_extension(char *path, int maxlen, const char *ext) +{ + int a; + + for(a=strlen(path)-1; a>=0; a--) + if(path[a] == '.' || path[a] == '/' || path[a] == '\\') + break; + + if(path[a] != '.') + a= strlen(path); + + if(a + strlen(ext) >= maxlen) + return 0; + + strcpy(path+a, ext); + return 1; +} + /* Converts "/foo/bar.txt" to "/foo/" and "bar.txt" * - wont change 'string' * - wont create any directories diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index d9fea2483b9..51d5f0354f9 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -500,3 +500,14 @@ void BLI_free_file_lines(LinkNode *lines) { BLI_linklist_free(lines, (void(*)(void*)) MEM_freeN); } + +int BLI_file_older(const char *file1, const char *file2) +{ + struct stat st1, st2; + + if(stat(file1, &st1)) return 0; + if(stat(file2, &st2)) return 0; + + return (st1.st_mtime < st2.st_mtime); +} + diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 42a3aebea2d..08835c4cb28 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8453,8 +8453,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main) ima->flag |= IMA_FIELDS; if(tex->imaflag & TEX_STD_FIELD_) ima->flag |= IMA_STD_FIELD; - if(tex->imaflag & TEX_ANTIALI_) - ima->flag |= IMA_ANTIALI; } tex->iuser.frames= tex->frames; tex->iuser.fie_ima= tex->fie_ima; diff --git a/source/blender/blenpluginapi/iff.h b/source/blender/blenpluginapi/iff.h index 9378cdc9134..b8628b00575 100644 --- a/source/blender/blenpluginapi/iff.h +++ b/source/blender/blenpluginapi/iff.h @@ -35,123 +35,19 @@ #include "util.h" #include "externdef.h" -#define IB_rect (1 << 0) -#define IB_planes (1 << 1) -#define IB_cmap (1 << 2) -#define IB_test (1 << 7) - -#define IB_fields (1 << 11) -#define IB_yuv (1 << 12) -#define IB_zbuf (1 << 13) -#define IB_rgba (1 << 14) - -#define JP2 (1 << 18) - -#define AMI (1 << 31) -#define PNG (1 << 30) -#define Anim (1 << 29) -#define TGA (1 << 28) -#define JPG (1 << 27) -#define BMP (1 << 26) -#ifdef WITH_QUICKTIME -#define QUICKTIME (1 << 25) -#endif -#define RADHDR (1<<24) - -#define RAWTGA (TGA | 1) - -#define JPG_STD (JPG | (0 << 8)) -#define JPG_VID (JPG | (1 << 8)) -#define JPG_JST (JPG | (2 << 8)) -#define JPG_MAX (JPG | (3 << 8)) -#define JPG_MSK (0xffffff00) - -#define AM_ham (0x0800 | AMI) -#define AM_hbrite (0x0080 | AMI) -#define AM_lace (0x0004 | AMI) -#define AM_hires (0x8000 | AMI) -#define AM_hblace (AM_hbrite | AM_lace) -#define AM_hilace (AM_hires | AM_lace) -#define AM_hamlace (AM_ham | AM_lace) - -#define RGB888 1 -#define RGB555 2 -#define DYUV 3 -#define CLUT8 4 -#define CLUT7 5 -#define CLUT4 6 -#define CLUT3 7 -#define RL7 8 -#define RL3 9 -#define MPLTE 10 - -#define DYUV1 0 -#define C233 1 -#define YUVX 2 -#define HAMX 3 -#define TANX 4 - -#define AN_c233 (Anim | C233) -#define AN_yuvx (Anim | YUVX) -#define AN_hamx (Anim | HAMX) -#define AN_tanx (Anim | TANX) - -#define IS_amiga(x) (x->ftype & AMI) -#define IS_ham(x) ((x->ftype & AM_ham) == AM_ham) -#define IS_hbrite(x) ((x->ftype & AM_hbrite) == AM_hbrite) - -#define IS_lace(x) ((x->ftype & AM_lace) == AM_lace) -#define IS_hires(x) ((x->ftype & AM_hires) == AM_hires) -#define IS_hblace(x) ((x->ftype & AM_hblace) == AM_hblace) -#define IS_hilace(x) ((x->ftype & AM_hilace) == AM_hilace) -#define IS_hamlace(x) ((x->ftype & AM_hamlace) == AM_hamlace) - -#define IS_anim(x) (x->ftype & Anim) -#define IS_hamx(x) (x->ftype == AN_hamx) -#define IS_tga(x) (x->ftype & TGA) -#define IS_png(x) (x->ftype & PNG) -#define IS_bmp(x) (x->ftype & BMP) -#define IS_radhdr(x) (x->ftype & RADHDR) -#define IS_tim(x) (x->ftype & TIM) -#define IS_tiff(x) (x->ftype & TIFF) -#define IS_openexr(x) (x->ftype & OPENEXR) -#define IS_jp2(x) (x->ftype & JP2) - - -#define IMAGIC 0732 -#define IS_iris(x) (x->ftype == IMAGIC) - -#define IS_jpg(x) (x->ftype & JPG) -#define IS_stdjpg(x) ((x->ftype & JPG_MSK) == JPG_STD) -#define IS_vidjpg(x) ((x->ftype & JPG_MSK) == JPG_VID) -#define IS_jstjpg(x) ((x->ftype & JPG_MSK) == JPG_JST) -#define IS_maxjpg(x) ((x->ftype & JPG_MSK) == JPG_MAX) - -#define AN_INIT an_stringdec = stringdec; an_stringenc = stringenc; - -#define IB_MIPMAP_LEVELS 10 - -struct MEM_CacheLimiterHandle_s; +struct ImMetaData; + +#define IB_MIPMAP_LEVELS 20 +#define IB_FILENAME_SIZE 1023 typedef struct ImBuf { struct ImBuf *next, *prev; /**< allow lists of ImBufs, for caches or flipbooks */ short x, y; /**< width and Height of our image buffer */ - short skipx; /**< Width in ints to get to the next scanline */ unsigned char depth; /**< Active amount of bits/bitplanes */ - unsigned char cbits; /**< Amount of active bits in cmap */ - unsigned short mincol; /**< smallest color in colormap */ - unsigned short maxcol; /**< Largest color in colormap */ - int type; /**< 0=abgr, 1=bitplanes */ - int ftype; /**< File type we are going to save as */ - unsigned int *cmap; /**< Color map data. */ unsigned int *rect; /**< pixel values stored here */ - unsigned int **planes; /**< bitplanes */ + unsigned int *crect; /**< color corrected pixel values stored here */ int flags; /**< Controls which components should exist. */ int mall; /**< what is malloced internal, and can be freed */ - short xorig, yorig; /**< Cordinates of first pixel of an image used in some formats (example: targa) */ - char name[1023]; /**< The file name assocated with this image */ - char namenull; /**< Unused don't want to remove it thought messes things up */ - int userflags; /**< Used to set imbuf to Dirty and other stuff */ int *zbuf; /**< z buffer data, original zbuffer */ float *zbuf_float; /**< z buffer data, camera coordinates */ void *userdata; /**< temporary storage, only used by baking at the moment */ @@ -159,34 +55,43 @@ typedef struct ImBuf { unsigned int encodedsize; /**< Size of data written to encodedbuffer */ unsigned int encodedbuffersize; /**< Size of encodedbuffer */ - float *rect_float; /**< floating point Rect equivilant */ + float *rect_float; /**< floating point Rect equivalent + Linear RGB color space - may need gamma correction to + sRGB when generating 8bit representations */ int channels; /**< amount of channels in rect_float (0 = 4 channel default) */ float dither; /**< random dither value, for conversion from float -> byte rect */ - - struct MEM_CacheLimiterHandle_s * c_handle; /**< handle for cache limiter */ - struct ImgInfo * img_info; - int refcounter; /**< Refcounter for multiple users */ - int index; /**< reference index for ImBuf lists */ - + short profile; /** color space/profile preset that the byte rect buffer represents */ + char profile_filename[256]; /** to be implemented properly, specific filename for custom profiles */ + + /* mipmapping */ struct ImBuf *mipmap[IB_MIPMAP_LEVELS]; /**< MipMap levels, a series of halved images */ + int miplevels; + + /* externally used flags */ + int index; /* reference index for ImBuf lists */ + int userflags; /* used to set imbuf to dirty and other stuff */ + struct ImMetaData *metadata; + + /* file information */ + int ftype; /* file type we are going to save as */ + char name[IB_FILENAME_SIZE]; /* filename associated with this image */ + + /* memory cache limiter */ + struct MEM_CacheLimiterHandle_s *c_handle; /* handle for cache limiter */ + int refcounter; /* reference counter for multiple users */ } ImBuf; LIBIMPORT struct ImBuf *allocImBuf(short,short,uchar,uint,uchar); LIBIMPORT struct ImBuf *dupImBuf(struct ImBuf *); LIBIMPORT void freeImBuf(struct ImBuf*); -LIBIMPORT short converttocmap(struct ImBuf* ibuf); - LIBIMPORT short saveiff(struct ImBuf *,char *,int); -LIBIMPORT struct ImBuf *loadiffmem(int *,int); LIBIMPORT struct ImBuf *loadifffile(int,int); LIBIMPORT struct ImBuf *loadiffname(char *,int); LIBIMPORT struct ImBuf *testiffname(char *,int); LIBIMPORT struct ImBuf *onehalf(struct ImBuf *); -LIBIMPORT struct ImBuf *onethird(struct ImBuf *); -LIBIMPORT struct ImBuf *halflace(struct ImBuf *); LIBIMPORT struct ImBuf *half_x(struct ImBuf *); LIBIMPORT struct ImBuf *half_y(struct ImBuf *); LIBIMPORT struct ImBuf *double_x(struct ImBuf *); @@ -196,17 +101,11 @@ LIBIMPORT struct ImBuf *double_fast_y(struct ImBuf *); LIBIMPORT int ispic(char *); -LIBIMPORT void dit2(struct ImBuf *, short, short); -LIBIMPORT void dit0(struct ImBuf *, short, short); - LIBIMPORT struct ImBuf *scaleImBuf(struct ImBuf *, short, short); LIBIMPORT struct ImBuf *scalefastImBuf(struct ImBuf *, short, short); -LIBIMPORT struct ImBuf *scalefieldImBuf(struct ImBuf *, short, short); -LIBIMPORT struct ImBuf *scalefastfieldImBuf(struct ImBuf *, short, short); LIBIMPORT void de_interlace(struct ImBuf *ib); LIBIMPORT void interlace(struct ImBuf *ib); -LIBIMPORT void gamwarp(struct ImBuf *ibuf, double gamma); LIBIMPORT void IMB_rectcpy(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx, int desty, int srcx, int srcy, int width, int height); diff --git a/source/blender/blenpluginapi/intern/pluginapi.c b/source/blender/blenpluginapi/intern/pluginapi.c index 28bc06eaea0..9e739f7927d 100644 --- a/source/blender/blenpluginapi/intern/pluginapi.c +++ b/source/blender/blenpluginapi/intern/pluginapi.c @@ -118,11 +118,6 @@ LIBEXPORT void freeImBuf(struct ImBuf* ib) IMB_freeImBuf(ib); } -LIBEXPORT short converttocmap(struct ImBuf* ibuf) -{ - return IMB_converttocmap(ibuf); -} - LIBEXPORT short saveiff(struct ImBuf *ib, char *c, int i) @@ -130,11 +125,6 @@ LIBEXPORT short saveiff(struct ImBuf *ib, return IMB_saveiff(ib, c, i); } -LIBEXPORT struct ImBuf *loadiffmem(int *mem,int flags) -{ - return IMB_loadiffmem(mem, flags); -} - LIBEXPORT struct ImBuf *loadifffile(int a, int b) { @@ -158,16 +148,6 @@ LIBEXPORT struct ImBuf *onehalf(struct ImBuf *ib) return IMB_onehalf(ib); } -LIBEXPORT struct ImBuf *onethird(struct ImBuf *ib) -{ - return IMB_onethird(ib); -} - -LIBEXPORT struct ImBuf *halflace(struct ImBuf *ib) -{ - return IMB_halflace(ib); -} - LIBEXPORT struct ImBuf *half_x(struct ImBuf *ib) { return IMB_half_x(ib); @@ -203,20 +183,6 @@ LIBEXPORT int ispic(char * name) return IMB_ispic(name); } -LIBEXPORT void dit2(struct ImBuf *ib, - short a, - short b) -{ - IMB_dit2(ib, a, b); -} - -LIBEXPORT void dit0(struct ImBuf *ib, - short a, - short b) -{ - IMB_dit0(ib, a, b); -} - /* still the same name */ /* void (*ditherfunc)(struct ImBuf *, short, short){} */ @@ -234,21 +200,6 @@ LIBEXPORT struct ImBuf *scalefastImBuf(struct ImBuf *ib, return IMB_scalefastImBuf(ib, x, y); } - -LIBEXPORT struct ImBuf *scalefieldImBuf(struct ImBuf *ib, - short x, - short y) -{ - return IMB_scalefieldImBuf(ib, x, y); -} - -LIBEXPORT struct ImBuf *scalefastfieldImBuf(struct ImBuf *ib, - short x, - short y) -{ - return IMB_scalefastfieldImBuf(ib, x, y); -} - /* Extra ones that some NaN (read Ton) plugins use, * even though they aren't in the header */ @@ -258,11 +209,6 @@ LIBEXPORT void interlace(struct ImBuf *ibuf) IMB_interlace(ibuf); } -LIBEXPORT void gamwarp(struct ImBuf *ibuf, double gamma) -{ - IMB_gamwarp(ibuf,gamma); -} - LIBEXPORT void de_interlace(struct ImBuf *ib) { IMB_de_interlace(ib); @@ -334,15 +280,11 @@ int pluginapi_force_ref(void) GET_INT_FROM_POINTER( allocImBuf ) + GET_INT_FROM_POINTER( dupImBuf ) + GET_INT_FROM_POINTER( freeImBuf ) + - GET_INT_FROM_POINTER( converttocmap ) + GET_INT_FROM_POINTER( saveiff ) + - GET_INT_FROM_POINTER( loadiffmem ) + GET_INT_FROM_POINTER( loadifffile ) + GET_INT_FROM_POINTER( loadiffname ) + GET_INT_FROM_POINTER( testiffname ) + GET_INT_FROM_POINTER( onehalf ) + - GET_INT_FROM_POINTER( onethird ) + - GET_INT_FROM_POINTER( halflace ) + GET_INT_FROM_POINTER( half_x ) + GET_INT_FROM_POINTER( half_y ) + GET_INT_FROM_POINTER( double_x ) + @@ -350,17 +292,12 @@ int pluginapi_force_ref(void) GET_INT_FROM_POINTER( double_fast_x ) + GET_INT_FROM_POINTER( double_fast_y ) + GET_INT_FROM_POINTER( ispic ) + - GET_INT_FROM_POINTER( dit2 ) + - GET_INT_FROM_POINTER( dit0 ) + GET_INT_FROM_POINTER( scaleImBuf ) + GET_INT_FROM_POINTER( scalefastImBuf ) + - GET_INT_FROM_POINTER( scalefieldImBuf ) + - GET_INT_FROM_POINTER( scalefastfieldImBuf ) + GET_INT_FROM_POINTER( hnoise ) + GET_INT_FROM_POINTER( hnoisep ) + GET_INT_FROM_POINTER( turbulence ) + GET_INT_FROM_POINTER( turbulence1 ) + GET_INT_FROM_POINTER( de_interlace ) + - GET_INT_FROM_POINTER( interlace ) + - GET_INT_FROM_POINTER( gamwarp ); + GET_INT_FROM_POINTER( interlace ); } diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 9c5b4febc40..16ef2dd5c9b 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -469,7 +469,7 @@ void ui_draw_but_IMAGE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect //int w, h; /* hardcoded to splash, loading and freeing every draw, eek! */ - ibuf= IMB_ibImageFromMemory((int *)datatoc_splash_png, datatoc_splash_png_size, IB_rect); + ibuf= IMB_ibImageFromMemory((unsigned char*)datatoc_splash_png, datatoc_splash_png_size, IB_rect); if (!ibuf) return; diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 7ffd46c34c7..622b9ddbfdf 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -480,7 +480,7 @@ static void init_internal_icons() } } if(bbuf==NULL) - bbuf = IMB_ibImageFromMemory((int *)datatoc_blenderbuttons, datatoc_blenderbuttons_size, IB_rect); + bbuf = IMB_ibImageFromMemory((unsigned char*)datatoc_blenderbuttons, datatoc_blenderbuttons_size, IB_rect); if(bbuf) { /* free existing texture if any */ diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 122424385be..32b60b658c7 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -88,8 +88,6 @@ static int screenshot_exec(bContext *C, wmOperator *op) ibuf= IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0, 0); ibuf->rect= scd->dumprect; - if(scene->r.planes == 8) IMB_cspace(ibuf, rgb_to_bw); - BKE_write_ibuf(scene, ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality); IMB_freeImBuf(ibuf); diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index f38b06e7b85..66552088085 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -375,7 +375,7 @@ void filelist_init_icons() short x, y, k; ImBuf *bbuf; ImBuf *ibuf; - bbuf = IMB_ibImageFromMemory((int *)datatoc_prvicons, datatoc_prvicons_size, IB_rect); + bbuf = IMB_ibImageFromMemory((unsigned char*)datatoc_prvicons, datatoc_prvicons_size, IB_rect); if (bbuf) { for (y=0; yrelname, ".psd") || BLI_testextensie(file->relname, ".tif") || BLI_testextensie(file->relname, ".tiff") + || BLI_testextensie(file->relname, ".tx") || BLI_testextensie(file->relname, ".pct") || BLI_testextensie(file->relname, ".pict") || BLI_testextensie(file->relname, ".pntg") //macpaint @@ -913,6 +914,7 @@ void filelist_setfiletypes(struct FileList* filelist, short has_quicktime) || BLI_testextensie(file->relname, ".iff") || BLI_testextensie(file->relname, ".tif") || BLI_testextensie(file->relname, ".tiff") + || BLI_testextensie(file->relname, ".tx") || BLI_testextensie(file->relname, ".hdr") #ifdef WITH_DDS || BLI_testextensie(file->relname, ".dds") diff --git a/source/blender/editors/space_file/writeimage.c b/source/blender/editors/space_file/writeimage.c index d05ed3e992e..c9b30983b93 100644 --- a/source/blender/editors/space_file/writeimage.c +++ b/source/blender/editors/space_file/writeimage.c @@ -183,7 +183,6 @@ void save_image_filesel_str(Scene *scene, char *str) #endif /* default we save jpeg, also for all movie formats */ case R_JPEG90: - case R_MOVIE: case R_AVICODEC: case R_AVIRAW: case R_AVIJPEG: diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index aaae7e156cd..f7c810e3387 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -882,7 +882,6 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propn uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "fields")); col= uiLayoutColumn(split, 0); - uiItemR(col, &imaptr, "antialias", 0, NULL, 0); uiItemR(col, &imaptr, "premultiply", 0, NULL, 0); } } diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 14c58496352..37399c9d68a 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -37,40 +37,6 @@ * blenlib handles guarded memory management in blender-style. * BLI_winstuff.h makes a few windows specific behaviours * posix-compliant. - * - avi - * avi defines import/export to the avi format. Only anim.c - * needs this. It uses the following functions: - * - avi_close - * - avi_is_avi - * - avi_print_error - * - avi_open_movie - * - avi_read_frame - * - avi_get_stream - * Additionally, it needs the types from the avi module. - * - external jpeg library - * The jpeg lib defines import/export to the jpeg format. - * only jpeg.c needs these. Used functions are: - * - jpeg_destroy - * - jpeg_resync_to_restart - * - jpeg_set_marker_processor - * - jpeg_read_header - * - jpeg_start_decompress - * - jpeg_abort_decompress - * - jpeg_read_scanlines - * - jpeg_finish_decompress - * - jpeg_std_error - * - jpeg_create_decompress - * - jpeg_stdio_src - * - jpeg_start_compress - * - jpeg_write_marker - * - jpeg_write_scanlines - * - jpeg_finish_compress - * - jpeg_create_compress - * - jpeg_stdio_dest - * - jpeg_set_defaults - * - jpeg_set_quality - * - jpeg_destroy_compress - * Additionally, it needs the types from the jpeg lib. */ /* * $Id$ @@ -100,6 +66,7 @@ * * ***** END GPL LICENSE BLOCK ***** */ + #ifndef IMB_IMBUF_H #define IMB_IMBUF_H @@ -117,33 +84,16 @@ struct anim; /** * - * @attention Defined in cmap.c - */ -void IMB_freeImBufdata(void); - -/** - * - * @attention Defined in cmap.c - */ -void IMB_applycmap(struct ImBuf *ibuf); - -/** - * - * @attention Defined in cmap.c - */ -short IMB_converttocmap(struct ImBuf *ibuf); - -/** - * - * @attention Defined in cmap.c + * @attention Defined in allocimbuf.c */ -int IMB_alpha_to_col0(int value); +void IMB_init(void); +void IMB_exit(void); /** * * @attention Defined in readimage.c */ -struct ImBuf *IMB_ibImageFromMemory(int *mem, int size, int flags); +struct ImBuf *IMB_ibImageFromMemory(unsigned char *mem, int size, int flags); /** * @@ -161,7 +111,7 @@ struct ImBuf *IMB_loadiffname(const char *naam, int flags); * * @attention Defined in allocimbuf.c */ -void IMB_freeImBuf(struct ImBuf * ibuf); +void IMB_freeImBuf(struct ImBuf *ibuf); /** * @@ -180,37 +130,33 @@ struct ImBuf *IMB_allocImBuf(short x, short y, * @attention Defined in allocimbuf.c */ -void IMB_refImBuf(struct ImBuf * ibuf); +void IMB_refImBuf(struct ImBuf *ibuf); /** * * @attention Defined in allocimbuf.c */ -void IMB_cache_limiter_insert(struct ImBuf * i); -void IMB_cache_limiter_unmanage(struct ImBuf * i); -void IMB_cache_limiter_touch(struct ImBuf * i); -void IMB_cache_limiter_ref(struct ImBuf * i); -void IMB_cache_limiter_unref(struct ImBuf * i); -int IMB_cache_limiter_get_refcount(struct ImBuf * i); +void IMB_cache_limiter_insert(struct ImBuf *i); +void IMB_cache_limiter_unmanage(struct ImBuf *i); +void IMB_cache_limiter_touch(struct ImBuf *i); +void IMB_cache_limiter_ref(struct ImBuf *i); +void IMB_cache_limiter_unref(struct ImBuf *i); +int IMB_cache_limiter_get_refcount(struct ImBuf *i); -/** - * - * @attention Defined in allocimbuf.c - */ -struct ImBuf *IMB_dupImBuf(struct ImBuf *ibuf1); +void IMB_free_cache_limiter(void); /** * * @attention Defined in allocimbuf.c */ -short addzbufImBuf(struct ImBuf * ibuf); -short addzbuffloatImBuf(struct ImBuf * ibuf); +struct ImBuf *IMB_dupImBuf(struct ImBuf *ibuf1); /** * * @attention Defined in allocimbuf.c */ -void IMB_freecmapImBuf(struct ImBuf * ibuf); +short addzbufImBuf(struct ImBuf *ibuf); +short addzbuffloatImBuf(struct ImBuf *ibuf); /** * @@ -253,8 +199,8 @@ int IMB_anim_get_duration(struct anim *anim); * * @attention Defined in anim.c */ -struct anim * IMB_open_anim(const char * name, int ib_flags); -void IMB_close_anim(struct anim * anim); +struct anim *IMB_open_anim(const char *name, int ib_flags); +void IMB_close_anim(struct anim *anim); /** * @@ -262,53 +208,34 @@ void IMB_close_anim(struct anim * anim); */ int ismovie(char *name); -void IMB_anim_set_preseek(struct anim * anim, int preseek); -int IMB_anim_get_preseek(struct anim * anim); +void IMB_anim_set_preseek(struct anim *anim, int preseek); +int IMB_anim_get_preseek(struct anim *anim); /** * * @attention Defined in anim.c */ -struct ImBuf * IMB_anim_absolute(struct anim * anim, int position); +struct ImBuf *IMB_anim_absolute(struct anim *anim, int position); /** * * @attention Defined in anim.c * fetches a define previewframe, usually half way into the movie */ -struct ImBuf * IMB_anim_previewframe(struct anim * anim); +struct ImBuf *IMB_anim_previewframe(struct anim *anim); /** * * @attention Defined in anim.c */ -void IMB_free_anim_ibuf(struct anim * anim); +void IMB_free_anim_ibuf(struct anim *anim); /** * * @attention Defined in anim.c */ -void IMB_free_anim(struct anim * anim); - -/** - * - * @attention Defined in anim.c - */ -struct ImBuf * IMB_anim_nextpic(struct anim * anim); - - -/** - * - * @attention Defined in antialias.c - */ -void IMB_clever_double (struct ImBuf * ibuf); - -/** - * - * @attention Defined in antialias.c - */ -void IMB_antialias(struct ImBuf * ibuf); +void IMB_free_anim(struct anim *anim); /** * @@ -318,30 +245,34 @@ void IMB_filter(struct ImBuf *ibuf); void IMB_filterN(struct ImBuf *out, struct ImBuf *in); void IMB_filter_extend(struct ImBuf *ibuf, char *mask); void IMB_makemipmap(struct ImBuf *ibuf, int use_filter); +struct ImBuf *IMB_getmipmap(struct ImBuf *ibuf, int level); /** * - * @attention Defined in filter.c + * @attention Defined in cache.c */ -void IMB_filtery(struct ImBuf *ibuf); + +void IMB_tile_cache_params(int totthread, int maxmem); +unsigned int *IMB_gettile(struct ImBuf *ibuf, int tx, int ty, int thread); +void IMB_tiles_to_rect(struct ImBuf *ibuf); /** * - * @attention Defined in scaling.c + * @attention Defined in filter.c */ -struct ImBuf *IMB_onehalf(struct ImBuf *ibuf1); +void IMB_filtery(struct ImBuf *ibuf); /** * * @attention Defined in scaling.c */ -struct ImBuf *IMB_scaleImBuf(struct ImBuf * ibuf, short newx, short newy); +struct ImBuf *IMB_onehalf(struct ImBuf *ibuf1); /** * * @attention Defined in scaling.c */ -struct ImBuf *IMB_scalefieldImBuf(struct ImBuf *ibuf, short newx, short newy); +struct ImBuf *IMB_scaleImBuf(struct ImBuf *ibuf, short newx, short newy); /** * @@ -372,13 +303,13 @@ int IMB_ispic(char *name); * * @attention Defined in util.c */ -int IMB_isanim(char * name); +int IMB_isanim(char *name); /** * * @attention Defined in util.c */ -int imb_get_anim_type(char * name); +int imb_get_anim_type(char *name); /** * @@ -386,7 +317,6 @@ int imb_get_anim_type(char * name); */ void IMB_de_interlace(struct ImBuf *ibuf); void IMB_interlace(struct ImBuf *ibuf); -void IMB_gamwarp(struct ImBuf *ibuf, double gamma); void IMB_rect_from_float(struct ImBuf *ibuf); void IMB_float_from_rect(struct ImBuf *ibuf); @@ -397,18 +327,6 @@ void IMB_float_from_rect(struct ImBuf *ibuf); * @attention Defined in imageprocess.c */ void IMB_convert_rgba_to_abgr(struct ImBuf *ibuf); -/** - * - * @attention defined in imageprocess.c - */ -void bicubic_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout); -void neareast_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout); -void bilinear_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout); - -void bicubic_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v); -void neareast_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v); -void bilinear_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v); -void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v); /** * Change the ordering of the color bytes pointed to by rect from @@ -420,11 +338,16 @@ void IMB_convert_bgra_to_rgba(int size, unsigned int *rect); /** * - * @attention defined in scaling.c + * @attention defined in imageprocess.c */ -struct ImBuf *IMB_scalefastfieldImBuf(struct ImBuf *ibuf, - short newx, - short newy); +void bicubic_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout); +void neareast_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout); +void bilinear_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout); + +void bicubic_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v); +void neareast_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v); +void bilinear_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v); +void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v); /** * @@ -478,68 +401,23 @@ struct ImBuf *IMB_double_fast_y(struct ImBuf *ibuf1); */ struct ImBuf *IMB_double_y(struct ImBuf *ibuf1); -/** - * - * @attention defined in scaling.c - */ -struct ImBuf *IMB_onethird(struct ImBuf *ibuf1); - -/** - * - * @attention defined in scaling.c - */ -struct ImBuf *IMB_halflace(struct ImBuf *ibuf1); - -/** - * - * @attention defined in dither.c - */ -void IMB_dit2(struct ImBuf * ibuf, short ofs, short bits); - -/** - * - * @attention defined in dither.c - */ -void IMB_dit0(struct ImBuf * ibuf, short ofs, short bits); - -/** Externally used vars: fortunately they do not use funny types */ - -/** - * boolean toggle that tells whether or not to - * scale the color map in the y-direction. - * - * @attention declared in hamx.c - */ -extern int scalecmapY; - -/** - * This 'matrix' defines the transformation from rgb to bw color - * maps. You need to do a sort of dot-product for that. It is a matrix - * with fixed coefficients, extracted from some book. - * - * @attention Defined in matrix.h, only included in hamx.c - */ -extern float rgb_to_bw[4][4]; - /** * * @attention Defined in rotate.c */ void IMB_flipx(struct ImBuf *ibuf); -void IMB_flipy(struct ImBuf * ibuf); +void IMB_flipy(struct ImBuf *ibuf); -/** - * - * @attention Defined in cspace.c - */ -void IMB_cspace(struct ImBuf *ibuf, float mat[][4]); +/* Premultiply alpha */ + +void IMB_premultiply_alpha(struct ImBuf *ibuf); /** * * @attention Defined in allocimbuf.c */ -void IMB_freezbufImBuf(struct ImBuf * ibuf); -void IMB_freezbuffloatImBuf(struct ImBuf * ibuf); +void IMB_freezbufImBuf(struct ImBuf *ibuf); +void IMB_freezbuffloatImBuf(struct ImBuf *ibuf); /** * @@ -551,34 +429,19 @@ void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, i /* this should not be here, really, we needed it for operating on render data, IMB_rectfill_area calls it */ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float *col, int x1, int y1, int x2, int y2); -/* defined in imginfo.c */ -int IMB_imginfo_change_field(struct ImBuf *img, const char *key, const char *field); +/* defined in metadata.c */ +int IMB_metadata_change_field(struct ImBuf *img, const char *key, const char *field); /* exported for image tools in blender, to quickly allocate 32 bits rect */ -short imb_addrectImBuf(struct ImBuf * ibuf); -void imb_freerectImBuf(struct ImBuf * ibuf); +short imb_addrectImBuf(struct ImBuf *ibuf); +void imb_freerectImBuf(struct ImBuf *ibuf); -short imb_addrectfloatImBuf(struct ImBuf * ibuf); -void imb_freerectfloatImBuf(struct ImBuf * ibuf); -void imb_freemipmapImBuf(struct ImBuf * ibuf); +short imb_addrectfloatImBuf(struct ImBuf *ibuf); +void imb_freerectfloatImBuf(struct ImBuf *ibuf); +void imb_freemipmapImBuf(struct ImBuf *ibuf); -#ifdef WITH_QUICKTIME -/** - * - * @attention Defined in quicktime_import.c - */ -void quicktime_init(void); - -/** - * - * @attention Defined in quicktime_import.c - */ -void quicktime_exit(void); - -#endif //WITH_QUICKTIME - -/* intern/dynlibtiff.c */ -void libtiff_init(void); -void libtiff_exit(void); +short imb_addtilesImBuf(struct ImBuf *ibuf); +void imb_freetilesImBuf(struct ImBuf *ibuf); #endif + diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h index 6c58641a0d5..e0dcc344016 100644 --- a/source/blender/imbuf/IMB_imbuf_types.h +++ b/source/blender/imbuf/IMB_imbuf_types.h @@ -48,14 +48,10 @@ #ifndef IMB_IMBUF_TYPES_H #define IMB_IMBUF_TYPES_H -#include /* for size_t */ -#include "DNA_listBase.h" /* for ListBase */ -struct _AviMovie; -struct Mdec; +struct ImMetaData; -struct ImgInfo; - -#define IB_MIPMAP_LEVELS 10 +#define IB_MIPMAP_LEVELS 20 +#define IB_FILENAME_SIZE 1023 /** * \brief The basic imbuf type @@ -73,56 +69,69 @@ struct ImgInfo; */ typedef struct ImBuf { struct ImBuf *next, *prev; /**< allow lists of ImBufs, for caches or flipbooks */ - short x, y; /**< width and Height of our image buffer */ - short skipx; /**< Width in ints to get to the next scanline */ - unsigned char depth; /**< Active amount of bits/bitplanes */ - unsigned char cbits; /**< Amount of active bits in cmap */ - unsigned short mincol; /**< smallest color in colormap */ - unsigned short maxcol; /**< Largest color in colormap */ - int type; /**< 0=abgr, 1=bitplanes */ - int ftype; /**< File type we are going to save as */ - unsigned int *cmap; /**< Color map data. */ - unsigned int *rect; /**< pixel values stored here */ - unsigned int *crect; /**< color corrected pixel values stored here */ - unsigned int **planes; /**< bitplanes */ - int flags; /**< Controls which components should exist. */ - int mall; /**< what is malloced internal, and can be freed */ - short xorig, yorig; /**< Cordinates of first pixel of an image used in some formats (example: targa) */ - char name[1023]; /**< The file name assocated with this image */ - char namenull; /**< Unused don't want to remove it thought messes things up */ - int userflags; /**< Used to set imbuf to Dirty and other stuff */ - int *zbuf; /**< z buffer data, original zbuffer */ - float *zbuf_float; /**< z buffer data, camera coordinates */ - void *userdata; /**< temporary storage, only used by baking at the moment */ - unsigned char *encodedbuffer; /**< Compressed image only used with png currently */ - unsigned int encodedsize; /**< Size of data written to encodedbuffer */ - unsigned int encodedbuffersize; /**< Size of encodedbuffer */ - - float *rect_float; /**< floating point Rect equivalent - Linear RGB color space - may need gamma correction to - sRGB when generating 8bit representations */ - int channels; /**< amount of channels in rect_float (0 = 4 channel default) */ - float dither; /**< random dither value, for conversion from float -> byte rect */ - short profile; /** color space/profile preset that the byte rect buffer represents */ - char profile_filename[256]; /** to be implemented properly, specific filename for custom profiles */ - - struct MEM_CacheLimiterHandle_s * c_handle; /**< handle for cache limiter */ - struct ImgInfo * img_info; - int refcounter; /**< Refcounter for multiple users */ - int index; /**< reference index for ImBuf lists */ + + /* dimensions */ + short x, y; /* width and Height of our image buffer */ + unsigned char depth; /* Active amount of bits/bitplanes */ + int channels; /* amount of channels in rect_float (0 = 4 channel default) */ + + /* flags */ + int flags; /* Controls which components should exist. */ + int mall; /* what is malloced internal, and can be freed */ + + /* pixels */ + unsigned int *rect; /* pixel values stored here */ + unsigned int *crect; /* color corrected pixel values stored here */ + float *rect_float; /* floating point Rect equivalent + Linear RGB color space - may need gamma correction to + sRGB when generating 8bit representations */ - struct ImBuf *mipmap[IB_MIPMAP_LEVELS]; /**< MipMap levels, a series of halved images */ + /* tiled pixel storage */ + int tilex, tiley; + int xtiles, ytiles; + unsigned int **tiles; + + /* zbuffer */ + int *zbuf; /* z buffer data, original zbuffer */ + float *zbuf_float; /* z buffer data, camera coordinates */ + + /* parameters used by conversion between byte and float */ + float dither; /* random dither value, for conversion from float -> byte rect */ + short profile; /* color space/profile preset that the byte rect buffer represents */ + char profile_filename[256]; /* to be implemented properly, specific filename for custom profiles */ + + /* mipmapping */ + struct ImBuf *mipmap[IB_MIPMAP_LEVELS]; /* MipMap levels, a series of halved images */ + int miptot, miplevel; + + /* externally used data */ + int index; /* reference index for ImBuf lists */ + int userflags; /* used to set imbuf to dirty and other stuff */ + struct ImMetaData *metadata; /* image metadata */ + void *userdata; /* temporary storage, only used by baking at the moment */ + + /* file information */ + int ftype; /* file type we are going to save as */ + char name[IB_FILENAME_SIZE]; /* filename associated with this image */ + char cachename[IB_FILENAME_SIZE]; /* full filename used for reading from cache */ + + /* memory cache limiter */ + struct MEM_CacheLimiterHandle_s *c_handle; /* handle for cache limiter */ + int refcounter; /* reference counter for multiple users */ + + /* some parameters to pass along for packing images */ + unsigned char *encodedbuffer; /* Compressed image only used with png currently */ + unsigned int encodedsize; /* Size of data written to encodedbuffer */ + unsigned int encodedbuffersize; /* Size of encodedbuffer */ } ImBuf; /* Moved from BKE_bmfont_types.h because it is a userflag bit mask. */ /** * \brief Flags used internally by blender for imagebuffers */ -typedef enum { - IB_BITMAPFONT = 1 << 0, /* This image is a font */ - IB_BITMAPDIRTY = 1 << 1 /* Image needs to be saved is not the same as filename */ -} ImBuf_userflagsMask; +#define IB_BITMAPFONT (1 << 0) /* this image is a font */ +#define IB_BITMAPDIRTY (1 << 1) /* image needs to be saved is not the same as filename */ /* From iff.h. This was once moved away by Frank, now Nzc moves it * back. Such is the way it is... It is a long list of defines, and @@ -136,33 +145,26 @@ typedef enum { */ /**@{*/ /** \brief Flag defining the components of the ImBuf struct. */ -#define IB_rect (1 << 0) -#define IB_planes (1 << 1) -#define IB_cmap (1 << 2) - -#define IB_vert (1 << 4) -#define IB_freem (1 << 6) -#define IB_test (1 << 7) - -#define IB_ttob (1 << 8) -#define IB_subdlta (1 << 9) -#define IB_fields (1 << 11) -#define IB_zbuf (1 << 13) - -#define IB_mem (1 << 14) -#define IB_rectfloat (1 << 15) -#define IB_zbuffloat (1 << 16) -#define IB_multilayer (1 << 17) -#define IB_imginfo (1 << 18) -#define IB_animdeinterlace (1 << 19) + +#define IB_rect (1 << 0) +#define IB_test (1 << 1) +#define IB_fields (1 << 2) +#define IB_zbuf (1 << 3) +#define IB_mem (1 << 4) +#define IB_rectfloat (1 << 5) +#define IB_zbuffloat (1 << 6) +#define IB_multilayer (1 << 7) +#define IB_metadata (1 << 8) +#define IB_animdeinterlace (1 << 9) +#define IB_tiles (1 << 10) +#define IB_tilecache (1 << 11) +#define IB_premul (1 << 12) /* * The bit flag is stored in the ImBuf.ftype variable. * Note that the lower 10 bits is used for storing custom flags */ -#define AMI (1 << 31) #define PNG (1 << 30) -#define Anim (1 << 29) #define TGA (1 << 28) #define JPG (1 << 27) #define BMP (1 << 26) @@ -188,11 +190,11 @@ typedef enum { #ifdef WITH_OPENJPEG #define JP2 (1 << 18) -#define JP2_12BIT (1 << 17) -#define JP2_16BIT (1 << 16) +#define JP2_12BIT (1 << 17) +#define JP2_16BIT (1 << 16) #define JP2_YCC (1 << 15) -#define JP2_CINE (1 << 14) -#define JP2_CINE_48FPS (1 << 13) +#define JP2_CINE (1 << 14) +#define JP2_CINE_48FPS (1 << 13) #endif #define RAWTGA (TGA | 1) @@ -203,66 +205,16 @@ typedef enum { #define JPG_MAX (JPG | (3 << 8)) #define JPG_MSK (0xffffff00) -#define AM_ham (0x0800 | AMI) -#define AM_hbrite (0x0080 | AMI) - -#define C233 1 -#define YUVX 2 -#define HAMX 3 -#define TANX 4 - -#define AN_c233 (Anim | C233) -#define AN_yuvx (Anim | YUVX) -#define AN_hamx (Anim | HAMX) -#define AN_tanx (Anim | TANX) -/**@}*/ +#define IMAGIC 0732 /** * \name Imbuf preset profile tags * \brief Some predefined color space profiles that 8 bit imbufs can represent */ -/**@{*/ #define IB_PROFILE_NONE 0 #define IB_PROFILE_LINEAR_RGB 1 #define IB_PROFILE_SRGB 2 #define IB_PROFILE_CUSTOM 3 -/**@}*/ - - -/** \name Imbuf File Type Tests - * \brief These macros test if an ImBuf struct is the corresponding file type. - */ -/**@{*/ -/** \brief Tests the ImBuf.ftype variable for the file format. */ -#define IS_amiga(x) (x->ftype & AMI) -#define IS_ham(x) ((x->ftype & AM_ham) == AM_ham) -#define IS_hbrite(x) ((x->ftype & AM_hbrite) == AM_hbrite) - -#define IS_anim(x) (x->ftype & Anim) -#define IS_hamx(x) (x->ftype == AN_hamx) -#define IS_tga(x) (x->ftype & TGA) -#define IS_png(x) (x->ftype & PNG) -#define IS_openexr(x) (x->ftype & OPENEXR) -#define IS_jp2(x) (x->ftype & JP2) -#define IS_cineon(x) (x->ftype & CINEON) -#define IS_dpx(x) (x->ftype & DPX) -#define IS_bmp(x) (x->ftype & BMP) -#define IS_tiff(x) (x->ftype & TIF) -#define IS_radhdr(x) (x->ftype & RADHDR) - -#ifdef WITH_DDS -#define IS_dds(x) (x->ftype & DDS) -#endif - -#define IMAGIC 0732 -#define IS_iris(x) (x->ftype == IMAGIC) - -#define IS_jpg(x) (x->ftype & JPG) -#define IS_stdjpg(x) ((x->ftype & JPG_MSK) == JPG_STD) -#define IS_vidjpg(x) ((x->ftype & JPG_MSK) == JPG_VID) -#define IS_jstjpg(x) ((x->ftype & JPG_MSK) == JPG_JST) -#define IS_maxjpg(x) ((x->ftype & JPG_MSK) == JPG_MAX) -/**@}*/ #endif diff --git a/source/blender/imbuf/IMB_thumbs.h b/source/blender/imbuf/IMB_thumbs.h index 165accc9e17..c7e39b9e0d7 100644 --- a/source/blender/imbuf/IMB_thumbs.h +++ b/source/blender/imbuf/IMB_thumbs.h @@ -53,7 +53,7 @@ typedef enum ThumbSource { THB_SOURCE_MOVIE } ThumbSource; -// IB_imginfo +// IB_metadata /* create thumbnail for file and returns new imbuf for thumbnail */ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source); diff --git a/source/blender/imbuf/SConscript b/source/blender/imbuf/SConscript index a8d91b2d31e..b4f56df9ec0 100644 --- a/source/blender/imbuf/SConscript +++ b/source/blender/imbuf/SConscript @@ -14,6 +14,9 @@ incs += ' ' + env['BF_ZLIB_INC'] defs = [] +if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'): + incs += ' ' + env['BF_PTHREADS_INC'] + if env['WITH_BF_OPENEXR']: defs.append('WITH_OPENEXR') diff --git a/source/blender/imbuf/intern/IMB_amiga.h b/source/blender/imbuf/intern/IMB_amiga.h deleted file mode 100644 index e8d908df4c3..00000000000 --- a/source/blender/imbuf/intern/IMB_amiga.h +++ /dev/null @@ -1,47 +0,0 @@ -/** - * IMB_amiga.h - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -/** - * \file IMB_amiga.h - * \ingroup imbuf - * \brief Function declarations for amiga.c - */ - -#ifndef IMB_AMIGA_H -#define IMB_AMIGA_H - -struct ImBuf; - -struct ImBuf *imb_loadamiga(int *iffmem,int flags); -short imb_encodebodyh(struct ImBuf *ibuf, int file); -short imb_encodebodyv(struct ImBuf *ibuf, int file); - -#endif - diff --git a/source/blender/imbuf/intern/IMB_anim.h b/source/blender/imbuf/intern/IMB_anim.h index 39b8e48fb7f..c9eac2c1399 100644 --- a/source/blender/imbuf/intern/IMB_anim.h +++ b/source/blender/imbuf/intern/IMB_anim.h @@ -65,7 +65,6 @@ BLI_countlist BLI_stringdec */ #include "imbuf.h" -#include "imbuf_patch.h" #include "AVI_avi.h" @@ -93,7 +92,6 @@ #include "IMB_imbuf.h" #include "IMB_allocimbuf.h" -#include "IMB_bitplanes.h" @@ -117,7 +115,7 @@ #define ANIM_NONE (0) #define ANIM_SEQUENCE (1 << 0) #define ANIM_DIR (1 << 1) -#define ANIM_ANIM5 (1 << 2) +#define ANIM_DEPRECATED (1 << 2) #define ANIM_TGA (1 << 3) #define ANIM_MOVIE (1 << 4) #define ANIM_MDEC (1 << 5) @@ -126,13 +124,10 @@ #define ANIM_FFMPEG (1 << 8) #define ANIM_REDCODE (1 << 9) -#define ANIM5_MMAP 0 -#define ANIM5_MALLOC 1 -#define ANIM5_SNGBUF 2 -#define ANIM5_XOR 4 - #define MAXNUMSTREAMS 50 +struct _AviMovie; + struct anim { int ib_flags; int curtype; @@ -145,14 +140,6 @@ struct anim { /* voor sequence */ char first[256]; - /* anim5 */ - struct ListBase anim5base; - void * anim5mmap; - int anim5len; - struct Anim5Delta *anim5curdlta; - void (*anim5decode)(struct ImBuf *, unsigned char *); - int anim5flags; - /* movie */ void *movie; void *track; diff --git a/source/blender/imbuf/intern/IMB_anim5.h b/source/blender/imbuf/intern/IMB_anim5.h deleted file mode 100644 index 245b3b9a9be..00000000000 --- a/source/blender/imbuf/intern/IMB_anim5.h +++ /dev/null @@ -1,20 +0,0 @@ -/* IMB_anim.h */ -#ifndef IMB_ANIM5_H -#define IMB_ANIM5_H - -struct anim; - -/** - * - * @attention Defined in anim5.c - */ -int nextanim5(struct anim * anim); -int rewindanim5(struct anim * anim); -int startanim5(struct anim * anim); -void free_anim_anim5(struct anim * anim); -struct ImBuf * anim5_fetchibuf(struct anim * anim); - - -#endif - - diff --git a/source/blender/imbuf/intern/IMB_bitplanes.h b/source/blender/imbuf/intern/IMB_bitplanes.h deleted file mode 100644 index c8deb6f9a02..00000000000 --- a/source/blender/imbuf/intern/IMB_bitplanes.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * IMB_bitplanes.h - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -/** - * \file IMB_bitplanes.h - * \ingroup imbuf - * \brief Function declarations for bitplanes.c - */ - -#ifndef IMB_BITPLANES_H -#define IMB_BITPLANES_H - -struct ImBuf; - -void imb_bptolong(struct ImBuf *ibuf); -void imb_longtobp(struct ImBuf *ibuf); -unsigned int **imb_copyplanelist(struct ImBuf *ibuf); - -#endif - diff --git a/source/blender/imbuf/intern/IMB_bmp.h b/source/blender/imbuf/intern/IMB_bmp.h deleted file mode 100644 index 99561eeead2..00000000000 --- a/source/blender/imbuf/intern/IMB_bmp.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * IMB_bmp.h - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -/** - * \file IMB_bmp.h - * \ingroup imbuf - * \brief Function declarations for bmp.c - */ - -#ifndef IMB_BMP_H -#define IMB_BMP_H - -struct ImBuf; - -int imb_is_a_bmp(void *buf); -struct ImBuf *imb_bmp_decode(unsigned char *mem, int size, int flags); -short imb_savebmp(struct ImBuf *ibuf, char *name, int flags); - -#endif - diff --git a/source/blender/imbuf/intern/IMB_cmap.h b/source/blender/imbuf/intern/IMB_cmap.h deleted file mode 100644 index 5e30e66f58e..00000000000 --- a/source/blender/imbuf/intern/IMB_cmap.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * IMB_cmap.h - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -/** - * \file IMB_cmap.h - * \ingroup imbuf - * \brief Function declarations for cmap.c - */ -#ifndef IMB_CMAP_H -#define IMB_CMAP_H - -struct ImBuf; - -void imb_makecolarray(struct ImBuf *ibuf, unsigned char *mem, short nocols); -void imb_losecmapbits(struct ImBuf *ibuf, unsigned int *coltab); -short *imb_coldeltatab(unsigned char *coltab, short mincol, short maxcol, short cbits); - -#endif - diff --git a/source/blender/imbuf/intern/IMB_cocoa.h b/source/blender/imbuf/intern/IMB_cocoa.h deleted file mode 100644 index a62e7028143..00000000000 --- a/source/blender/imbuf/intern/IMB_cocoa.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * IMB_cocoa.h - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributor(s): Damien Plisson 10/2009 - * - * ***** END GPL LICENSE BLOCK ***** - */ -/** - * \file IMB_cocoa.h - * \ingroup imbuf - * \brief Function declarations for imbuf_cocoa.m - */ - -#ifndef IMB_COCOA_H -#define IMB_COCOA_H - -/* Foward declaration of ImBuf structure. */ -struct ImBuf; - -/* Declarations for imbuf_cocoa.m */ -struct ImBuf *imb_cocoaLoadImage(unsigned char *mem, int size, int flags); -short imb_cocoaSaveImage(struct ImBuf *ibuf, char *name, int flags); - -#endif /* IMB_COCOA_H */ - diff --git a/source/blender/imbuf/intern/IMB_divers.h b/source/blender/imbuf/intern/IMB_divers.h deleted file mode 100644 index 5ab0ce25484..00000000000 --- a/source/blender/imbuf/intern/IMB_divers.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * divers.h - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -/** - * \file IMB_divers.h - * \ingroup imbuf - * \brief Function declarations for divers.c - */ - -#ifndef IMB_DIVERS_H -#define IMB_DIVERS_H - -struct ImBuf; - -void imb_checkncols(struct ImBuf *ibuf); - -#endif - diff --git a/source/blender/imbuf/intern/IMB_dpxcineon.h b/source/blender/imbuf/intern/IMB_dpxcineon.h deleted file mode 100644 index 4719ecd49f3..00000000000 --- a/source/blender/imbuf/intern/IMB_dpxcineon.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * IMB_dpxcineon.h - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -/** - * \file IMB_dpxcineon.h - * \ingroup imbuf - */ -#ifndef _IMB_DPX_CINEON_H -#define _IMB_DPX_CINEON_H - -struct ImBuf; - -short imb_savecineon(struct ImBuf *buf, char *myfil, int flags); -struct ImBuf *imb_loadcineon(unsigned char *mem, int size, int flags); -int imb_is_cineon(void *buf); -short imb_save_dpx(struct ImBuf *buf, char *myfile, int flags); -struct ImBuf *imb_loaddpx(unsigned char *mem, int size, int flags); -int imb_is_dpx(void *buf); - -#endif /*_IMB_DPX_CINEON_H*/ diff --git a/source/blender/imbuf/intern/IMB_filetype.h b/source/blender/imbuf/intern/IMB_filetype.h new file mode 100644 index 00000000000..f6afe20cb5c --- /dev/null +++ b/source/blender/imbuf/intern/IMB_filetype.h @@ -0,0 +1,120 @@ +/** + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Blender Foundation 2010. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef IMB_FILETYPE_H +#define IMB_FILETYPE_H + +/* Generic File Type */ + +struct ImBuf; + +#define IM_FTYPE_FLOAT 1 + +typedef struct ImFileType { + void (*init)(void); + void (*exit)(void); + + int (*is_a)(unsigned char *buf); + int (*ftype)(struct ImFileType *type, struct ImBuf *ibuf); + struct ImBuf *(*load)(unsigned char *mem, int size, int flags); + int (*save)(struct ImBuf *ibuf, char *name, int flags); + void (*load_tile)(struct ImBuf *ibuf, unsigned char *mem, int size, int tx, int ty, unsigned int *rect); + + int flag; + int filetype; +} ImFileType; + +extern ImFileType IMB_FILE_TYPES[]; + +void imb_filetypes_init(void); +void imb_filetypes_exit(void); + +void imb_tile_cache_init(void); +void imb_tile_cache_exit(void); + +void imb_loadtile(struct ImBuf *ibuf, int tx, int ty, unsigned int *rect); +void imb_tile_cache_tile_free(struct ImBuf *ibuf, int tx, int ty); + +/* Type Specific Functions */ + +/* png */ +int imb_is_a_png(unsigned char *buf); +struct ImBuf *imb_loadpng(unsigned char *mem, int size, int flags); +int imb_savepng(struct ImBuf *ibuf, char *name, int flags); + +/* targa */ +int imb_is_a_targa(unsigned char *buf); +struct ImBuf *imb_loadtarga(unsigned char *mem, int size, int flags); +int imb_savetarga(struct ImBuf * ibuf, char *name, int flags); + +/* iris */ +int imb_is_a_iris(unsigned char *mem); +struct ImBuf *imb_loadiris(unsigned char *mem, int size, int flags); +int imb_saveiris(struct ImBuf * ibuf, char *name, int flags); + +/* jp2 */ +int imb_is_a_jp2(unsigned char *buf); +struct ImBuf *imb_jp2_decode(unsigned char *mem, int size, int flags); +int imb_savejp2(struct ImBuf *ibuf, char *name, int flags); + +/* jpeg */ +int imb_is_a_jpeg(unsigned char *mem); +int imb_savejpeg(struct ImBuf * ibuf, char * name, int flags); +struct ImBuf * imb_ibJpegImageFromFilename (const char * filename, int flags); +struct ImBuf * imb_load_jpeg (unsigned char * buffer, int size, int flags); + +/* bmp */ +int imb_is_a_bmp(unsigned char *buf); +struct ImBuf *imb_bmp_decode(unsigned char *mem, int size, int flags); +int imb_savebmp(struct ImBuf *ibuf, char *name, int flags); + +/* cocoa */ +struct ImBuf *imb_cocoaLoadImage(unsigned char *mem, int size, int flags); +short imb_cocoaSaveImage(struct ImBuf *ibuf, char *name, int flags); + +/* cineon */ +int imb_savecineon(struct ImBuf *buf, char *myfil, int flags); +struct ImBuf *imb_loadcineon(unsigned char *mem, int size, int flags); +int imb_is_cineon(unsigned char *buf); + +/* dpx */ +int imb_save_dpx(struct ImBuf *buf, char *myfile, int flags); +struct ImBuf *imb_loaddpx(unsigned char *mem, int size, int flags); +int imb_is_dpx(unsigned char *buf); + +/* hdr */ +int imb_is_a_hdr(unsigned char *buf); +struct ImBuf *imb_loadhdr(unsigned char *mem, int size, int flags); +int imb_savehdr(struct ImBuf * ibuf, char *name, int flags); + +/* tiff */ +int imb_is_a_tiff(unsigned char *buf); +struct ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags); +void imb_loadtiletiff(struct ImBuf *ibuf, unsigned char *mem, int size, + int tx, int ty, unsigned int *rect); +int imb_savetiff(struct ImBuf *ibuf, char *name, int flags); +void *libtiff_findsymbol(char *name); + +#endif /* IMB_FILETYPE_H */ + diff --git a/source/blender/imbuf/intern/IMB_filter.h b/source/blender/imbuf/intern/IMB_filter.h index 4f54ea91a1f..84ad72c520a 100644 --- a/source/blender/imbuf/intern/IMB_filter.h +++ b/source/blender/imbuf/intern/IMB_filter.h @@ -41,5 +41,8 @@ struct ImBuf; void imb_filterx(struct ImBuf *ibuf); +void IMB_premultiply_rect(unsigned int *rect, int depth, int w, int h); +void IMB_premultiply_rect_float(float *rect_float, int depth, int w, int h); + #endif diff --git a/source/blender/imbuf/intern/IMB_ham.h b/source/blender/imbuf/intern/IMB_ham.h deleted file mode 100644 index d455f9b519a..00000000000 --- a/source/blender/imbuf/intern/IMB_ham.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * IMB_ham.h - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -/** - * \file IMB_ham.h - * \ingroup imbuf - * \brief Function declarations for ham.c - */ - -#ifndef IMB_HAM_H -#define IMB_HAM_H - -struct ImBuf; - -short imb_converttoham(struct ImBuf *ibuf); - -#endif - diff --git a/source/blender/imbuf/intern/IMB_hamx.h b/source/blender/imbuf/intern/IMB_hamx.h deleted file mode 100644 index e39aef8355d..00000000000 --- a/source/blender/imbuf/intern/IMB_hamx.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * IMB_hamx.h - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -/** - * \file IMB_hamx.h - * \ingroup imbuf - * \brief Function declarations for hamx.c - */ - -#ifndef IMB_HAMX_H -#define IMB_HAMX_H - -struct ImBuf; - -struct ImBuf *imb_loadanim(int *iffmem, int flags); -short imb_enc_anim(struct ImBuf *ibuf, int file); -void imb_convhamx(struct ImBuf *ibuf, unsigned char *coltab, short *deltab); - -#endif - diff --git a/source/blender/imbuf/intern/IMB_iff.h b/source/blender/imbuf/intern/IMB_iff.h deleted file mode 100644 index 7d0a74dc00b..00000000000 --- a/source/blender/imbuf/intern/IMB_iff.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * IMB_iff.h - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -/** - * \file IMB_iff.h - * \ingroup imbuf - * \brief Function declarations for iff.c - */ - -#ifndef IMB_IFF_H -#define IMB_IFF_H - -struct ImBuf; - -unsigned short imb_start_iff(struct ImBuf *ibuf, int file); -unsigned short imb_update_iff(int file, int code); - -#endif - diff --git a/source/blender/imbuf/intern/IMB_imginfo.h b/source/blender/imbuf/intern/IMB_imginfo.h deleted file mode 100644 index 2884abcaf6e..00000000000 --- a/source/blender/imbuf/intern/IMB_imginfo.h +++ /dev/null @@ -1,85 +0,0 @@ -/** - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Austin Benesh. Ton Roosendaal. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef _IMB_IMGINFO_H -#define _IMB_IMGINFO_H - -#ifdef __cplusplus -extern "C" { -#endif - -struct ImBuf; - -typedef struct ImgInfo { - struct ImgInfo *next, *prev; - char* key; - char* value; - int len; -} ImgInfo; - -/** The imginfo is a list of key/value pairs (both char*) that can me - saved in the header of several image formats. - Apart from some common keys like - 'Software' and 'Description' (png standard) we'll use keys within the - Blender namespace, so should be called 'Blender::StampInfo' or 'Blender::FrameNum' - etc... -*/ - - -/* free blender ImgInfo struct */ -void IMB_imginfo_free(struct ImBuf* img); - -/** read the field from the image info into the field - * @param img - the ImBuf that contains the image data - * @param key - the key of the field - * @param value - the data in the field, first one found with key is returned, - memory has to be allocated by user. - * @param len - length of value buffer allocated by user. - * @return - 1 (true) if ImageInfo present and value for the key found, 0 (false) otherwise - */ -int IMB_imginfo_get_field(struct ImBuf* img, const char* key, char* value, int len); - -/** set user data in the ImgInfo struct, which has to be allocated with IMB_imginfo_create - * before calling this function. - * @param img - the ImBuf that contains the image data - * @param key - the key of the field - * @param value - the data to be written to the field. zero terminated string - * @return - 1 (true) if ImageInfo present, 0 (false) otherwise - */ -int IMB_imginfo_add_field(struct ImBuf* img, const char* key, const char* field); - -/** delete the key/field par in the ImgInfo struct. - * @param img - the ImBuf that contains the image data - * @param key - the key of the field - * @return - 1 (true) if delete the key/field, 0 (false) otherwise - */ -int IMB_imginfo_del_field(struct ImBuf *img, const char *key); - -#endif /* _IMB_IMGINFO_H */ - diff --git a/source/blender/imbuf/intern/IMB_iris.h b/source/blender/imbuf/intern/IMB_iris.h deleted file mode 100644 index 3aa157cb959..00000000000 --- a/source/blender/imbuf/intern/IMB_iris.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * IMB_iris.h - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -/** - * \file IMB_iris.h - * \ingroup imbuf - * \brief Function declarations for iris.c - */ - -#ifndef IMB_IRIS_H -#define IMB_IRIS_H - -struct ImBuf; - -struct ImBuf *imb_loadiris(unsigned char *mem, int flags); -short imb_saveiris(struct ImBuf * ibuf, char *name, int flags); - -#endif - diff --git a/source/blender/imbuf/intern/IMB_jp2.h b/source/blender/imbuf/intern/IMB_jp2.h deleted file mode 100644 index 66ff69314ae..00000000000 --- a/source/blender/imbuf/intern/IMB_jp2.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * IMB_jp2.h - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -/** - * \file IMB_jp2.h - * \ingroup imbuf - * \brief Function declarations for jp2.c - */ - -#ifndef IMB_JP2_H -#define IMB_JP2_H - -#ifdef WITH_OPENJPEG -struct ImBuf; - -int imb_is_a_jp2(void *buf); -struct ImBuf *imb_jp2_decode(unsigned char *mem, int size, int flags); -short imb_savejp2(struct ImBuf *ibuf, char *name, int flags); -#endif /* WITH_OPENJPEG */ - -#endif - diff --git a/source/blender/imbuf/intern/IMB_jpeg.h b/source/blender/imbuf/intern/IMB_jpeg.h deleted file mode 100644 index 8e0ba3451ae..00000000000 --- a/source/blender/imbuf/intern/IMB_jpeg.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * IMB_jpeg.h - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -/** - * \file IMB_jpeg.h - * \ingroup imbuf - * \brief Function declarations for jpeg.c - */ - -#ifndef IMB_JPEG_H -#define IMB_JPEG_H - -struct ImBuf; -struct jpeg_compress_struct; - -int imb_is_a_jpeg(unsigned char *mem); -int imb_savejpeg(struct ImBuf * ibuf, char * name, int flags); -struct ImBuf * imb_ibJpegImageFromFilename (const char * filename, int flags); -struct ImBuf * imb_ibJpegImageFromMemory (unsigned char * buffer, int size, int flags); - -#endif - diff --git a/source/blender/imbuf/intern/IMB_metadata.h b/source/blender/imbuf/intern/IMB_metadata.h new file mode 100644 index 00000000000..751978a88da --- /dev/null +++ b/source/blender/imbuf/intern/IMB_metadata.h @@ -0,0 +1,80 @@ +/** + * $Id: IMB_metadata.h 28607 2010-05-06 07:10:56Z campbellbarton $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2005 Blender Foundation + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Austin Benesh. Ton Roosendaal. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef _IMB_IMGINFO_H +#define _IMB_IMGINFO_H + +struct ImBuf; + +typedef struct ImMetaData { + struct ImMetaData *next, *prev; + char* key; + char* value; + int len; +} ImMetaData; + +/** The metadata is a list of key/value pairs (both char*) that can me + saved in the header of several image formats. + Apart from some common keys like + 'Software' and 'Description' (png standard) we'll use keys within the + Blender namespace, so should be called 'Blender::StampInfo' or 'Blender::FrameNum' + etc... +*/ + + +/* free blender ImMetaData struct */ +void IMB_metadata_free(struct ImBuf* img); + +/** read the field from the image info into the field + * @param img - the ImBuf that contains the image data + * @param key - the key of the field + * @param value - the data in the field, first one found with key is returned, + memory has to be allocated by user. + * @param len - length of value buffer allocated by user. + * @return - 1 (true) if ImageInfo present and value for the key found, 0 (false) otherwise + */ +int IMB_metadata_get_field(struct ImBuf* img, const char* key, char* value, int len); + +/** set user data in the ImMetaData struct, which has to be allocated with IMB_metadata_create + * before calling this function. + * @param img - the ImBuf that contains the image data + * @param key - the key of the field + * @param value - the data to be written to the field. zero terminated string + * @return - 1 (true) if ImageInfo present, 0 (false) otherwise + */ +int IMB_metadata_add_field(struct ImBuf* img, const char* key, const char* field); + +/** delete the key/field par in the ImMetaData struct. + * @param img - the ImBuf that contains the image data + * @param key - the key of the field + * @return - 1 (true) if delete the key/field, 0 (false) otherwise + */ +int IMB_metadata_del_field(struct ImBuf *img, const char *key); + +#endif /* _IMB_IMGINFO_H */ diff --git a/source/blender/imbuf/intern/IMB_png.h b/source/blender/imbuf/intern/IMB_png.h deleted file mode 100644 index 28e3adb2722..00000000000 --- a/source/blender/imbuf/intern/IMB_png.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * IMB_png.h - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -/** - * \file IMB_png.h - * \ingroup imbuf - * \brief Function declarations for png.c - */ - -#ifndef IMB_PNG_H -#define IMB_PNG_H - -struct ImBuf; - -int imb_is_a_png(void *buf); -struct ImBuf *imb_loadpng(unsigned char *mem, int size, int flags); - -short imb_savepng(struct ImBuf *ibuf, char *name, int flags); - -#endif - diff --git a/source/blender/imbuf/intern/IMB_radiance_hdr.h b/source/blender/imbuf/intern/IMB_radiance_hdr.h deleted file mode 100644 index 325715906a0..00000000000 --- a/source/blender/imbuf/intern/IMB_radiance_hdr.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * IMB_radiance_hdr.h - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef IMB_RADIANCE_HDR_H -#define IMB_RADIANCE_HDR_H - -struct ImBuf; - -int imb_is_a_hdr(void *buf); - -struct ImBuf *imb_loadhdr(unsigned char *mem, int size, int flags); -short imb_savehdr(struct ImBuf * ibuf, char *name, int flags); - -#endif diff --git a/source/blender/imbuf/intern/IMB_targa.h b/source/blender/imbuf/intern/IMB_targa.h deleted file mode 100644 index a81801eedac..00000000000 --- a/source/blender/imbuf/intern/IMB_targa.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * IMB_targa.h - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -/** - * \file IMB_targa.h - * \ingroup imbuf - * \brief Function declarations for targa.c - */ - -#ifndef IMB_TARGA_H -#define IMB_TARGA_H - -struct ImBuf; - -int imb_is_a_targa(void *buf); - -struct ImBuf *imb_loadtarga(unsigned char *mem, int size, int flags); -short imb_savetarga(struct ImBuf * ibuf, char *name, int flags); - -#endif - diff --git a/source/blender/imbuf/intern/IMB_tiff.h b/source/blender/imbuf/intern/IMB_tiff.h deleted file mode 100644 index ccd993fe477..00000000000 --- a/source/blender/imbuf/intern/IMB_tiff.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * IMB_tiff.h - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributor(s): Jonathan Merritt. - * - * ***** END GPL LICENSE BLOCK ***** - */ -/** - * \file IMB_tiff.h - * \ingroup imbuf - * \brief Function declarations for tiff.c - */ - -#ifndef IMB_TIFF_H -#define IMB_TIFF_H - -/* Foward declaration of ImBuf structure. */ -struct ImBuf; - -/* Declarations for tiff.c */ -int imb_is_a_tiff(void *buf); -struct ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags); -short imb_savetiff(struct ImBuf *ibuf, char *name, int flags); -void* libtiff_findsymbol(char *name); - -#endif /* IMB_TIFF_H */ - diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 056de9ab708..606913dd590 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -32,54 +32,38 @@ /* It's become a bit messy... Basically, only the IMB_ prefixed files * should remain. */ -#include "IMB_imbuf_types.h" - -#include "imbuf.h" -#include "imbuf_patch.h" #include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" -#include "IMB_divers.h" #include "IMB_allocimbuf.h" -#include "IMB_imginfo.h" -#include "MEM_CacheLimiterC-Api.h" +#include "IMB_filetype.h" +#include "IMB_metadata.h" -static unsigned int dfltcmap[16] = { - 0x00000000, 0xffffffff, 0x777777ff, 0xccccccff, - 0xcc3344ff, 0xdd8844ff, 0xccdd44ff, 0x888833ff, - 0x338844ff, 0x44dd44ff, 0x44ddccff, 0x3388ccff, - 0x8888ddff, 0x4433ccff, 0xcc33ccff, 0xcc88ddff -}; +#include "imbuf.h" -void imb_freeplanesImBuf(struct ImBuf * ibuf) -{ - if (ibuf==NULL) return; - if (ibuf->planes){ - if (ibuf->mall & IB_planes) MEM_freeN(ibuf->planes); - } - ibuf->planes = 0; - ibuf->mall &= ~IB_planes; -} +#include "MEM_CacheLimiterC-Api.h" -void imb_freemipmapImBuf(struct ImBuf * ibuf) +void imb_freemipmapImBuf(ImBuf *ibuf) { int a; - for(a=0; amipmap[a]) IMB_freeImBuf(ibuf->mipmap[a]); - ibuf->mipmap[a]= NULL; + for(a=1; amiptot; a++) { + if(ibuf->mipmap[a-1]) + IMB_freeImBuf(ibuf->mipmap[a-1]); + ibuf->mipmap[a-1]= NULL; } + + ibuf->miptot= 0; } /* any free rect frees mipmaps to be sure, creation is in render on first request */ -void imb_freerectfloatImBuf(struct ImBuf * ibuf) +void imb_freerectfloatImBuf(ImBuf *ibuf) { - if (ibuf==NULL) return; + if(ibuf==NULL) return; - if (ibuf->rect_float) { - if (ibuf->mall & IB_rectfloat) { - MEM_freeN(ibuf->rect_float); - ibuf->rect_float=NULL; - } + if(ibuf->rect_float && (ibuf->mall & IB_rectfloat)) { + MEM_freeN(ibuf->rect_float); + ibuf->rect_float=NULL; } imb_freemipmapImBuf(ibuf); @@ -89,19 +73,15 @@ void imb_freerectfloatImBuf(struct ImBuf * ibuf) } /* any free rect frees mipmaps to be sure, creation is in render on first request */ -void imb_freerectImBuf(struct ImBuf * ibuf) +void imb_freerectImBuf(ImBuf *ibuf) { - if (ibuf==NULL) return; + if(ibuf==NULL) return; - if (ibuf->crect && ibuf->crect != ibuf->rect) { + if(ibuf->crect && ibuf->crect != ibuf->rect) MEM_freeN(ibuf->crect); - } - if (ibuf->rect) { - if (ibuf->mall & IB_rect) { - MEM_freeN(ibuf->rect); - } - } + if(ibuf->rect && (ibuf->mall & IB_rect)) + MEM_freeN(ibuf->rect); imb_freemipmapImBuf(ibuf); @@ -110,150 +90,166 @@ void imb_freerectImBuf(struct ImBuf * ibuf) ibuf->mall &= ~IB_rect; } -static void freeencodedbufferImBuf(struct ImBuf * ibuf) +void imb_freetilesImBuf(ImBuf *ibuf) { - if (ibuf==NULL) return; - if (ibuf->encodedbuffer){ - if (ibuf->mall & IB_mem) MEM_freeN(ibuf->encodedbuffer); + int tx, ty; + + if(ibuf==NULL) return; + + if(ibuf->tiles && (ibuf->mall & IB_tiles)) { + for(ty=0; tyytiles; ty++) { + for(tx=0; txxtiles; tx++) { + if(ibuf->tiles[ibuf->xtiles*ty + tx]) { + imb_tile_cache_tile_free(ibuf, tx, ty); + MEM_freeN(ibuf->tiles[ibuf->xtiles*ty + tx]); + } + } + } + + MEM_freeN(ibuf->tiles); } + + ibuf->tiles= NULL; + ibuf->mall &= ~IB_tiles; +} + +static void freeencodedbufferImBuf(ImBuf *ibuf) +{ + if(ibuf==NULL) return; + + if(ibuf->encodedbuffer && (ibuf->mall & IB_mem)) + MEM_freeN(ibuf->encodedbuffer); + ibuf->encodedbuffer = 0; ibuf->encodedbuffersize = 0; ibuf->encodedsize = 0; ibuf->mall &= ~IB_mem; } -void IMB_freezbufImBuf(struct ImBuf * ibuf) +void IMB_freezbufImBuf(ImBuf *ibuf) { - if (ibuf==NULL) return; - if (ibuf->zbuf){ - if (ibuf->mall & IB_zbuf) MEM_freeN(ibuf->zbuf); - } + if(ibuf==NULL) return; + + if(ibuf->zbuf && (ibuf->mall & IB_zbuf)) + MEM_freeN(ibuf->zbuf); + ibuf->zbuf= NULL; ibuf->mall &= ~IB_zbuf; } -void IMB_freezbuffloatImBuf(struct ImBuf * ibuf) +void IMB_freezbuffloatImBuf(ImBuf *ibuf) { - if (ibuf==NULL) return; - if (ibuf->zbuf_float){ - if (ibuf->mall & IB_zbuffloat) MEM_freeN(ibuf->zbuf_float); - } + if(ibuf==NULL) return; + + if(ibuf->zbuf_float && (ibuf->mall & IB_zbuffloat)) + MEM_freeN(ibuf->zbuf_float); + ibuf->zbuf_float= NULL; ibuf->mall &= ~IB_zbuffloat; } -void IMB_freecmapImBuf(struct ImBuf * ibuf) -{ - if (ibuf==NULL) return; - if (ibuf->cmap){ - if (ibuf->mall & IB_cmap) MEM_freeN(ibuf->cmap); - } - ibuf->cmap = 0; - ibuf->mall &= ~IB_cmap; -} - -void IMB_freeImBuf(struct ImBuf * ibuf) +void IMB_freeImBuf(ImBuf *ibuf) { - if (ibuf){ - if (ibuf->refcounter > 0) { + if(ibuf) { + if(ibuf->refcounter > 0) { ibuf->refcounter--; - } else { - imb_freeplanesImBuf(ibuf); + } + else { imb_freerectImBuf(ibuf); imb_freerectfloatImBuf(ibuf); + imb_freetilesImBuf(ibuf); IMB_freezbufImBuf(ibuf); IMB_freezbuffloatImBuf(ibuf); - IMB_freecmapImBuf(ibuf); freeencodedbufferImBuf(ibuf); IMB_cache_limiter_unmanage(ibuf); - IMB_imginfo_free(ibuf); + IMB_metadata_free(ibuf); MEM_freeN(ibuf); } } } -void IMB_refImBuf(struct ImBuf * ibuf) +void IMB_refImBuf(ImBuf *ibuf) { ibuf->refcounter++; } -short addzbufImBuf(struct ImBuf * ibuf) +short addzbufImBuf(ImBuf *ibuf) { int size; - if (ibuf==NULL) return(FALSE); + if(ibuf==NULL) return FALSE; IMB_freezbufImBuf(ibuf); - size = ibuf->x * ibuf->y * sizeof(unsigned int); - if ( (ibuf->zbuf = MEM_mapallocN(size, "addzbufImBuf")) ){ + size = ibuf->x *ibuf->y *sizeof(unsigned int); + if((ibuf->zbuf = MEM_mapallocN(size, "addzbufImBuf"))) { ibuf->mall |= IB_zbuf; ibuf->flags |= IB_zbuf; - return (TRUE); + return TRUE; } - return (FALSE); + return FALSE; } -short addzbuffloatImBuf(struct ImBuf * ibuf) +short addzbuffloatImBuf(ImBuf *ibuf) { int size; - if (ibuf==NULL) return(FALSE); + if(ibuf==NULL) return FALSE; IMB_freezbuffloatImBuf(ibuf); - size = ibuf->x * ibuf->y * sizeof(float); - if ( (ibuf->zbuf_float = MEM_mapallocN(size, "addzbuffloatImBuf")) ){ + size = ibuf->x *ibuf->y *sizeof(float); + if((ibuf->zbuf_float = MEM_mapallocN(size, "addzbuffloatImBuf"))) { ibuf->mall |= IB_zbuffloat; ibuf->flags |= IB_zbuffloat; - return (TRUE); + return TRUE; } - return (FALSE); + return FALSE; } -short imb_addencodedbufferImBuf(struct ImBuf * ibuf) +short imb_addencodedbufferImBuf(ImBuf *ibuf) { - if (ibuf==NULL) return(FALSE); + if(ibuf==NULL) return FALSE; freeencodedbufferImBuf(ibuf); - if (ibuf->encodedbuffersize == 0) + if(ibuf->encodedbuffersize == 0) ibuf->encodedbuffersize = 10000; ibuf->encodedsize = 0; - if ( (ibuf->encodedbuffer = MEM_mallocN(ibuf->encodedbuffersize, "addencodedbufferImBuf") )){ + if((ibuf->encodedbuffer = MEM_mallocN(ibuf->encodedbuffersize, "addencodedbufferImBuf"))) { ibuf->mall |= IB_mem; ibuf->flags |= IB_mem; - return (TRUE); + return TRUE; } - return (FALSE); + return FALSE; } -short imb_enlargeencodedbufferImBuf(struct ImBuf * ibuf) +short imb_enlargeencodedbufferImBuf(ImBuf *ibuf) { unsigned int newsize, encodedsize; void *newbuffer; - if (ibuf==NULL) return(FALSE); + if(ibuf==NULL) return FALSE; - if (ibuf->encodedbuffersize < ibuf->encodedsize) { + if(ibuf->encodedbuffersize < ibuf->encodedsize) { printf("imb_enlargeencodedbufferImBuf: error in parameters\n"); - return(FALSE); + return FALSE; } - newsize = 2 * ibuf->encodedbuffersize; - if (newsize < 10000) newsize = 10000; + newsize = 2 *ibuf->encodedbuffersize; + if(newsize < 10000) newsize = 10000; newbuffer = MEM_mallocN(newsize, "enlargeencodedbufferImBuf"); - if (newbuffer == NULL) return(FALSE); + if(newbuffer == NULL) return FALSE; - if (ibuf->encodedbuffer) { + if(ibuf->encodedbuffer) { memcpy(newbuffer, ibuf->encodedbuffer, ibuf->encodedsize); } else { ibuf->encodedsize = 0; @@ -269,153 +265,98 @@ short imb_enlargeencodedbufferImBuf(struct ImBuf * ibuf) ibuf->mall |= IB_mem; ibuf->flags |= IB_mem; - return (TRUE); + return TRUE; } -short imb_addrectfloatImBuf(struct ImBuf * ibuf) +short imb_addrectfloatImBuf(ImBuf *ibuf) { int size; - if (ibuf==NULL) return(FALSE); + if(ibuf==NULL) return FALSE; imb_freerectfloatImBuf(ibuf); - size = ibuf->x * ibuf->y; - size = size * 4 * sizeof(float); + size = ibuf->x *ibuf->y; + size = size *4 *sizeof(float); ibuf->channels= 4; - if ( (ibuf->rect_float = MEM_mapallocN(size, "imb_addrectfloatImBuf")) ){ + if((ibuf->rect_float = MEM_mapallocN(size, "imb_addrectfloatImBuf"))) { ibuf->mall |= IB_rectfloat; ibuf->flags |= IB_rectfloat; - return (TRUE); + return TRUE; } - return (FALSE); + return FALSE; } /* question; why also add zbuf? */ -short imb_addrectImBuf(struct ImBuf * ibuf) +short imb_addrectImBuf(ImBuf *ibuf) { int size; - if (ibuf==NULL) return(FALSE); + if(ibuf==NULL) return FALSE; imb_freerectImBuf(ibuf); - size = ibuf->x * ibuf->y; - size = size * sizeof(unsigned int); + size = ibuf->x*ibuf->y; + size = size*sizeof(unsigned int); - if ( (ibuf->rect = MEM_mapallocN(size, "imb_addrectImBuf")) ){ + if((ibuf->rect = MEM_mapallocN(size, "imb_addrectImBuf"))) { ibuf->mall |= IB_rect; ibuf->flags |= IB_rect; - if (ibuf->depth > 32) return (addzbufImBuf(ibuf)); - else return (TRUE); - } - - return (FALSE); -} - - -short imb_addcmapImBuf(struct ImBuf *ibuf) -{ - int min; - - if (ibuf==NULL) return(FALSE); - IMB_freecmapImBuf(ibuf); - - imb_checkncols(ibuf); - if (ibuf->maxcol == 0) return (TRUE); - - if ( (ibuf->cmap = MEM_callocN(sizeof(unsigned int) * ibuf->maxcol, "imb_addcmapImBuf") ) ){ - min = ibuf->maxcol * sizeof(unsigned int); - if (min > sizeof(dfltcmap)) min = sizeof(dfltcmap); - memcpy(ibuf->cmap, dfltcmap, min); - ibuf->mall |= IB_cmap; - ibuf->flags |= IB_cmap; - return (TRUE); + if(ibuf->depth > 32) return (addzbufImBuf(ibuf)); + else return TRUE; } - return (FALSE); + return FALSE; } - -short imb_addplanesImBuf(struct ImBuf *ibuf) +short imb_addtilesImBuf(ImBuf *ibuf) { - int size; - short skipx,d,y; - unsigned int **planes; - unsigned int *point2; - - if (ibuf==NULL) return(FALSE); - imb_freeplanesImBuf(ibuf); + if(ibuf==NULL) return FALSE; - skipx = ((ibuf->x+31) >> 5); - ibuf->skipx=skipx; - y=ibuf->y; - d=ibuf->depth; - - planes = MEM_mallocN( (d*skipx*y)*sizeof(int) + d*sizeof(int *), "imb_addplanesImBuf"); - - ibuf->planes = planes; - if (planes==0) return (FALSE); + if(!ibuf->tiles) + if((ibuf->tiles = MEM_callocN(sizeof(unsigned int*)*ibuf->xtiles*ibuf->ytiles, "imb_tiles"))) + ibuf->mall |= IB_tiles; - point2 = (unsigned int *)(planes+d); - size = skipx*y; - - for (;d>0;d--){ - *(planes++) = point2; - point2 += size; - } - ibuf->mall |= IB_planes; - ibuf->flags |= IB_planes; - - return (TRUE); + return (ibuf->tiles != NULL); } - -struct ImBuf *IMB_allocImBuf(short x, short y, uchar d, unsigned int flags, uchar bitmap) +ImBuf *IMB_allocImBuf(short x, short y, uchar d, unsigned int flags, uchar bitmap) /* XXX bitmap argument is deprecated */ { - struct ImBuf *ibuf; + ImBuf *ibuf; - ibuf = MEM_callocN(sizeof(struct ImBuf), "ImBuf_struct"); - if (bitmap) flags |= IB_planes; + ibuf = MEM_callocN(sizeof(ImBuf), "ImBuf_struct"); - if (ibuf){ + if(ibuf) { ibuf->x= x; ibuf->y= y; ibuf->depth= d; ibuf->ftype= TGA; ibuf->channels= 4; /* float option, is set to other values when buffers get assigned */ - if (flags & IB_rect){ - if (imb_addrectImBuf(ibuf)==FALSE){ + if(flags & IB_rect) { + if(imb_addrectImBuf(ibuf)==FALSE) { IMB_freeImBuf(ibuf); return NULL; } } - if (flags & IB_rectfloat){ - if (imb_addrectfloatImBuf(ibuf)==FALSE){ + if(flags & IB_rectfloat) { + if(imb_addrectfloatImBuf(ibuf)==FALSE) { IMB_freeImBuf(ibuf); return NULL; } } - if (flags & IB_zbuf){ - if (addzbufImBuf(ibuf)==FALSE){ + if(flags & IB_zbuf) { + if(addzbufImBuf(ibuf)==FALSE) { IMB_freeImBuf(ibuf); return NULL; } } - if (flags & IB_zbuffloat){ - if (addzbuffloatImBuf(ibuf)==FALSE){ - IMB_freeImBuf(ibuf); - return NULL; - } - } - - if (flags & IB_planes){ - if (imb_addplanesImBuf(ibuf)==FALSE){ + if(flags & IB_zbuffloat) { + if(addzbuffloatImBuf(ibuf)==FALSE) { IMB_freeImBuf(ibuf); return NULL; } @@ -425,37 +366,33 @@ struct ImBuf *IMB_allocImBuf(short x, short y, uchar d, unsigned int flags, ucha } /* does no zbuffers? */ -struct ImBuf *IMB_dupImBuf(struct ImBuf *ibuf1) +ImBuf *IMB_dupImBuf(ImBuf *ibuf1) { - struct ImBuf *ibuf2, tbuf; + ImBuf *ibuf2, tbuf; int flags = 0; int a, x, y; - if (ibuf1 == NULL) return NULL; + if(ibuf1 == NULL) return NULL; - if (ibuf1->rect) flags |= IB_rect; - if (ibuf1->rect_float) flags |= IB_rectfloat; - if (ibuf1->planes) flags |= IB_planes; + if(ibuf1->rect) flags |= IB_rect; + if(ibuf1->rect_float) flags |= IB_rectfloat; x = ibuf1->x; y = ibuf1->y; - if (ibuf1->flags & IB_fields) y *= 2; + if(ibuf1->flags & IB_fields) y *= 2; ibuf2 = IMB_allocImBuf(x, y, ibuf1->depth, flags, 0); - if (ibuf2 == NULL) return NULL; + if(ibuf2 == NULL) return NULL; - if (flags & IB_rect) - memcpy(ibuf2->rect, ibuf1->rect, x * y * sizeof(int)); + if(flags & IB_rect) + memcpy(ibuf2->rect, ibuf1->rect, x *y *sizeof(int)); - if (flags & IB_rectfloat) - memcpy(ibuf2->rect_float, ibuf1->rect_float, ibuf1->channels * x * y * sizeof(float)); + if(flags & IB_rectfloat) + memcpy(ibuf2->rect_float, ibuf1->rect_float, ibuf1->channels *x *y *sizeof(float)); - if (flags & IB_planes) - memcpy(*(ibuf2->planes),*(ibuf1->planes),ibuf1->depth * ibuf1->skipx * y * sizeof(int)); - - if (ibuf1->encodedbuffer) { + if(ibuf1->encodedbuffer) { ibuf2->encodedbuffersize = ibuf1->encodedbuffersize; - if (imb_addencodedbufferImBuf(ibuf2) == FALSE) { + if(imb_addencodedbufferImBuf(ibuf2) == FALSE) { IMB_freeImBuf(ibuf2); return NULL; } @@ -469,8 +406,6 @@ struct ImBuf *IMB_dupImBuf(struct ImBuf *ibuf1) // fix pointers tbuf.rect = ibuf2->rect; tbuf.rect_float = ibuf2->rect_float; - tbuf.planes = ibuf2->planes; - tbuf.cmap = ibuf2->cmap; tbuf.encodedbuffer = ibuf2->encodedbuffer; tbuf.zbuf= NULL; tbuf.zbuf_float= NULL; @@ -482,42 +417,36 @@ struct ImBuf *IMB_dupImBuf(struct ImBuf *ibuf1) tbuf.c_handle = 0; tbuf.refcounter = 0; - // for now don't duplicate image info - tbuf.img_info = 0; + // for now don't duplicate metadata + tbuf.metadata = 0; *ibuf2 = tbuf; - if (ibuf1->cmap){ - imb_addcmapImBuf(ibuf2); - if (ibuf2->cmap) memcpy(ibuf2->cmap,ibuf1->cmap,ibuf2->maxcol * sizeof(int)); - } - return(ibuf2); } /* support for cache limiting */ -static void imbuf_cache_destructor(void * data) +static void imbuf_cache_destructor(void *data) { - struct ImBuf * ibuf = (struct ImBuf*) data; + ImBuf *ibuf = (ImBuf*) data; - imb_freeplanesImBuf(ibuf); imb_freerectImBuf(ibuf); imb_freerectfloatImBuf(ibuf); IMB_freezbufImBuf(ibuf); IMB_freezbuffloatImBuf(ibuf); - IMB_freecmapImBuf(ibuf); freeencodedbufferImBuf(ibuf); ibuf->c_handle = 0; } -static MEM_CacheLimiterC ** get_imbuf_cache_limiter() +static MEM_CacheLimiterC **get_imbuf_cache_limiter() { - static MEM_CacheLimiterC * c = 0; - if (!c) { + static MEM_CacheLimiterC *c = 0; + + if(!c) c = new_MEM_CacheLimiter(imbuf_cache_destructor); - } + return &c; } @@ -527,9 +456,9 @@ void IMB_free_cache_limiter() *get_imbuf_cache_limiter() = 0; } -void IMB_cache_limiter_insert(struct ImBuf * i) +void IMB_cache_limiter_insert(ImBuf *i) { - if (!i->c_handle) { + if(!i->c_handle) { i->c_handle = MEM_CacheLimiter_insert( *get_imbuf_cache_limiter(), i); MEM_CacheLimiter_ref(i->c_handle); @@ -539,39 +468,37 @@ void IMB_cache_limiter_insert(struct ImBuf * i) } } -void IMB_cache_limiter_unmanage(struct ImBuf * i) +void IMB_cache_limiter_unmanage(ImBuf *i) { - if (i->c_handle) { + if(i->c_handle) { MEM_CacheLimiter_unmanage(i->c_handle); i->c_handle = 0; } } -void IMB_cache_limiter_touch(struct ImBuf * i) +void IMB_cache_limiter_touch(ImBuf *i) { - if (i->c_handle) { + if(i->c_handle) MEM_CacheLimiter_touch(i->c_handle); - } } -void IMB_cache_limiter_ref(struct ImBuf * i) +void IMB_cache_limiter_ref(ImBuf *i) { - if (i->c_handle) { + if(i->c_handle) MEM_CacheLimiter_ref(i->c_handle); - } } -void IMB_cache_limiter_unref(struct ImBuf * i) +void IMB_cache_limiter_unref(ImBuf *i) { - if (i->c_handle) { + if(i->c_handle) MEM_CacheLimiter_unref(i->c_handle); - } } -int IMB_cache_limiter_get_refcount(struct ImBuf * i) +int IMB_cache_limiter_get_refcount(ImBuf *i) { - if (i->c_handle) { + if(i->c_handle) return MEM_CacheLimiter_get_refcount(i->c_handle); - } + return 0; } + diff --git a/source/blender/imbuf/intern/amiga.c b/source/blender/imbuf/intern/amiga.c deleted file mode 100644 index 4b9e1d85df3..00000000000 --- a/source/blender/imbuf/intern/amiga.c +++ /dev/null @@ -1,540 +0,0 @@ -/** - * amiga.c - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifdef _WIN32 -#include -#define open _open -#define read _read -#define close _close -#define write _write -#endif -#include "imbuf.h" -#include "imbuf_patch.h" - -#include "IMB_imbuf_types.h" -#include "IMB_imbuf.h" - -#include "BKE_global.h" - -#include "IMB_cmap.h" -#include "IMB_allocimbuf.h" -#include "IMB_bitplanes.h" -#include "IMB_amiga.h" - -/* actually hard coded endianness */ -#define GET_BIG_LONG(x) (((uchar *) (x))[0] << 24 | ((uchar *) (x))[1] << 16 | ((uchar *) (x))[2] << 8 | ((uchar *) (x))[3]) -#define GET_LITTLE_LONG(x) (((uchar *) (x))[3] << 24 | ((uchar *) (x))[2] << 16 | ((uchar *) (x))[1] << 8 | ((uchar *) (x))[0]) -#define SWAP_L(x) (((x << 24) & 0xff000000) | ((x << 8) & 0xff0000) | ((x >> 8) & 0xff00) | ((x >> 24) & 0xff)) -#define SWAP_S(x) (((x << 8) & 0xff00) | ((x >> 8) & 0xff)) - -/* more endianness... should move to a separate file... */ -#if defined(__sgi) || defined (__sparc) || defined (__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__hppa__) || defined (__BIG_ENDIAN__) -#define GET_ID GET_BIG_LONG -#define LITTLE_LONG SWAP_LONG -#else -#define GET_ID GET_LITTLE_LONG -#define LITTLE_LONG ENDIAN_NOP -#endif - -static uchar *decodebodyscanl(uchar *body, short bytes, uchar **list, short d) -{ - for (;d>0;d--){ - uchar *point; - short todo; - uchar i,j; - - point = *(list++); - todo=bytes; - while (todo>0){ - i = *body++; - - if (i & 128){ /* fill */ - if (i==128) continue; /* nop */ - - i=257-i; - todo-=i; - j = *(body++); - do{ - *(point++) = j; - i--; - }while (i); - } else{ /* copy */ - i++; - todo-=i; - - do{ - *(point++) = *(body++); - i--; - }while (i); - } - } - if (todo) return (0); - } - return(body); -} - - -static uchar *decodebodyh(struct ImBuf *ibuf, uchar *body) -{ - if (ibuf->y==1) { - body=decodebodyscanl(body, WIDTHB(ibuf->x), (uchar **)ibuf->planes, ibuf->depth); - } - else { - unsigned int **list; - short skipx,i,bytes,y; - - list = imb_copyplanelist(ibuf); - if (list == 0) return (0); - - y=ibuf->y; - bytes = WIDTHB(ibuf->x); - skipx = ibuf->skipx; - - for (;y>0;y--){ - body=decodebodyscanl(body, bytes, (uchar **)list, ibuf->depth); - if (body == 0) return (0); - - for (i=ibuf->depth-1;i>=0;i--){ - list[i] += skipx; - } - } - free(list); - } - return(body); -} - - -static uchar *decodebodykolum(uchar *body, short bytes, uchar **list, short d, int next) -{ - for (;d>0;d--){ - uchar *point; - short todo; - uchar i,j; - - point = *(list++); - todo=bytes; - while (todo>0){ - i = *body++; - - if (i & 128){ /* fill */ - if (i==128) continue; /* nop */ - - i=257-i; - todo-=i; - j = *body++; - do{ - *point = j; - point += next; - i--; - }while (i); - } - else{ /* copy */ - i++; - todo-=i; - - do{ - *point = *body++; - point += next; - i--; - }while (i); - } - } - if (todo) return (0); - } - return(body); -} - - -static uchar *decodebodyv(struct ImBuf *ibuf, uchar *body) -{ - uchar **list; - int skipx, i, bytes, times; - - list = (uchar **)imb_copyplanelist(ibuf); - if (list == 0) return (0); - - bytes = ibuf->y; - times = WIDTHB(ibuf->x); - skipx = ibuf->skipx << 2; - - for (;times>0;times--){ - body=decodebodykolum(body,bytes,list,ibuf->depth,skipx); - if (body == 0) return (0); - - for (i=ibuf->depth-1;i>=0;i--){ - list[i] += 1; - } - } - free(list); - return(body); -} - -static uchar *makebody(uchar **planes, short bytes, short depth, uchar *buf) -{ - uchar *bitplstart,*temp; - - register uchar last,this,*bitpl; - register short todo; - register int copy; - - bytes--; - for (;depth>0;depth--){ - bitpl = *(planes++); - bitplstart = bitpl; - todo = bytes; - last = *bitpl++; - this = *bitpl++; - copy = last^this; - while (todo>0){ - - if (copy){ - do{ - last = this; - this = *bitpl++; - if (last == this){ - if (this == bitpl[-3]){ /* three identical ones? */ - todo -= 1; /* set todo */ - break; - } - } - }while (--todo != 0); - - copy=bitpl-bitplstart; - copy -= 1; - if (todo) copy -= 2; - - temp = bitpl; - bitpl = bitplstart; - - while (copy){ - last = copy; - if (copy>MAXDAT) last = MAXDAT; - copy -= last; - *buf++ = last-1; - do{ - *buf++ = *bitpl++; - }while(--last != 0); - } - bitplstart = bitpl; - bitpl = temp; - last = this; - - copy = FALSE; - } - else{ - while (*bitpl++ == this){ /* search for first different bye */ - if (--todo == 0) break; /* or end of line */ - } - bitpl -= 1; - copy = bitpl-bitplstart; - bitplstart = bitpl; - todo -= 1; - this = *bitpl++; - - while (copy){ - if (copy>MAXRUN){ - *buf++ = -(MAXRUN-1); - *buf++ = last; - copy -= MAXRUN; - } - else{ - *buf++ = -(copy-1); - *buf++ = last; - break; - } - } - copy=TRUE; - } - } - } - return (buf); -} - - -short imb_encodebodyh(struct ImBuf *ibuf, int file) -{ - uchar *buf, *endbuf, *max; - int size, line, ok = TRUE; - unsigned int **list; - short skipx,i,y; - - line = WIDTHB(ibuf->x) * ibuf->depth; - line += (line >> 6) + 10; - size = 16 * line; - if (size < 16384) size = 16384; - - buf = (uchar *) malloc(size); - if (buf == 0) return (0); - - max = buf + size - line; - - list = imb_copyplanelist(ibuf); - if (list == 0){ - free(buf); - return (0); - } - - y=ibuf->y; - skipx = ibuf->skipx; - endbuf = buf; - - for (y=ibuf->y;y>0;y--){ - endbuf = makebody((uchar **)list, WIDTHB(ibuf->x), ibuf->depth, endbuf); - if (endbuf==0){ - ok = -20; - break; - } - if (endbuf >= max || y == 1){ - size = endbuf-buf; - if (write(file,buf,size)!=size) ok = -19; - endbuf = buf; - } - for (i=ibuf->depth-1;i>=0;i--){ - list[i] += skipx; - } - if (ok != TRUE) break; - } - free(list); - - free(buf); - return(ok); -} - - -short imb_encodebodyv(struct ImBuf *ibuf, int file) -{ - struct ImBuf *ibufv; - uchar *buf,*endbuf; - short x,offset; - - buf = (uchar *) malloc((ibuf->y + (ibuf->y >> 6) + 10) * ibuf->depth); - if (buf == 0) return (0); - - ibufv=IMB_allocImBuf((ibuf->y)<<3,1, ibuf->depth, 0, 1); - if (ibufv == 0){ - free(buf); - return (0); - } - - offset=0; - - for(x = WIDTHB(ibuf->x);x>0;x--){ - register short i; - - for(i = ibuf->depth-1 ;i>=0;i--){ - register uchar *p1,*p2; - register int skipx; - register short y; - - skipx = (ibuf->skipx)*sizeof(int *); - p1=(uchar *)ibuf->planes[i]; - p2=(uchar *)ibufv->planes[i]; - p1 += offset; - - for (y=ibuf->y;y>0;y--){ - *(p2++) = *p1; - p1 += skipx; - } - } - offset += 1; - - endbuf=makebody((uchar **)ibufv->planes, ibuf->y, ibuf->depth, buf); - if (endbuf==0) return (-20); - if (write(file,buf,endbuf-buf)!=endbuf-buf) return (-19); - } - free(buf); - IMB_freeImBuf(ibufv); - return (TRUE); -} - -static uchar *readbody(struct ImBuf *ibuf, uchar *body) -{ - int skipbuf,skipbdy,depth,y,offset = 0; - - skipbuf = ibuf->skipx; - skipbdy = WIDTHB(ibuf->x); - - for (y = ibuf->y; y> 0; y--){ - for( depth = 0; depth < ibuf->depth; depth ++){ - memcpy(ibuf->planes[depth] + offset, body, skipbdy); - body += skipbdy; - } - offset += skipbuf; - } - return body; -} - -struct ImBuf *imb_loadamiga(int *iffmem,int flags) -{ - int chunk,totlen,len,*cmap=0,cmaplen =0,*mem,ftype=0; - uchar *body=0; - struct BitMapHeader bmhd; - struct ImBuf *ibuf=0; - - mem = iffmem; - bmhd.w = 0; - - if (GET_ID(mem) != FORM) return (0); - if (GET_ID(mem+2) != ILBM) return (0); - totlen= (GET_BIG_LONG(mem+1) + 1) & ~1; - mem += 3; - totlen -= 4; - - - while(totlen > 0){ - chunk = GET_ID(mem); - len= (GET_BIG_LONG(mem+1) + 1) & ~1; - mem += 2; - - totlen -= len+8; - - switch (chunk){ - case BMHD: - memcpy(&bmhd, mem, sizeof(struct BitMapHeader)); - - bmhd.w = BIG_SHORT(bmhd.w); - bmhd.h = BIG_SHORT(bmhd.h); - bmhd.x = BIG_SHORT(bmhd.x); - bmhd.y = BIG_SHORT(bmhd.y); - bmhd.transparentColor = BIG_SHORT(bmhd.transparentColor); - bmhd.pageWidth = BIG_SHORT(bmhd.pageWidth); - bmhd.pageHeight = BIG_SHORT(bmhd.pageHeight); - - break; - case BODY: - body = (uchar *)mem; - break; - case CMAP: - cmap = mem; - cmaplen = len/3; - break; - case CAMG: - ftype = GET_BIG_LONG(mem); - break; - } - mem = (int *)((uchar *)mem +len); - if (body) break; - } - if (bmhd.w == 0) return (0); - if (body == 0) return (0); - - if (flags & IB_test) ibuf = IMB_allocImBuf(bmhd.w, bmhd.h, bmhd.nPlanes, 0, 0); - else ibuf = IMB_allocImBuf(bmhd.w, bmhd.h, bmhd.nPlanes + (bmhd.masking & 1),0,1); - - if (ibuf == 0) return (0); - - ibuf->ftype = (ftype | AMI); - ibuf->profile = IB_PROFILE_SRGB; - - if (cmap){ - ibuf->mincol = 0; - ibuf->maxcol = cmaplen; - imb_addcmapImBuf(ibuf); - imb_makecolarray(ibuf, (uchar *)cmap, 0); - } - - if (flags & IB_test){ - if (flags & IB_freem) free(iffmem); - return(ibuf); - } - - switch (bmhd.compression){ - case 0: - body= readbody(ibuf, body); - break; - case 1: - body= decodebodyh(ibuf,body); - break; - case 2: - body= decodebodyv(ibuf,body); - ibuf->type |= IB_subdlta; - break; - } - - if (flags & IB_freem) free(iffmem); - - if (body == 0){ - free (ibuf); - return(0); - } - - /* forget stencil */ - ibuf->depth = bmhd.nPlanes; - - if (flags & IB_rect){ - imb_addrectImBuf(ibuf); - imb_bptolong(ibuf); - imb_freeplanesImBuf(ibuf); - if (ibuf->cmap){ - if ((flags & IB_cmap) == 0) IMB_applycmap(ibuf); - } else if (ibuf->depth == 18){ - int i,col; - unsigned int *rect; - - rect = ibuf->rect; - for(i=ibuf->x * ibuf->y ; i>0 ; i--){ - col = *rect; - col = ((col & 0x3f000) << 6) + ((col & 0xfc0) << 4) + ((col & 0x3f) << 2); - col += (col & 0xc0c0c0) >> 6; - *rect++ = col; - } - ibuf->depth = 24; - } else if (ibuf->depth <= 8) { /* no colormap and no 24 bits: b&w */ - uchar *rect; - int size, shift; - - if (ibuf->depth < 8){ - rect = (uchar *) ibuf->rect; - rect += 3; - shift = 8 - ibuf->depth; - for (size = ibuf->x * ibuf->y; size > 0; size --){ - rect[0] <<= shift; - rect += 4; - } - } - rect = (uchar *) ibuf->rect; - for (size = ibuf->x * ibuf->y; size > 0; size --){ - rect[1] = rect[2] = rect[3]; - rect += 4; - } - ibuf->depth = 8; - } - } - - if ((flags & IB_ttob) == 0) IMB_flipy(ibuf); - - if (ibuf) { - if (ibuf->rect) - if (ENDIAN_ORDER == B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf); - } - - return (ibuf); -} diff --git a/source/blender/imbuf/intern/anim.c b/source/blender/imbuf/intern/anim.c index 188f3580170..bc0f9225fbc 100644 --- a/source/blender/imbuf/intern/anim.c +++ b/source/blender/imbuf/intern/anim.c @@ -64,7 +64,6 @@ #include "BKE_global.h" #include "imbuf.h" -#include "imbuf_patch.h" #include "AVI_avi.h" @@ -78,9 +77,7 @@ #include "IMB_imbuf.h" #include "IMB_allocimbuf.h" -#include "IMB_bitplanes.h" #include "IMB_anim.h" -#include "IMB_anim5.h" #ifdef WITH_FFMPEG #include @@ -327,7 +324,6 @@ void IMB_free_anim(struct anim * anim) { } IMB_free_anim_ibuf(anim); - free_anim_anim5(anim); free_anim_movie(anim); free_anim_avi(anim); @@ -341,7 +337,7 @@ void IMB_free_anim(struct anim * anim) { free_anim_redcode(anim); #endif - free(anim); + MEM_freeN(anim); } void IMB_close_anim(struct anim * anim) { @@ -476,7 +472,7 @@ static ImBuf * avi_fetchibuf (struct anim *anim, int position) { if (anim->pgf) { lpbi = AVIStreamGetFrame(anim->pgf, position + AVIStreamStart(anim->pavi[anim->firstvideo])); if (lpbi) { - ibuf = IMB_ibImageFromMemory((int *) lpbi, 100, IB_rect); + ibuf = IMB_ibImageFromMemory((unsigned char *) lpbi, 100, IB_rect); //Oh brother... } } @@ -995,7 +991,6 @@ static struct ImBuf * anim_getnew(struct anim * anim) { if (anim == NULL) return(0); - free_anim_anim5(anim); free_anim_movie(anim); free_anim_avi(anim); #ifdef WITH_QUICKTIME @@ -1013,10 +1008,6 @@ static struct ImBuf * anim_getnew(struct anim * anim) { anim->curtype = imb_get_anim_type(anim->name); switch (anim->curtype) { - case ANIM_ANIM5: - if (startanim5(anim)) return (0); - ibuf = anim5_fetchibuf(anim); - break; case ANIM_SEQUENCE: ibuf = IMB_loadiffname(anim->name, anim->ib_flags); if (ibuf) { @@ -1094,26 +1085,13 @@ struct ImBuf * IMB_anim_absolute(struct anim * anim, int position) { if (position >= anim->duration) return(0); switch(anim->curtype) { - case ANIM_ANIM5: - if (anim->curposition > position) rewindanim5(anim); - while (anim->curposition < position) { - if (nextanim5(anim)) return (0); - } - ibuf = anim5_fetchibuf(anim); - ibuf->profile = IB_PROFILE_SRGB; - break; case ANIM_SEQUENCE: pic = an_stringdec(anim->first, head, tail, &digits); pic += position; an_stringenc(anim->name, head, tail, digits, pic); - ibuf = IMB_loadiffname(anim->name, LI_rect); + ibuf = IMB_loadiffname(anim->name, IB_rect); if (ibuf) { anim->curposition = position; - /* patch... by freeing the cmap you prevent a double apply cmap... */ - /* probably the IB_CMAP option isn't working proper - * after the abgr->rgba reconstruction - */ - IMB_freecmapImBuf(ibuf); } break; case ANIM_MOVIE: @@ -1153,7 +1131,6 @@ struct ImBuf * IMB_anim_absolute(struct anim * anim, int position) { } if (ibuf) { - if (anim->ib_flags & IB_ttob) IMB_flipy(ibuf); if (filter_y) IMB_filtery(ibuf); sprintf(ibuf->name, "%s.%04d", anim->name, anim->curposition + 1); @@ -1161,16 +1138,6 @@ struct ImBuf * IMB_anim_absolute(struct anim * anim, int position) { return(ibuf); } -struct ImBuf * IMB_anim_nextpic(struct anim * anim) { - struct ImBuf * ibuf = 0; - - if (anim == 0) return(0); - - ibuf = IMB_anim_absolute(anim, anim->curposition + 1); - - return(ibuf); -} - /***/ int IMB_anim_get_duration(struct anim *anim) { diff --git a/source/blender/imbuf/intern/anim5.c b/source/blender/imbuf/intern/anim5.c deleted file mode 100644 index 41c4c2c610b..00000000000 --- a/source/blender/imbuf/intern/anim5.c +++ /dev/null @@ -1,539 +0,0 @@ -/** - * anim5.c - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): phase, code torn apart from anim.c - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include "BLI_blenlib.h" /* BLI_remlink BLI_filesize BLI_addtail - BLI_countlist BLI_stringdec */ - -#include "imbuf.h" -#include "imbuf_patch.h" - -#include "IMB_imbuf_types.h" -#include "IMB_imbuf.h" - -#include "IMB_cmap.h" -#include "IMB_allocimbuf.h" -#include "IMB_bitplanes.h" -#include "IMB_amiga.h" - -#include "IMB_anim.h" - -#include "IMB_anim5.h" - -#ifdef _WIN32 -#include -#include "BLI_winstuff.h" -#endif - -typedef struct Anhd{ - unsigned char type, mask; - unsigned short w, h; - unsigned short x, y; - unsigned short abs16, abs, reala6, real; - unsigned char interleave, pad0; - unsigned short bits16, bits; - unsigned char pad[16]; -}Anhd; - -typedef struct Anim5Delta { - struct Anim5Delta * next, * prev; - void * data; - int type; -}Anim5Delta; - - -/* om anim5's te kunnen lezen, moet een aantal gegevens bijgehouden worden: - * Een lijst van pointers naar delta's, in geheugen of ge'mmap'ed - * - * Mogelijk kan er ook een 'skiptab' aangelegd worden, om sneller - * sprongen te kunnen maken. - * - * Er moeten niet direct al plaatjes gegenereed worden, dit maakt de - * routines onbruikbaar om snel naar het goede plaatje te springen. - * Een routine voert dus de delta's uit, een andere routine maakt van - * voorgrondplaatje een ibuf; - */ - - -/* - een aantal functie pointers moet geinporteerd worden, zodat er niet - nog meer library's / objects meegelinkt hoeven te worden. - - Dezelfde structuur moet ook gebruikt kunnen worden voor het wegschrijven - van animaties. Hoe geef je dit aan ? - - Hoe snel kunnen 10 .dlta's gedecomprimeerd worden - (zonder omzetten naar rect). - - 1 - zoek naar 1e plaatje, animatie die aan de eisen voldoet - 2 - probeer volgende plaatje te vinden: - anim5 - decomprimeer - sequence - teller ophogen - directory - volgende entry - 3 - geen succes ? ga naar 1. - - -*/ - -/* - 1. Initialiseer routine met toegestane reeksen, en eerste naam - - series op naam (.0001) - - directories - - anim5 animaties - - TGA delta's - - iff 24bits delta's (.delta) - - 2. haal volgende (vorige ?) plaatje op. - - 3. vrijgeven -*/ - -/* selectie volgorde is: - 1 - anim5() - 2 - name - 3 - dir -*/ - -void free_anim_anim5(struct anim * anim) { - ListBase * animbase; - Anim5Delta * delta, * next; - - if (anim == NULL) return; - - animbase = &anim->anim5base; - delta = animbase->first; - - while (delta) { - next = delta->next; - - if (delta->type == ANIM5_MALLOC) free(delta->data); - BLI_remlink(animbase, delta); - free(delta); - - delta = next; - } - - if (anim->anim5mmap && anim->anim5len) { - MEM_freeN(anim->anim5mmap); - } - - anim->anim5mmap = NULL; - anim->anim5len = 0; - anim->anim5curdlta = 0; - anim->duration = 0; -} - -static void planes_to_rect(struct ImBuf * ibuf, int flags) { - if (ibuf == 0) return; - - /* dit komt regelrecht uit de amiga.c */ - - if (flags & IB_rect && ibuf->rect == 0) { - imb_addrectImBuf(ibuf); - imb_bptolong(ibuf); - IMB_flipy(ibuf); - imb_freeplanesImBuf(ibuf); - - if (ibuf->cmap){ - if ((flags & IB_cmap) == 0) { - IMB_applycmap(ibuf); - IMB_convert_rgba_to_abgr(ibuf); - } - } else if (ibuf->depth == 18){ - int i,col; - unsigned int *rect; - - rect = ibuf->rect; - for(i=ibuf->x * ibuf->y ; i>0 ; i--){ - col = *rect; - col = ((col & 0x3f000) << 6) + ((col & 0xfc0) << 4) - + ((col & 0x3f) << 2); - col += (col & 0xc0c0c0) >> 6; - *rect++ = col; - } - ibuf->depth = 24; - } else if (ibuf->depth <= 8) { - /* geen colormap en geen 24 bits: zwartwit */ - uchar *rect; - int size, shift; - - if (ibuf->depth < 8){ - rect = (uchar *) ibuf->rect; - rect += 3; - shift = 8 - ibuf->depth; - for (size = ibuf->x * ibuf->y; size > 0; size --){ - rect[0] <<= shift; - rect += 4; - } - } - rect = (uchar *) ibuf->rect; - for (size = ibuf->x * ibuf->y; size > 0; size --){ - rect[1] = rect[2] = rect[3]; - rect += 4; - } - ibuf->depth = 8; - } - } -} - - -static void anim5decode(struct ImBuf * ibuf, uchar * dlta) { - uchar depth; - int skip; - int *ofspoint; - uchar **planes; - - /* composition delta: - list with ofsets for delta' s by bitplane (ofspoint) - by column in delta (point) - number of operations (noops) - code - associated data - ... - ... - */ - - dlta += 8; - - ofspoint = (int *)dlta; - skip = ibuf->skipx * sizeof(int *); - planes = (uchar **)ibuf->planes; - - for(depth=ibuf->depth ; depth>0 ; depth--){ - if (GET_BIG_LONG(ofspoint)){ - uchar *planestart; - uchar *point; - uchar x; - - point = dlta + GET_BIG_LONG(ofspoint); - planestart = planes[0]; - x = (ibuf->x + 7) >> 3; - - do{ - uchar noop; - - if ( (noop = *(point++)) ){ - uchar *plane; - uchar code; - - plane = planestart; - do{ - if ((code = *(point++))==0){ - uchar val; - - code = *(point++); - val = *(point++); - do { - plane[0] = val; - plane += skip; - } while(--code); - - } else if (code & 128){ - - code &= 0x7f; - do{ - plane[0] = *(point++); - plane += skip; - } while(--code); - - } else plane += code * skip; - - } while(--noop); - } - planestart++; - } while(--x); - } - ofspoint++; - planes++; - } -} - - -static void anim5xordecode(struct ImBuf * ibuf, uchar * dlta) { - uchar depth; - int skip; - int *ofspoint; - uchar **planes; - - /* samenstelling delta: - lijst met ofsets voor delta's per bitplane (ofspoint) - per kolom in delta (point) - aantal handelingen (noops) - code - bijbehorende data - ... - ... - */ - - dlta += 8; - - ofspoint = (int *)dlta; - skip = ibuf->skipx * sizeof(int *); - planes = (uchar **)ibuf->planes; - - for(depth=ibuf->depth ; depth>0 ; depth--){ - - if (GET_BIG_LONG(ofspoint)){ - uchar *planestart; - uchar *point; - uchar x; - - point = dlta + GET_BIG_LONG(ofspoint); - planestart = planes[0]; - x = (ibuf->x + 7) >> 3; - - do{ - uchar noop; - - if ( (noop = *(point++)) ){ - uchar *plane; - uchar code; - - plane = planestart; - do{ - if ((code = *(point++))==0){ - uchar val; - - code = *(point++); - val = *(point++); - do{ - plane[0] ^= val; - plane += skip; - }while(--code); - - } else if (code & 128){ - - code &= 0x7f; - do{ - plane[0] ^= *(point++); - plane += skip; - }while(--code); - - } else plane += code * skip; - - }while(--noop); - } - planestart++; - }while(--x); - } - ofspoint++; - planes++; - } -} - - -int nextanim5(struct anim * anim) { - Anim5Delta * delta; - struct ImBuf * ibuf; - - if (anim == 0) return(-1); - - delta = anim->anim5curdlta; - - if (delta == 0) return (-1); - - if (anim->anim5flags & ANIM5_SNGBUF) { - ibuf = anim->ibuf1; - if (ibuf == 0) return (0); - anim->anim5decode(ibuf, delta->data); - } else { - ibuf = anim->ibuf2; - if (ibuf == 0) return (0); - anim->anim5decode(ibuf, delta->data); - anim->ibuf2 = anim->ibuf1; - anim->ibuf1 = ibuf; - } - - anim->anim5curdlta = anim->anim5curdlta->next; - anim->curposition++; - - return(0); -} - -int rewindanim5(struct anim * anim) { - Anim5Delta * delta; - struct ImBuf * ibuf; - - if (anim == 0) return (-1); - - IMB_free_anim_ibuf(anim); - - delta = anim->anim5base.first; - if (delta == 0) return (-1); - - ibuf = IMB_loadiffmem(delta->data, IB_planes); - if (ibuf == 0) return(-1); - - anim->ibuf1 = ibuf; - if ((anim->anim5flags & ANIM5_SNGBUF) == 0) anim->ibuf2 = IMB_dupImBuf(ibuf); - - anim->anim5curdlta = delta->next; - anim->curposition = 0; - - return(0); -} - - -int startanim5(struct anim * anim) { - int file, buf[20], totlen; - unsigned int len; - short * mem; - ListBase * animbase; - Anim5Delta * delta; - Anhd anhd; - - /* Controles */ - - if (anim == 0) return(-1); - - file = open(anim->name,O_BINARY|O_RDONLY); - if (file < 0) return (-1); - - if (read(file, buf, 24) != 24) { - close(file); - return(-1); - } - - if ((GET_ID(buf) != FORM) || (GET_ID(buf + 2) != ANIM) - || (GET_ID(buf + 3) != FORM) || (GET_ID(buf + 5) != ILBM)){ - printf("No anim5 file %s\n",anim->name); - close(file); - return (-1); - } - - /* de hele file wordt in het geheugen gemapped */ - - totlen = BLI_filesize(file); - if (totlen>0 && file>=0) { - lseek(file, 0L, SEEK_SET); - - mem= MEM_mallocN(totlen, "mmap"); - if (read(file, mem, totlen) != totlen) { - MEM_freeN(mem); - mem = NULL; - } - } else { - mem = NULL; - } - close (file); - - if (!mem) return (-1); - - anhd.interleave = 0; - anhd.bits = 0; - anhd.type = 5; - - anim->anim5mmap = mem; - anim->anim5len = totlen; - anim->anim5flags = 0; - anim->duration = 0; - - animbase = & anim->anim5base; - animbase->first = animbase->last = 0; - - /* eerste plaatje inlezen */ - - mem = mem + 6; - totlen -= 12; - - len = GET_BIG_LONG(mem + 2); - len = (len + 8 + 1) & ~1; - delta = NEW(Anim5Delta); - - delta->data = mem; - delta->type = ANIM5_MMAP; - - BLI_addtail(animbase, delta); - - mem += (len >> 1); - totlen -= len; - - while (totlen > 0) { - len = GET_BIG_LONG(mem + 2); - len = (len + 8 + 1) & ~1; - - switch(GET_ID(mem)){ - case FORM: - len = 12; - break; - case ANHD: - memcpy(&anhd, mem + 4, sizeof(Anhd)); - break; - case DLTA: - delta = NEW(Anim5Delta); - delta->data = mem; - delta->type = ANIM5_MMAP; - BLI_addtail(animbase, delta); - break; - } - - mem += (len >> 1); - totlen -= len; - } - - if (anhd.interleave == 1) anim->anim5flags |= ANIM5_SNGBUF; - if (BIG_SHORT(anhd.bits) & 2) anim->anim5decode = anim5xordecode; - else anim->anim5decode = anim5decode; - - /* laatste twee delta's wissen */ - - delta = animbase->last; - if (delta) { - BLI_remlink(animbase, delta); - free(delta); - } - - if ((anim->anim5flags & ANIM5_SNGBUF) == 0) { - delta = animbase->last; - if (delta) { - BLI_remlink(animbase, delta); - free(delta); - } - } - - anim->duration = BLI_countlist(animbase); - - return(rewindanim5(anim)); -} - - -struct ImBuf * anim5_fetchibuf(struct anim * anim) { - struct ImBuf * ibuf; - - if (anim == 0) return (0); - - ibuf = IMB_dupImBuf(anim->ibuf1); - planes_to_rect(ibuf, anim->ib_flags); - - ibuf->profile = IB_PROFILE_SRGB; - - return(ibuf); -} - diff --git a/source/blender/imbuf/intern/antialias.c b/source/blender/imbuf/intern/antialias.c deleted file mode 100644 index e3a878d0ac4..00000000000 --- a/source/blender/imbuf/intern/antialias.c +++ /dev/null @@ -1,466 +0,0 @@ -/** - * antialias.c - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include "imbuf.h" - -#include "BLI_blenlib.h" -#include "DNA_listBase.h" - -#include "imbuf_patch.h" -#include "IMB_imbuf_types.h" -#include "IMB_imbuf.h" -#include "IMB_allocimbuf.h" - -/* how it works: - -1 - seek for a transistion in a collumn -2 - check the relationship with left and right, - -Is pixel above transition to the left or right equal to the top color, seek down - -Is pixel below transition to the left or right equal to the bottom color, seek up - -*/ - -/* there should be a funcion * to indicate if two colors are - * equal or not. - * For now we use a define - */ - - -static unsigned int anti_mask = 0xffffffff; -static int anti_a, anti_b, anti_g, anti_r; - -#define compare(x, y) ((x ^ y) & anti_mask) - -typedef struct Edge -{ - struct Edge * next, * prev; - short position; - int col1, col2; -}Edge; - -static void anti_free_listarray(int count, ListBase * listarray) -{ - int i; - - if (listarray == 0) return; - - for (i = 0; i < count; i++) BLI_freelistN(listarray + i); - MEM_freeN(listarray); -} - -static ListBase * scanimage(struct ImBuf * ibuf, int dir) -{ - int step, pixels, lines, nextline, x, y, col1, col2; - unsigned int * rect; - ListBase * listarray, * curlist; - Edge * edge; - int count; - - switch (dir) { - case 'h': - step = 1; nextline = ibuf->x; - pixels = ibuf->x; lines = ibuf->y; - break; -/* case 'v': changed so assured values for step etc.. */ - default: - step = ibuf->x; nextline = 1; - pixels = ibuf->y; lines = ibuf->x; - } - - listarray = (ListBase*)MEM_callocN((lines)* sizeof(ListBase), "listarray"); - for (y = 0; y < lines; y++){ - rect = ibuf->rect; - rect += y * nextline; - curlist = listarray + y; - - col1 = rect[0]; - count = 0; - - for (x = 0; x < pixels; x++) { - col2 = rect[0]; - if (compare(col1, col2)) { - edge = NEW(Edge); - - if (edge == NULL) return(0); - - edge->position = x; - edge->col1 = col1; - edge->col2 = col2; - BLI_addtail(curlist, edge); - col1 = col2; - count++; - if (count > 100) { - printf("\n\n%s: Aborting antialias !\n", ibuf->name); - printf("To many transitions.\nIs this a natural image ?\n\n"), - anti_free_listarray(lines, listarray); - return(0); - } - } - rect += step; - } - } - - return(listarray); -} - - -static Edge * findmatch(Edge * first, Edge * edge) -{ - Edge * match = 0; - int in = 0, out = 65535; - - if (edge->prev) in = edge->prev->position; - if (edge->next) out = edge->next->position; - - while (first) { - if (first->position < edge->position) { - if (first->col1 == edge->col1) { - if (first->position >= in) match = first; - } else if (first->col2 == edge->col2) { - if (first->next == 0) match = first; - else if (first->next->position >= edge->position) match = first; - } else if (first->col2 == edge->col1) { - match = 0; /* at 'sig saw' situations this one can be wrongly set */ - } - } else if (first->position == edge->position) { - if (first->col1 == edge->col1 || first->col2 == edge->col2) match = first; - } else { - if (match) break; /* there is one */ - - if (first->col1 == edge->col1) { - if (first->prev == 0) match = first; - else if (first->prev->position <= edge->position) match = first; - } else if (first->col2 == edge->col2) { - if (first->position <= out) match = first; - } - } - - first = first->next; - } - - return(match); -} - - -static void filterdraw(unsigned int * ldest, unsigned int * lsrce, int zero, int half, int step) -{ - uchar * src, * dst; - int count; - double weight, add; - - /* we filter the pixels at ldest between in and out with pixels from lsrce - * weight values go from 0 to 1 - */ - - - count = half - zero; - if (count < 0) count = -count; - if (count <= 1) return; - - if (zero < half) { - src = (uchar *) (lsrce + (step * zero)); - dst = (uchar *) (ldest + (step * zero)); - } else { - zero--; - src = (uchar *) (lsrce + (step * zero)); - dst = (uchar *) (ldest + (step * zero)); - step = -step; - } - - step = 4 * step; - - dst += step * (count >> 1); - src += step * (count >> 1); - - count = (count + 1) >> 1; - add = 0.5 / count; - weight = 0.5 * add; - - /* this of course gamma corrected */ - - for(; count > 0; count --) { - if (anti_a) dst[0] += weight * (src[0] - dst[0]); - if (anti_b) dst[1] += weight * (src[1] - dst[1]); - if (anti_g) dst[2] += weight * (src[2] - dst[2]); - if (anti_r) dst[3] += weight * (src[3] - dst[3]); - dst += step; - src += step; - weight += add; - } -} - -static void filterimage(struct ImBuf * ibuf, struct ImBuf * cbuf, ListBase * listarray, int dir) -{ - int step, pixels, lines, nextline, y, pos, drawboth; - unsigned int * irect, * crect; - Edge * left, * middle, * right, temp, * any; - - switch (dir) { - case 'h': - step = 1; nextline = ibuf->x; - pixels = ibuf->x; lines = ibuf->y; - break; -/* case 'v': changed so have values */ - default: - step = ibuf->x; nextline = 1; - pixels = ibuf->y; lines = ibuf->x; - } - - for (y = 1; y < lines - 1; y++){ - irect = ibuf->rect; - irect += y * nextline; - crect = cbuf->rect; - crect += y * nextline; - - middle = listarray[y].first; - while (middle) { - left = findmatch(listarray[y - 1].first, middle); - right = findmatch(listarray[y + 1].first, middle); - drawboth = FALSE; - - if (left == 0 || right == 0) { - /* edge */ - any = left; - if (right) any = right; - if (any) { - /* mirroring */ - pos = 2 * middle->position - any->position; - - if (any->position < middle->position) { - if (pos > pixels - 1) pos = pixels - 1; - if (middle->next) { - if (pos > middle->next->position) pos = middle->next->position; - } -/* if (any->next) { - if (pos > any->next->position) pos = any->next->position; - } -*/ } else { - if (pos < 0) pos = 0; - if (middle->prev) { - if (pos < middle->prev->position) pos = middle->prev->position; - } -/* if (any->prev) { - if (pos < any->prev->position) pos = any->prev->position; - } -*/ } - temp.position = pos; - if (left) right = &temp; - else left = &temp; - drawboth = TRUE; - } - } else if (left->position == middle->position || right->position == middle->position) { - /* straight piece */ - /* small corner, with one of the two at distance 2 (the other is at dist 0) ? */ - - if (abs(left->position - right->position) == 2) drawboth = TRUE; - } else if (left->position < middle->position && right->position > middle->position){ - /* stair 1 */ - drawboth = TRUE; - } else if (left->position > middle->position && right->position < middle->position){ - /* stair 2 */ - drawboth = TRUE; - } else { - /* a peek */ - drawboth = TRUE; - } - - if (drawboth) { - filterdraw(irect, crect - nextline, left->position, middle->position, step); - filterdraw(irect, crect + nextline, right->position, middle->position, step); - } - - middle = middle->next; - } - } -} - - -void IMB_antialias(struct ImBuf * ibuf) -{ - struct ImBuf * cbuf; - ListBase * listarray; - - if (ibuf == 0) return; - cbuf = IMB_dupImBuf(ibuf); - if (cbuf == 0) return; - - anti_a = (anti_mask >> 24) & 0xff; - anti_b = (anti_mask >> 16) & 0xff; - anti_g = (anti_mask >> 8) & 0xff; - anti_r = (anti_mask >> 0) & 0xff; - - listarray = scanimage(cbuf, 'h'); - if (listarray) { - filterimage(ibuf, cbuf, listarray, 'h'); - anti_free_listarray(ibuf->y, listarray); - - listarray = scanimage(cbuf, 'v'); - if (listarray) { - filterimage(ibuf, cbuf, listarray, 'v'); - anti_free_listarray(ibuf->x, listarray); - } - } - - IMB_freeImBuf(cbuf); -} - - -/* intelligent scaling */ - -static void _intel_scale(struct ImBuf * ibuf, ListBase * listarray, int dir) -{ - int step, lines, nextline, x, y, col; - unsigned int * irect, * trect; - int start, end; - Edge * left, * right; - struct ImBuf * tbuf; - - switch (dir) { - case 'h': - step = 1; nextline = ibuf->x; - lines = ibuf->y; - tbuf = IMB_double_fast_y(ibuf); - break; - case 'v': - step = 2 * ibuf->x; nextline = 1; - lines = ibuf->x; - tbuf = IMB_double_fast_x(ibuf); - break; - default: - return; - } - - if (tbuf == NULL) return; - - imb_freerectImBuf(ibuf); - - ibuf->rect = tbuf->rect; - ibuf->mall |= IB_rect; - - ibuf->x = tbuf->x; - ibuf->y = tbuf->y; - tbuf->rect = 0; - IMB_freeImBuf(tbuf); - - for (y = 0; y < lines - 2; y++){ - irect = ibuf->rect; - irect += ((2 * y) + 1) * nextline; - - left = listarray[y].first; - while (left) { - right = findmatch(listarray[y + 1].first, left); - if (right) { - if (left->col2 == right->col2) { - if (left->next && right->next) { - if (left->next->position >= right->position) { - start = ((left->position + right->position) >> 1); - end = ((left->next->position + right->next->position) >> 1); - col = left->col2; - trect = irect + (start * step); - for (x = start; x < end; x++) { - *trect = col; - trect += step; - } - } - } - } - - if (left->col1 == right->col1) { - if (left->prev && right->prev) { - if (left->prev->position <= right->position) { - end = ((left->position + right->position) >> 1); - start = ((left->prev->position + right->prev->position) >> 1); - col = left->col1; - trect = irect + (start * step); - for (x = start; x < end; x++) { - *trect = col; - trect += step; - } - } - } - } - - } - left = left->next; - } - } -} - - -void IMB_clever_double(struct ImBuf * ibuf) -{ - ListBase * listarray, * curlist; - Edge * new; - int size; - int i; - - if (ibuf == 0) return; - - size = ibuf->x; - listarray = scanimage(ibuf, 'v'); - if (listarray) { - for (i = 0; i < size; i++) { - curlist = listarray + i; - new = (Edge*)MEM_callocN(sizeof(Edge),"Edge"); - new->col2 = ibuf->rect[i]; /* upper pixel */ - new->col1 = new->col2 - 1; - BLI_addhead(curlist, new); - new = (Edge*)MEM_callocN(sizeof(Edge),"Edge"); - new->position = ibuf->y - 1; - new->col1 = ibuf->rect[i + ((ibuf->y -1) * ibuf->x)]; /* bottom pixel */ - new->col2 = new->col1 - 1; - BLI_addtail(curlist, new); - } - _intel_scale(ibuf, listarray, 'v'); - anti_free_listarray(size, listarray); - - size = ibuf->y; - listarray = scanimage(ibuf, 'h'); - if (listarray) { - for (i = 0; i < size; i++) { - curlist = listarray + i; - new = (Edge*)MEM_callocN(sizeof(Edge),"Edge"); - new->col2 = ibuf->rect[i * ibuf->x]; /* left pixel */ - new->col1 = new->col2 - 1; - BLI_addhead(curlist, new); - new = (Edge*)MEM_callocN(sizeof(Edge),"Edge"); - new->position = ibuf->x - 1; - new->col1 = ibuf->rect[((i + 1) * ibuf->x) - 1]; /* right pixel */ - new->col2 = new->col1 - 1; - BLI_addtail(curlist, new); - } - _intel_scale(ibuf, listarray, 'h'); - anti_free_listarray(size, listarray); - } - } -} diff --git a/source/blender/imbuf/intern/bitplanes.c b/source/blender/imbuf/intern/bitplanes.c deleted file mode 100644 index 91fd2a0f563..00000000000 --- a/source/blender/imbuf/intern/bitplanes.c +++ /dev/null @@ -1,356 +0,0 @@ -/** - * bitplanes.c - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include "imbuf.h" -#include "BLI_blenlib.h" - -#include "imbuf_patch.h" - -#include "IMB_imbuf_types.h" -#include "IMB_imbuf.h" -#include "IMB_allocimbuf.h" -#include "IMB_bitplanes.h" - -unsigned int **imb_copyplanelist(struct ImBuf *ibuf) -{ - int nobp,i; - unsigned int **listn,**listo; - - nobp=ibuf->depth; - listn= malloc(nobp*sizeof(int *)); /* make copy of bitmap */ - if (listn==0) return (0); - - listo=ibuf->planes; - for (i=nobp;i>0;i--){ - *(listn++) = *(listo++); - } - listn -= nobp; - - return (listn); -} - -static void bptolscanl(unsigned int *buf, int size, unsigned int **list, int nobp, int offset) -{ - /* converts bitplanes to a buffer with ints - by 4 dividiable amount of bitplanes, - the width of bitplanes is rounded at ints */ - - list += nobp; - - for (;nobp>0;) - { - int todo,i; - register int bp1, bp2, bp3, bp4, data; - register unsigned int *point; - int loffset; - /*register unsigned int bp1, bp2, bp3, bp4;*/ - - bp1 = bp2 = bp3 = bp4 = todo = 0; - point = buf; - loffset = offset; - - if (nobp & 1){ - list -= 1; - nobp -= 1; - for(i=size;i>0;i--) - { - if (todo==0) - { - bp1 = BIG_LONG((list[0])[loffset]); - loffset++; - todo=32; - } - - data = *point; - data<<=1; - - if (bp1<0) data+=1; - bp1<<=1; - - /* data += (bp1 >> 31); - bp1 <<= 1; - */ - *(point++)=data; - todo--; - } - } else if (nobp & 2){ - list -= 2; - nobp -= 2; - for(i=size;i>0;i--) - { - if (todo==0) - { - bp1 = BIG_LONG((list[0])[loffset]); - bp2 = BIG_LONG((list[1])[loffset]); - loffset++; - todo=32; - } - - data = *point; - data<<=2; - - if (bp1<0) data+=1; - bp1<<=1; - if (bp2<0) data+=2; - bp2<<=1; - - /* data += (bp1 >> 31) + ((bp2 & 0x80000000) >> 30); - bp1 <<= 1; bp2 <<= 1; - */ - *(point++)=data; - todo--; - } - } else{ - list -= 4; - nobp -= 4; - for(i=size;i>0;i--) - { - if (todo==0) { - bp1 = BIG_LONG((list[0])[loffset]); - bp2 = BIG_LONG((list[1])[loffset]); - bp3 = BIG_LONG((list[2])[loffset]); - bp4 = BIG_LONG((list[3])[loffset]); - loffset++; - todo=32; - } - - data = *point; - data<<=4; - - if (bp1<0) data+=1; - bp1<<=1; - if (bp2<0) data+=2; - bp2<<=1; - if (bp3<0) data+=4; - bp3<<=1; - if (bp4<0) data+=8; - bp4<<=1; - - /* data += (bp1 >> 31) \ - + ((bp2 & 0x80000000) >> 30) \ - + ((bp3 & 0x80000000) >> 29) \ - + ((bp4 & 0x80000000) >> 28); - - bp1 <<= 1; bp2 <<= 1; - bp3 <<= 1; bp4 <<= 1; - */ - - *(point++)=data; - todo--; - } - } - } -} - - -void imb_bptolong(struct ImBuf *ibuf) -{ - int nobp,i,x; - unsigned int *rect,offset; - float black[4] = {0.0,0.0,0.0,1.0}; - float clear[4] = {0.0,0.0,0.0,0.0}; - - /* first clear all ints */ - - if (ibuf == 0) return; - if (ibuf->planes == 0) return; - if (ibuf->rect == 0) imb_addrectImBuf(ibuf); - - nobp=ibuf->depth; - if (nobp != 32){ - if (nobp == 24) IMB_rectfill(ibuf, black); /* set alpha */ - else IMB_rectfill(ibuf, clear); - } - - rect= ibuf->rect; - x= ibuf->x; - offset=0; - - for (i= ibuf->y; i>0; i--){ - bptolscanl(rect, x, ibuf->planes, nobp, offset); - rect += x; - offset += ibuf->skipx; - } -} - - -static void ltobpscanl(unsigned int *rect, int x, unsigned int **list, int nobp, int offset) -{ - /* converts a buffer with ints to bitplanes. Take care, buffer - will be destroyed !*/ - - if (nobp != 32) - { - int *rect2; - int todo,j; - - rect2 = (int*)rect; - - todo = 32-nobp; - for (j = x;j>0;j--){ - *(rect2++) <<= todo; - } - } - - list += nobp; - for (;nobp>0;){ - register int bp1=0, bp2=0, bp3=0, data; - register unsigned int *point; - int i,todo; - int bp4=0,loffset; - - point = rect; - todo=32; - loffset=offset; - - if (nobp & 1){ - list -= 1; - nobp -= 1; - - for(i=x;i>0;i--){ - data = *point; - - bp1 <<= 1; - if (data<0) bp1 += 1; - data <<= 1; - - *(point++) = data; - - todo--; - if (todo == 0){ - (list[0])[loffset] = bp1; - loffset++; - todo=32; - } - } - if (todo != 32) - { - bp1 <<= todo; - (list[0])[loffset] = bp1; - } - } else if (nobp & 2){ - list -= 2; - nobp -= 2; - for(i=x;i>0;i--){ - data = *point; - - bp2 <<= 1; - if (data<0) bp2 += 1; - data <<= 1; - bp1 <<= 1; - if (data<0) bp1 += 1; - data <<= 1; - - *(point++) = data; - - todo--; - if (todo == 0){ - (list[0])[loffset] = bp1; - (list[1])[loffset] = bp2; - loffset++; - todo=32; - } - } - if (todo != 32){ - bp1 <<= todo; - bp2 <<= todo; - (list[0])[loffset] = bp1; - (list[1])[loffset] = bp2; - } - } else{ - list -= 4; - nobp -= 4; - for(i=x;i>0;i--){ - data = *point; - - bp4 <<= 1; - if (data<0) bp4 += 1; - data <<= 1; - bp3 <<= 1; - if (data<0) bp3 += 1; - data <<= 1; - bp2 <<= 1; - if (data<0) bp2 += 1; - data <<= 1; - bp1 <<= 1; - if (data<0) bp1 += 1; - data <<= 1; - - *(point++) = data; - - todo--; - if (todo == 0){ - (list[0])[loffset] = bp1; - (list[1])[loffset] = bp2; - (list[2])[loffset] = bp3; - (list[3])[loffset] = bp4; - loffset++; - todo=32; - } - } - if (todo != 32){ - bp1 <<= todo; - bp2 <<= todo; - bp3 <<= todo; - bp4 <<= todo; - (list[0])[loffset] = bp1; - (list[1])[loffset] = bp2; - (list[2])[loffset] = bp3; - (list[3])[loffset] = bp4; - } - } - } -} - - -void imb_longtobp(struct ImBuf *ibuf) -{ - /* converts a buffer with ints to bitplanes. Take care, buffer - will be destroyed !*/ - - int nobp,i,x; - unsigned int *rect,offset,*buf; - ; - - nobp = ibuf->depth; - rect=ibuf->rect; - x=ibuf->x; - offset=0; - if ((buf=malloc(x*sizeof(int)))==0) return; - - for (i=ibuf->y;i>0;i--){ - memcpy(buf, rect, x*sizeof(int)); - rect +=x ; - ltobpscanl(buf, x, ibuf->planes, nobp, offset); - offset += ibuf->skipx; - } - free(buf); -} diff --git a/source/blender/imbuf/intern/bmp.c b/source/blender/imbuf/intern/bmp.c index 606cce645ee..bdcf60090c3 100644 --- a/source/blender/imbuf/intern/bmp.c +++ b/source/blender/imbuf/intern/bmp.c @@ -30,13 +30,11 @@ #include "BLI_blenlib.h" #include "imbuf.h" -#include "imbuf_patch.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" #include "IMB_allocimbuf.h" -#include "IMB_cmap.h" -#include "IMB_bmp.h" +#include "IMB_filetype.h" /* some code copied from article on microsoft.com, copied here for enhanced BMP support in the future @@ -98,7 +96,7 @@ static int checkbmp(unsigned char *mem) return(ret_val); } -int imb_is_a_bmp(void *buf) { +int imb_is_a_bmp(unsigned char *buf) { return checkbmp(buf); } @@ -195,7 +193,7 @@ static int putShortLSB(unsigned short us,FILE *ofile) { } /* Found write info at http://users.ece.gatech.edu/~slabaugh/personal/c/bitmapUnix.c */ -short imb_savebmp(struct ImBuf *ibuf, char *name, int flags) { +int imb_savebmp(struct ImBuf *ibuf, char *name, int flags) { BMPINFOHEADER infoheader; int bytesize, extrabytes, x, y, t, ptr; diff --git a/source/blender/imbuf/intern/cache.c b/source/blender/imbuf/intern/cache.c new file mode 100644 index 00000000000..d15826df2f0 --- /dev/null +++ b/source/blender/imbuf/intern/cache.c @@ -0,0 +1,442 @@ +/* + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "BLI_ghash.h" +#include "BLI_listbase.h" +#include "BLI_memarena.h" +#include "BLI_threads.h" + +#include "BKE_utildefines.h" + +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" +#include "IMB_filetype.h" + +#include "imbuf.h" + +/* We use a two level cache here. A per-thread cache with limited number of + tiles. This can be accessed without locking and so is hoped to lead to most + tile access being lock-free. The global cache is shared between all threads + and requires slow locking to access, and contains all tiles. + + The per-thread cache should be big enough that one might hope to not fall + back to the global cache every pixel, but not to big to keep too many tiles + locked and using memory. */ + +#define IB_THREAD_CACHE_SIZE 100 + +typedef struct ImGlobalTile { + struct ImGlobalTile *next, *prev; + + ImBuf *ibuf; + int tx, ty; + int refcount; + volatile int loading; +} ImGlobalTile; + +typedef struct ImThreadTile { + struct ImThreadTile *next, *prev; + + ImBuf *ibuf; + int tx, ty; + + ImGlobalTile *global; +} ImThreadTile; + +typedef struct ImThreadTileCache { + ListBase tiles; + ListBase unused; + GHash *tilehash; +} ImThreadTileCache; + +typedef struct ImGlobalTileCache { + ListBase tiles; + ListBase unused; + GHash *tilehash; + + MemArena *memarena; + uintptr_t totmem, maxmem; + + ImThreadTileCache thread_cache[BLENDER_MAX_THREADS+1]; + int totthread; + + ThreadMutex mutex; +} ImGlobalTileCache; + +static ImGlobalTileCache GLOBAL_CACHE; + +/***************************** Hash Functions ********************************/ + +static unsigned int imb_global_tile_hash(void *gtile_p) +{ + ImGlobalTile *gtile= gtile_p; + + return ((unsigned int)(intptr_t)gtile->ibuf)*769 + gtile->tx*53 + gtile->ty*97; +} + +static int imb_global_tile_cmp(void *a_p, void *b_p) +{ + ImGlobalTile *a= a_p; + ImGlobalTile *b= b_p; + + if(a->ibuf == b->ibuf && a->tx == b->tx && a->ty == b->ty) return 0; + else if(a->ibuf < b->ibuf || a->tx < b->tx || a->ty < b->ty) return -1; + else return 1; +} + +static unsigned int imb_thread_tile_hash(void *ttile_p) +{ + ImThreadTile *ttile= ttile_p; + + return ((unsigned int)(intptr_t)ttile->ibuf)*769 + ttile->tx*53 + ttile->ty*97; +} + +static int imb_thread_tile_cmp(void *a_p, void *b_p) +{ + ImThreadTile *a= a_p; + ImThreadTile *b= b_p; + + if(a->ibuf == b->ibuf && a->tx == b->tx && a->ty == b->ty) return 0; + else if(a->ibuf < b->ibuf || a->tx < b->tx || a->ty < b->ty) return -1; + else return 1; +} + +/******************************** Load/Unload ********************************/ + +static void imb_global_cache_tile_load(ImGlobalTile *gtile) +{ + ImBuf *ibuf= gtile->ibuf; + int toffs= ibuf->xtiles*gtile->ty + gtile->tx; + unsigned int *rect; + + rect = MEM_callocN(sizeof(unsigned int)*ibuf->tilex*ibuf->tiley, "imb_tile"); + imb_loadtile(ibuf, gtile->tx, gtile->ty, rect); + ibuf->tiles[toffs]= rect; +} + +static void imb_global_cache_tile_unload(ImGlobalTile *gtile) +{ + ImBuf *ibuf= gtile->ibuf; + int toffs= ibuf->xtiles*gtile->ty + gtile->tx; + + MEM_freeN(ibuf->tiles[toffs]); + ibuf->tiles[toffs]= NULL; + + GLOBAL_CACHE.totmem -= sizeof(unsigned int)*ibuf->tilex*ibuf->tiley; +} + +/* external free */ +void imb_tile_cache_tile_free(ImBuf *ibuf, int tx, int ty) +{ + ImGlobalTile *gtile, lookuptile; + + BLI_mutex_lock(&GLOBAL_CACHE.mutex); + + lookuptile.ibuf = ibuf; + lookuptile.tx = tx; + lookuptile.ty = ty; + gtile= BLI_ghash_lookup(GLOBAL_CACHE.tilehash, &lookuptile); + + if(gtile) { + /* in case another thread is loading this */ + while(gtile->loading) + ; + + BLI_ghash_remove(GLOBAL_CACHE.tilehash, gtile, NULL, NULL); + BLI_remlink(&GLOBAL_CACHE.tiles, gtile); + BLI_addtail(&GLOBAL_CACHE.unused, gtile); + } + + BLI_mutex_unlock(&GLOBAL_CACHE.mutex); +} + +/******************************* Init/Exit ***********************************/ + +static void imb_thread_cache_init(ImThreadTileCache *cache) +{ + ImThreadTile *ttile; + int a; + + memset(cache, 0, sizeof(ImThreadTileCache)); + + cache->tilehash= BLI_ghash_new(imb_thread_tile_hash, imb_thread_tile_cmp, "imb_thread_cache_init gh"); + + /* pre-allocate all thread local tiles in unused list */ + for(a=0; aunused, ttile); + } +} + +static void imb_thread_cache_exit(ImThreadTileCache *cache) +{ + BLI_ghash_free(cache->tilehash, NULL, NULL); +} + +void imb_tile_cache_init(void) +{ + memset(&GLOBAL_CACHE, 0, sizeof(ImGlobalTileCache)); + + BLI_mutex_init(&GLOBAL_CACHE.mutex); + + /* initialize for one thread, for places that access textures + outside of rendering (displace modifier, painting, ..) */ + IMB_tile_cache_params(0, 0); +} + +void imb_tile_cache_exit(void) +{ + ImGlobalTile *gtile; + int a; + + for(gtile=GLOBAL_CACHE.tiles.first; gtile; gtile=gtile->next) + imb_global_cache_tile_unload(gtile); + + for(a=0; arefcount--; + + /* find tile in global cache */ + lookuptile.ibuf = ibuf; + lookuptile.tx = tx; + lookuptile.ty = ty; + gtile= BLI_ghash_lookup(GLOBAL_CACHE.tilehash, &lookuptile); + + if(gtile) { + /* found tile. however it may be in the process of being loaded + by another thread, in that case we do stupid busy loop waiting + for the other thread to load the tile */ + gtile->refcount++; + + BLI_mutex_unlock(&GLOBAL_CACHE.mutex); + + while(gtile->loading) + ; + } + else { + /* not found, let's load it from disk */ + + /* first check if we hit the memory limit */ + if(GLOBAL_CACHE.maxmem && GLOBAL_CACHE.totmem > GLOBAL_CACHE.maxmem) { + /* find an existing tile to unload */ + for(gtile=GLOBAL_CACHE.tiles.last; gtile; gtile=gtile->prev) + if(gtile->refcount == 0 && gtile->loading == 0) + break; + } + + if(gtile) { + /* found a tile to unload */ + imb_global_cache_tile_unload(gtile); + BLI_ghash_remove(GLOBAL_CACHE.tilehash, gtile, NULL, NULL); + BLI_remlink(&GLOBAL_CACHE.tiles, gtile); + } + else { + /* allocate a new tile or reuse unused */ + if(GLOBAL_CACHE.unused.first) { + gtile= GLOBAL_CACHE.unused.first; + BLI_remlink(&GLOBAL_CACHE.unused, gtile); + } + else + gtile= BLI_memarena_alloc(GLOBAL_CACHE.memarena, sizeof(ImGlobalTile)); + } + + /* setup new tile */ + gtile->ibuf= ibuf; + gtile->tx= tx; + gtile->ty= ty; + gtile->refcount= 1; + gtile->loading= 1; + + BLI_ghash_insert(GLOBAL_CACHE.tilehash, gtile, gtile); + BLI_addhead(&GLOBAL_CACHE.tiles, gtile); + + /* mark as being loaded and unlock to allow other threads to load too */ + GLOBAL_CACHE.totmem += sizeof(unsigned int)*ibuf->tilex*ibuf->tiley; + + BLI_mutex_unlock(&GLOBAL_CACHE.mutex); + + /* load from disk */ + imb_global_cache_tile_load(gtile); + + /* mark as done loading */ + gtile->loading= 0; + } + + return gtile; +} + +/***************************** Per-Thread Cache ******************************/ + +static unsigned int *imb_thread_cache_get_tile(ImThreadTileCache *cache, ImBuf *ibuf, int tx, int ty) +{ + ImThreadTile *ttile, lookuptile; + ImGlobalTile *gtile, *replacetile; + int toffs= ibuf->xtiles*ty + tx; + + /* test if it is already in our thread local cache */ + if((ttile=cache->tiles.first)) { + /* check last used tile before going to hash */ + if(ttile->ibuf == ibuf && ttile->tx == tx && ttile->ty == ty) + return ibuf->tiles[toffs]; + + /* find tile in hash */ + lookuptile.ibuf = ibuf; + lookuptile.tx = tx; + lookuptile.ty = ty; + + if((ttile=BLI_ghash_lookup(cache->tilehash, &lookuptile))) { + BLI_remlink(&cache->tiles, ttile); + BLI_addhead(&cache->tiles, ttile); + + return ibuf->tiles[toffs]; + } + } + + /* not found, have to do slow lookup in global cache */ + if(cache->unused.first == NULL) { + ttile= cache->tiles.last; + replacetile= ttile->global; + BLI_remlink(&cache->tiles, ttile); + BLI_ghash_remove(cache->tilehash, ttile, NULL, NULL); + } + else { + ttile= cache->unused.first; + replacetile= NULL; + BLI_remlink(&cache->unused, ttile); + } + + BLI_addhead(&cache->tiles, ttile); + BLI_ghash_insert(cache->tilehash, ttile, ttile); + + gtile= imb_global_cache_get_tile(ibuf, tx, ty, replacetile); + + ttile->ibuf= gtile->ibuf; + ttile->tx= gtile->tx; + ttile->ty= gtile->ty; + ttile->global= gtile; + + return ibuf->tiles[toffs]; +} + +unsigned int *IMB_gettile(ImBuf *ibuf, int tx, int ty, int thread) +{ + return imb_thread_cache_get_tile(&GLOBAL_CACHE.thread_cache[thread+1], ibuf, tx, ty); +} + +void IMB_tiles_to_rect(ImBuf *ibuf) +{ + ImBuf *mipbuf; + ImGlobalTile *gtile; + unsigned int *to, *from; + int a, tx, ty, y, w, h; + + for(a=0; amiptot; a++) { + mipbuf= IMB_getmipmap(ibuf, a); + + /* don't call imb_addrectImBuf, it frees all mipmaps */ + if(!mipbuf->rect) { + if((mipbuf->rect = MEM_mapallocN(ibuf->x*ibuf->y*sizeof(unsigned int), "imb_addrectImBuf"))) { + mipbuf->mall |= IB_rect; + mipbuf->flags |= IB_rect; + } + else + break; + } + + for(ty=0; tyytiles; ty++) { + for(tx=0; txxtiles; tx++) { + /* acquire tile through cache, this assumes cache is initialized, + which it is always now but it's a weak assumption ... */ + gtile= imb_global_cache_get_tile(mipbuf, tx, ty, NULL); + + /* setup pointers */ + from= mipbuf->tiles[mipbuf->xtiles*ty + tx]; + to= mipbuf->rect + mipbuf->x*ty*mipbuf->tiley + tx*mipbuf->tilex; + + /* exception in tile width/height for tiles at end of image */ + w= (tx == mipbuf->xtiles-1)? mipbuf->x - tx*mipbuf->tilex: mipbuf->tilex; + h= (ty == mipbuf->ytiles-1)? mipbuf->y - ty*mipbuf->tiley: mipbuf->tiley; + + for(y=0; ytilex; + to += mipbuf->x; + } + + /* decrease refcount for tile again */ + BLI_mutex_lock(&GLOBAL_CACHE.mutex); + gtile->refcount--; + BLI_mutex_unlock(&GLOBAL_CACHE.mutex); + } + } + } +} + diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.c index 2acd4dfda75..aa1b8ca3447 100644 --- a/source/blender/imbuf/intern/cineon/cineon_dpx.c +++ b/source/blender/imbuf/intern/cineon/cineon_dpx.c @@ -186,7 +186,7 @@ short imb_savecineon(struct ImBuf *buf, char *myfile, int flags) } -int imb_is_cineon(void *buf) +int imb_is_cineon(unsigned char *buf) { return cineonIsMemFileCineon(buf); } @@ -203,7 +203,7 @@ short imb_save_dpx(struct ImBuf *buf, char *myfile, int flags) return imb_save_dpx_cineon(buf, myfile, 0, flags); } -int imb_is_dpx(void *buf) +int imb_is_dpx(unsigned char *buf) { return dpxIsMemFileCineon(buf); } diff --git a/source/blender/imbuf/intern/cmap.c b/source/blender/imbuf/intern/cmap.c deleted file mode 100644 index 49edc93b507..00000000000 --- a/source/blender/imbuf/intern/cmap.c +++ /dev/null @@ -1,580 +0,0 @@ -/** - * cmap.c - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include -#include "BLI_blenlib.h" - -#include "imbuf.h" -#include "imbuf_patch.h" -#include "IMB_imbuf_types.h" -#include "IMB_imbuf.h" - -#include "IMB_cmap.h" - -static short *lastcube = 0; -static uchar *lastcoltab = 0; -static short lastmaxcol; -static short lastmincol; -static short lastcbits; -short alpha_col0 = FALSE; - -extern void IMB_free_cache_limiter(); - -/* - * there still is a bug here. If you want to convert an image to a 1 bit colormap you get - * a black image. All conversion to less than 4 bits is too dark anyway. - */ - -void IMB_freeImBufdata(void) -{ - if (lastcube) free(lastcube); - lastcube= 0; - if (lastcoltab) free(lastcoltab); - lastcoltab= 0; - IMB_free_cache_limiter(); -} - - -int IMB_alpha_to_col0(int value) -{ - int old; - - old = alpha_col0; - alpha_col0 = value; - return (old); -} - - -void imb_losecmapbits(struct ImBuf *ibuf, unsigned int *coltab) -{ - int i,bits; - unsigned int col, and1, and2, *rect; - - if (ibuf == 0) return; - if (ibuf->rect == 0) return; - if (ibuf->cbits == 0) return; - if (ibuf->cbits >= 8) return; - -/* - bij cbits = 5: - and1 = 11100000; - bij cbits = 6: - and1 = 11000000; -*/ - - bits = ibuf->cbits; - and1 = ((1 << (8-bits)) - 1) & 0xff; - and1 |= (and1 << 24) + (and1 << 16) + (and1 << 8); - and2 = ~and1; - and1 <<= bits; - - rect = ibuf->rect; - for (i = ibuf->x * ibuf->y ; i > 0; i--) { - col = rect[0]; - *rect++ = col - ((col & and1) >> bits); - } - - if (coltab){ - for (i = 0 ; i < ibuf->maxcol ; i++) { - col = coltab[i]; - coltab[i] = (col - ((col & and1) >> bits)) & and2; - } - } -} - - -static void addcmapbits(struct ImBuf *ibuf) -{ - int i,bits; - int div,mul; - uchar * cmap; - - if (ibuf == 0) return; - if (ibuf->cmap == 0) return; - if (ibuf->cbits == 0) return; - if (ibuf->cbits >= 8) return; - - bits = ibuf->cbits; - - /* bits = 4 -> div = 0xf0 - * bits = 5 -> div = 0xf8 - */ - - div = ((1 << bits) - 1) << (8 - bits); - mul = 0xffff / div; - - if (ibuf->cmap){ - cmap = (uchar *) ibuf->cmap; - for (i = 0 ; i < ibuf->maxcol ; i++){ - cmap[1] = (mul * cmap[1]) >> 8; - cmap[2] = (mul * cmap[2]) >> 8; - cmap[3] = (mul * cmap[3]) >> 8; - cmap += 4; - } - } -} - - -static short addplanetocube(short *cube, short *plane, int minx, int miny, int sizep, int addcx, int addcy, int sizec, int col) -{ - short done = FALSE; - int x, numx, numy, skipc, skipp, temp; - - /* clip first */ - - numx = numy = sizep; - - temp = minx + sizep - 1; - if (temp > sizec) numx -= temp - sizec; - - temp = miny + sizep - 1; - if (temp > sizec) numy -= temp - sizec; - - if (minx < 0){ - plane -= minx; - cube -= minx * addcx; - numx += minx; - } - - if (miny < 0){ - plane -= miny * sizep; - cube -= miny * addcy; - numy += miny; - } - - skipc = addcy - (numx * addcx); - skipp = sizep - numx; - - for (; numy > 0 ; numy--){ - for (x = numx ; x > 0; x--) { - - if (plane[0] < cube[1]) { - - cube[0] = col; - cube[1] = plane[0]; - done = TRUE; - } - plane ++; - cube += addcx; - } - plane += skipp; - cube += skipc; - } - - return (done); -} - - - -short *imb_coldeltatab(unsigned char *coltab, short mincol, short maxcol, short cbits) -{ - short max, *quadr, *_quadr, *_cube, *cube, *_plane, done, nocol; - unsigned int addcb, addcg, addcr, sizep; - uchar *_colp, *colp, *col; - int i, j, k, addcube; - int r, g, b; - - max = (1 << cbits) - 1; - nocol = maxcol - mincol; - coltab += 4 * mincol; - - /* reduce colors to the right amount of bits */ - - { - unsigned int * lctab, and; - - lctab = (unsigned int *) coltab; - and = max << (8 - cbits); - and = and + (and << 8) + (and << 16) + (and << 24); - for (i=nocol-1 ; i >= 0 ; i--) lctab[i] = (lctab[i] & and) >> (8 - cbits); - } - - /* is this data the same as previous ? */ - - if (lastcube){ - if (mincol == lastmincol && maxcol == lastmaxcol && cbits == lastcbits){ - if (lastcoltab){ - if (memcmp(lastcoltab, coltab, 4 * nocol) == 0) return(lastcube); - } - } - } - if (lastcube) free(lastcube); - if (lastcoltab) free(lastcoltab); - - lastcube = 0; - lastcoltab = 0; - _cube = malloc(2 * (1 << (3 * cbits)) * sizeof(short)); - _plane = malloc((2 * max + 1) * (2 * max + 1) * sizeof(short)); - _quadr = malloc((2 * max + 1) * sizeof(short)); - _colp = malloc(6 * nocol); - - if (_cube == 0 || _plane == 0 || _quadr == 0 || _colp == 0){ - if (_cube) free(_cube); - if (_plane) free(_plane); - if (_quadr) free(_quadr); - if (_colp) free(_colp); - return(0); - } - - lastcoltab = malloc(4 * nocol); - if (lastcoltab) memcpy(lastcoltab, coltab, 4 * nocol); - lastcube = _cube; - lastmincol = mincol; - lastmaxcol = maxcol; - lastcbits = cbits; - - /* cube initialise */ - - cube = _cube; - for (i = (1 << (3 * cbits)); i > 0 ; i--){ - cube[0] = 0; - cube[1] = 32767; - cube += 2; - } - - /* mak error look up table */ - - { - unsigned int delta; - - quadr = _quadr + max + 1; - quadr[0] = 0; - delta = 3; - for (i = 1 ; i <= max ; i++){ - quadr[i] = quadr[-i] = delta; - delta += i + 3; - } - } - - /* colorplane initialise */ - - for (i = 6 * nocol - 1; i >= 0; i--) _colp[i] = 1; - - addcr = 2; - addcg = (addcr << cbits); - addcb = (addcg << cbits); - - /* fill in first round */ - - { - unsigned int ofs; - - col = coltab; - cube = _cube; - - for (i = 0 ; i < nocol ; i++){ - ofs = (col[3] * addcr) + (col[2] * addcg) + (col[1] * addcb); - /* color been filled in -> then skip */ - if (cube[ofs + 1]) cube[ofs] = i + mincol; - cube[ofs + 1] = 0; - col += 4; - } - } - - for (i = 1; i <= max ; i++){ - colp = _colp; - col = coltab; - done = FALSE; - sizep = 2*i +1; - - /* plane initialise */ - { - unsigned int delta; - short *plane; - - plane = _plane; - for (j = -i ; j <= i; j++){ - delta = quadr[i] + quadr[j]; - for (k = -i; k <= i; k++){ - *plane++ = delta + quadr[k]; - } - } - } - - for (j = mincol; j < maxcol; j++){ - b = col[1] - i; - g = col[2] - i; - r = col[3] - i; - - addcube= (addcr * r) + (addcg * g) + (addcb * b); - /* PRINT4(d, d, d, d, addcube, r, g, b); */ - /* if(addcube >= 2 * (1 << (3 * cbits))) { */ - /* printf("maxerror: %d %d\n", addcube, 2 * (1 << (3 * cbits))); */ - /* add_cube= 2 * (1 << (3 * cbits)) -1; */ - /* } */ - cube = _cube + addcube; - - if (colp[0]){ - if (b < 0) colp[0] = 0; - else done |= colp[0] = addplanetocube(cube, _plane, r, g, sizep, addcr, addcg, max, j); - } - if (colp[1]){ - if (g < 0) colp[1] = 0; - else done |= colp[1] = addplanetocube(cube, _plane, r, b, sizep, addcr, addcb, max, j); - } - if (colp[2]){ - if (r < 0) colp[2] = 0; - else done |= colp[2] = addplanetocube(cube, _plane, b, g, sizep, addcb, addcg, max, j); - } - if (colp[3]){ - if ((b + sizep - 1) > max) colp[3] = 0; - else done |= colp[3] = addplanetocube(cube + (sizep -1) * addcb, _plane, r, g, sizep, addcr, - addcg, max, j); - } - if (colp[4]){ - if ((g + sizep - 1) > max) colp[4] = 0; - else done |= colp[4] = addplanetocube(cube + (sizep -1) * addcg, _plane, r, b, sizep, addcr, - addcb, max, j); - } - if (colp[5]){ - if ((r + sizep - 1) > max) colp[5] = 0; - else done |= colp[5] = addplanetocube(cube + (sizep -1) * addcr, _plane, b, g, sizep, addcb, - addcg, max, j); - } - - colp += 6; - col += 4; - } - if (done == 0) break; - } - - free(_quadr); - free(_plane); - free(_colp); - return(_cube); -} - - -static void convcmap(struct ImBuf* ibuf, short *deltab, short cbits) -{ - unsigned int *rect; - short x,y; - unsigned int col; - unsigned int bbits,gbits,rbits; - unsigned int bmask,gmask,rmask; - - bbits = 24 - 3 * cbits - 1; - gbits = 16 - 2 * cbits - 1; - rbits = 8 - cbits - 1; - - rmask = ((1 << cbits) - 1) << (8 - cbits); - gmask = rmask << 8; - bmask = gmask << 8; - - rect =(unsigned int *)ibuf->rect; - - for(y=ibuf->y;y>0;y--){ - for(x=ibuf->x;x>0;x--){ - col = *rect; - col = ((col & bmask) >> bbits) + ((col & gmask) >> gbits) + ((col & rmask) >> rbits); - *rect++ = deltab[col]; - } - } -} - -short IMB_converttocmap(struct ImBuf *ibuf) -{ - unsigned int *coltab; - short *deltab=0, cbits; - int i; - int mincol, mask = 0; - struct ImBuf * abuf = 0; - unsigned int * rect, * arect; - - cbits = 5; - if (ibuf->cmap == 0) return(0); - - if ((ibuf->cbits > 0) && (ibuf->cbits <8)) cbits = ibuf->cbits; - - coltab = calloc(ibuf->maxcol, sizeof(unsigned int)); - if (coltab == 0) return(0); - memcpy(coltab, ibuf->cmap, ibuf->maxcol * sizeof(unsigned int)); - - mincol = ibuf->mincol; - if (alpha_col0) { - if (mincol == 0) mincol = 1; - abuf = IMB_dupImBuf(ibuf); - } - - imb_losecmapbits(ibuf, coltab); - deltab = imb_coldeltatab((uchar *) coltab, mincol ,ibuf->maxcol, cbits); - - if (deltab == 0) { - free(coltab); - if (abuf) IMB_freeImBuf(abuf); - return(0); - } - - - IMB_dit0(ibuf,1,cbits); - IMB_dit0(ibuf,2,cbits); - IMB_dit0(ibuf,3,cbits); - convcmap(ibuf, deltab, cbits); - - if (abuf) { - /* convert alpha to color 0 */ - rect = ibuf->rect; - arect = abuf->rect; - - if (alpha_col0 == 1) mask = 0xff000000; /* alpha == 0 -> 0 */ - if (alpha_col0 == 2) mask = 0x80000000; /* alpha < 128 -> 0 */ - - for (i = ibuf->x * ibuf->y; i > 0; i--) { - if ((*arect++ & mask) == 0) rect[0] = 0; - rect++; - } - - IMB_freeImBuf(abuf); - } - - free(coltab); - - return (TRUE); -} - - -void imb_makecolarray(struct ImBuf *ibuf, unsigned char *mem, short nocols) -{ - short i,bits = 0; - uchar *cmap; - - /* what's the theory behind this? */ - - nocols = ibuf->maxcol; - - if (ibuf->cmap){ - cmap = (uchar *) ibuf->cmap; - for (i = 0; i < nocols; i++){ - cmap[3] = mem[0]; - cmap[2] = mem[1]; - cmap[1] = mem[2]; - cmap[0] = 0; - - bits |= mem[0] | mem[1] | mem[2]; - mem += 3; - cmap += 4; - } - - /* patch voor AdPro II */ - if (IS_ham(ibuf)){ - i = ibuf->depth - 2; - bits = ((1 << i) - 1) << (8 - i); - for (i=0 ; icmap[i] &= (bits << 24) + (bits << 16) + (bits << 8) + bits; - } - - if ((bits & 0x1f) == 0){ - ibuf->cbits = 3; - } else if ((bits & 0x0f) == 0){ - ibuf->cbits = 4; - } else if ((bits & 0x07) == 0){ - ibuf->cbits = 5; - } else if ((bits & 0x03) == 0){ - ibuf->cbits = 6; - } else ibuf->cbits = 8; - - addcmapbits(ibuf); - - if (IS_hbrite(ibuf)){ - for (i=31;i>=0;i--){ - ibuf->cmap[i+32] = (ibuf->cmap[i] & 0xfefefefe) >> 1; - } - } - - if (IS_amiga(ibuf)){ - cmap = (uchar * ) (ibuf->cmap + 1); - for (i = 1; i < nocols; i++){ - cmap[0] = 0xff; - cmap += 4; - } - } - } -} - -/* temporal... rects now are rgba, cmaps are abgr */ -#define SWITCH_INT(a) {char s_i, *p_i; p_i= (char *)&(a); s_i= p_i[0]; p_i[0]= p_i[3]; p_i[3]= s_i; s_i= p_i[1]; p_i[1]= p_i[2]; p_i[2]= s_i; } - -void IMB_applycmap(struct ImBuf *ibuf) -{ - unsigned int *rect, *cmap; - int x, y, i, col, code; - int *mask = 0; - - if (ibuf == 0) return; - if (ibuf->rect == 0 || ibuf->cmap == 0) return; - - rect = ibuf->rect; - cmap = ibuf->cmap; - - if (IS_ham(ibuf)){ - - /* generate mask of max (8 + 2) bits */ - mask = malloc(1024 * 2 * sizeof(int)); - - x = 1 << (ibuf->depth - 2); - y = 65535 / (x - 1); - - for (i = 0; i < x; i++){ - mask[i] = 0; - mask[i + x] = 0x00ffff; - mask[i + x + x] = 0xffff00; - mask[i + x + x + x] = 0xff00ff; - - col = (y * i) >> 8; - - mask[i + 1024] = 0xff000000 | ibuf->cmap[i]; - mask[i + x + 1024] = 0xff000000 | col << 16; - mask[i + x + x + 1024] = 0xff000000 | col; - mask[i + x + x + x + 1024] = 0xff000000 | col << 8; - } - - /* only color 0 transparant */ - mask[0+1024] =ibuf->cmap[0]; - - for (y = ibuf->y ; y>0 ; y--){ - col = cmap[0]; - for (x=ibuf->x ; x>0 ; x--){ - code = *rect; - *rect++ = col = (col & mask[code]) | mask[code + 1024]; - } - } - free(mask); - } else { - - for(i = ibuf->x * ibuf->y; i>0; i--){ - col = *rect; - if (col >= 0 && col < ibuf->maxcol) *rect = cmap[col]; - rect++; - - /* *(rect++) = cmap[*rect]; */ - } - } -} - diff --git a/source/blender/imbuf/intern/cspace.c b/source/blender/imbuf/intern/cspace.c deleted file mode 100644 index 46017fec5ec..00000000000 --- a/source/blender/imbuf/intern/cspace.c +++ /dev/null @@ -1,176 +0,0 @@ -/** - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include "BLI_blenlib.h" - -#include "imbuf.h" -#include "imbuf_patch.h" -#include "IMB_imbuf_types.h" - -void IMB_cspace(struct ImBuf *ibuf, float mat[][4]); - -/************************************************************************/ -/* COLORSPACE */ -/************************************************************************/ - -static void fillmattab(double val, unsigned short *mattab) -{ - int tot,ival; - int i; - - val *= (1 << 22); - ival = val; - tot = 32767; /* een half */ - - for(i = 256; i > 0; i--){ - *(mattab) = (tot >> 16); - mattab += 3; - tot += ival; - } -} - - -static void cspfill(short *buf, unsigned short *fill, int x) -{ - unsigned short r,g,b; - - b = fill[0]; - g = fill[1]; - r = fill[2]; - for (;x>0;x--){ - buf[0] = b; - buf[1] = g; - buf[2] = r; - buf += 3; - } -} - - -static void cspadd(short *buf, unsigned short *cont, unsigned char *rect, int x) -{ - short i; - for (;x>0;x--){ - i = *(rect); - rect += 4; - buf[0] += cont[i*3]; - buf[1] += cont[i*3 + 1]; - buf[2] += cont[i*3 + 2]; - buf += 3; - } -} - - -static void cspret(short *buf, unsigned char *rect, int x) -{ - int r,g,b; - - for(; x > 0; x--){ - b = buf[0]; - g = buf[1]; - r = buf[2]; - - if (b & 0x4000){ - if (b<0) rect[2]=0; - else rect[2]=255; - } else rect[2] = b >> 6; - - if (g & 0x4000){ - if (g<0) rect[1]=0; - else rect[1]=255; - } else rect[1] = g >> 6; - - if (r & 0x4000){ - if (r<0) rect[0]=0; - else rect[0]=255; - } else rect[0] = r >> 6; - - buf += 3; - rect += 4; - } -} - - -static void rotcspace(struct ImBuf *ibuf, unsigned short *cont_1, unsigned short *cont_2, unsigned short *cont_3, unsigned short *add) -{ - short x,y,*buf; - uchar *rect; - - x=ibuf->x; - rect= (uchar *)ibuf->rect; - - buf=(short *)malloc(x*3*sizeof(short)); - if (buf){ - for(y=ibuf->y;y>0;y--){ - cspfill(buf,add,x); - cspadd(buf,cont_1,rect+0,x); - cspadd(buf,cont_2,rect+1,x); - cspadd(buf,cont_3,rect+2,x); - cspret(buf,rect,x); - rect += x<<2; - } - free(buf); - } -} - - -void IMB_cspace(struct ImBuf *ibuf, float mat[][4]) -{ - unsigned short *cont_1,*cont_2,*cont_3,add[3]; - - cont_1=(unsigned short *)malloc(256*3*sizeof(short)); - cont_2=(unsigned short *)malloc(256*3*sizeof(short)); - cont_3=(unsigned short *)malloc(256*3*sizeof(short)); - - if (cont_1 && cont_2 && cont_3){ - - fillmattab(mat[0][0],cont_1); - fillmattab(mat[0][1],cont_1+1); - fillmattab(mat[0][2],cont_1+2); - - fillmattab(mat[1][0],cont_2); - fillmattab(mat[1][1],cont_2+1); - fillmattab(mat[1][2],cont_2+2); - - fillmattab(mat[2][0],cont_3); - fillmattab(mat[2][1],cont_3+1); - fillmattab(mat[2][2],cont_3+2); - - add[0] = (mat[3][0] * 64.0) + .5; - add[1] = (mat[3][1] * 64.0) + .5; - add[2] = (mat[3][2] * 64.0) + .5; - - rotcspace(ibuf, cont_1, cont_2, cont_3, add); - } - - if (cont_1) free(cont_1); - if (cont_2) free(cont_2); - if (cont_3) free(cont_3); -} - diff --git a/source/blender/imbuf/intern/data.c b/source/blender/imbuf/intern/data.c deleted file mode 100644 index 3b1f3035d62..00000000000 --- a/source/blender/imbuf/intern/data.c +++ /dev/null @@ -1,142 +0,0 @@ -/** - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * data.c - * - * $Id$ - */ - -#include "imbuf.h" -#include "matrix.h" - -/* -static short quadbase[31] = { - 150,133,117,102, - 88,75,63,52, - 42,33,25,18, - 12,7,3,0, - 3,7,12,18, - 25,33,42,52, - 63,75,88,102, - 117,133,150, -}; - -short *quadr = quadbase+15; -*/ -/* -main() -{ - ushort _quadr[511], *quadr; - int i, delta; - - quadr = _quadr + 255; - - delta = 0; - for (i = 0 ; i <= 255 ; i++){ - quadr[i] = quadr[-i] = delta; - delta += i + 3; - } - - delta = 0; - for (i = 0; i < 511; i++){ - printf("%6d, ", _quadr[i]); - delta++; - if (delta == 8){ - delta = 0; - printf("\n"); - } - } -} -*/ - -static unsigned short quadbase[511] = { - 33150, 32893, 32637, 32382, 32128, 31875, 31623, 31372, - 31122, 30873, 30625, 30378, 30132, 29887, 29643, 29400, - 29158, 28917, 28677, 28438, 28200, 27963, 27727, 27492, - 27258, 27025, 26793, 26562, 26332, 26103, 25875, 25648, - 25422, 25197, 24973, 24750, 24528, 24307, 24087, 23868, - 23650, 23433, 23217, 23002, 22788, 22575, 22363, 22152, - 21942, 21733, 21525, 21318, 21112, 20907, 20703, 20500, - 20298, 20097, 19897, 19698, 19500, 19303, 19107, 18912, - 18718, 18525, 18333, 18142, 17952, 17763, 17575, 17388, - 17202, 17017, 16833, 16650, 16468, 16287, 16107, 15928, - 15750, 15573, 15397, 15222, 15048, 14875, 14703, 14532, - 14362, 14193, 14025, 13858, 13692, 13527, 13363, 13200, - 13038, 12877, 12717, 12558, 12400, 12243, 12087, 11932, - 11778, 11625, 11473, 11322, 11172, 11023, 10875, 10728, - 10582, 10437, 10293, 10150, 10008, 9867, 9727, 9588, - 9450, 9313, 9177, 9042, 8908, 8775, 8643, 8512, - 8382, 8253, 8125, 7998, 7872, 7747, 7623, 7500, - 7378, 7257, 7137, 7018, 6900, 6783, 6667, 6552, - 6438, 6325, 6213, 6102, 5992, 5883, 5775, 5668, - 5562, 5457, 5353, 5250, 5148, 5047, 4947, 4848, - 4750, 4653, 4557, 4462, 4368, 4275, 4183, 4092, - 4002, 3913, 3825, 3738, 3652, 3567, 3483, 3400, - 3318, 3237, 3157, 3078, 3000, 2923, 2847, 2772, - 2698, 2625, 2553, 2482, 2412, 2343, 2275, 2208, - 2142, 2077, 2013, 1950, 1888, 1827, 1767, 1708, - 1650, 1593, 1537, 1482, 1428, 1375, 1323, 1272, - 1222, 1173, 1125, 1078, 1032, 987, 943, 900, - 858, 817, 777, 738, 700, 663, 627, 592, - 558, 525, 493, 462, 432, 403, 375, 348, - 322, 297, 273, 250, 228, 207, 187, 168, - 150, 133, 117, 102, 88, 75, 63, 52, - 42, 33, 25, 18, 12, 7, 3, 0, - 3, 7, 12, 18, 25, 33, 42, 52, - 63, 75, 88, 102, 117, 133, 150, 168, - 187, 207, 228, 250, 273, 297, 322, 348, - 375, 403, 432, 462, 493, 525, 558, 592, - 627, 663, 700, 738, 777, 817, 858, 900, - 943, 987, 1032, 1078, 1125, 1173, 1222, 1272, - 1323, 1375, 1428, 1482, 1537, 1593, 1650, 1708, - 1767, 1827, 1888, 1950, 2013, 2077, 2142, 2208, - 2275, 2343, 2412, 2482, 2553, 2625, 2698, 2772, - 2847, 2923, 3000, 3078, 3157, 3237, 3318, 3400, - 3483, 3567, 3652, 3738, 3825, 3913, 4002, 4092, - 4183, 4275, 4368, 4462, 4557, 4653, 4750, 4848, - 4947, 5047, 5148, 5250, 5353, 5457, 5562, 5668, - 5775, 5883, 5992, 6102, 6213, 6325, 6438, 6552, - 6667, 6783, 6900, 7018, 7137, 7257, 7378, 7500, - 7623, 7747, 7872, 7998, 8125, 8253, 8382, 8512, - 8643, 8775, 8908, 9042, 9177, 9313, 9450, 9588, - 9727, 9867, 10008, 10150, 10293, 10437, 10582, 10728, - 10875, 11023, 11172, 11322, 11473, 11625, 11778, 11932, - 12087, 12243, 12400, 12558, 12717, 12877, 13038, 13200, - 13363, 13527, 13692, 13858, 14025, 14193, 14362, 14532, - 14703, 14875, 15048, 15222, 15397, 15573, 15750, 15928, - 16107, 16287, 16468, 16650, 16833, 17017, 17202, 17388, - 17575, 17763, 17952, 18142, 18333, 18525, 18718, 18912, - 19107, 19303, 19500, 19698, 19897, 20097, 20298, 20500, - 20703, 20907, 21112, 21318, 21525, 21733, 21942, 22152, - 22363, 22575, 22788, 23002, 23217, 23433, 23650, 23868, - 24087, 24307, 24528, 24750, 24973, 25197, 25422, 25648, - 25875, 26103, 26332, 26562, 26793, 27025, 27258, 27492, - 27727, 27963, 28200, 28438, 28677, 28917, 29158, 29400, - 29643, 29887, 30132, 30378, 30625, 30873, 31122, 31372, - 31623, 31875, 32128, 32382, 32637, 32893, 33150, -}; - -unsigned short *quadr = quadbase + 255; diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp index 56880c57f1b..9a106253397 100644 --- a/source/blender/imbuf/intern/dds/dds_api.cpp +++ b/source/blender/imbuf/intern/dds/dds_api.cpp @@ -31,13 +31,12 @@ extern "C" { #include "imbuf.h" -#include "imbuf_patch.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" #include "IMB_allocimbuf.h" -short imb_save_dds(struct ImBuf * ibuf, char *name, int flags) +int imb_save_dds(struct ImBuf * ibuf, char *name, int flags) { return(0); /* todo: finish this function */ @@ -78,6 +77,9 @@ struct ImBuf *imb_load_dds(unsigned char *mem, int size, int flags) Color32 pixel; Color32 *pixels = 0; + if(!imb_is_a_dds(mem)) + return (0); + /* check if DDS is valid and supported */ if (!dds.isValid()) { /* no need to print error here, just testing if it is a DDS */ diff --git a/source/blender/imbuf/intern/dds/dds_api.h b/source/blender/imbuf/intern/dds/dds_api.h index b8a61c6fc1a..6d9fa0839dd 100644 --- a/source/blender/imbuf/intern/dds/dds_api.h +++ b/source/blender/imbuf/intern/dds/dds_api.h @@ -29,7 +29,7 @@ extern "C" { #endif -short imb_save_dds(struct ImBuf *ibuf, char *name, int flags); +int imb_save_dds(struct ImBuf *ibuf, char *name, int flags); int imb_is_a_dds(unsigned char *mem); /* use only first 32 bytes of mem */ struct ImBuf *imb_load_dds(unsigned char *mem, int size, int flags); diff --git a/source/blender/imbuf/intern/dither.c b/source/blender/imbuf/intern/dither.c deleted file mode 100644 index ccd7982ea07..00000000000 --- a/source/blender/imbuf/intern/dither.c +++ /dev/null @@ -1,130 +0,0 @@ -/** - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * dither.c - * - * $Id$ - */ - -#include "BLI_blenlib.h" - -#include "imbuf.h" -#include "imbuf_patch.h" -#include "IMB_imbuf_types.h" -#include "IMB_imbuf.h" - -void IMB_dit0(struct ImBuf * ibuf, short ofs, short bits) -{ - int x, y, and, add, pix; - uchar *rect; - - rect= (uchar *)ibuf->rect; - rect +=ofs; - - bits = 8 - bits; - and = ~((1 << bits)-1); - add = 1 << (bits - 1); - - for (y = ibuf->y; y > 0; y--){ - for (x = ibuf->x; x > 0; x--) { - pix = *rect + add; - if (pix > 255) pix = 255; - *rect = pix & and; - rect += 4; - } - } -} - -void IMB_dit2(struct ImBuf * ibuf, short ofs, short bits) -{ - short x,y,pix,and,add1,add2; - uchar *rect; - uchar dit[4]; - - rect= (uchar *)ibuf->rect; - rect +=ofs; - - bits = 8 - bits; - and = ~((1<>= -bits; - dit[1] >>= -bits; - dit[2] >>= -bits; - dit[3] >>= -bits; - } else{ - dit[0] <<= bits; - dit[1] <<= bits; - dit[2] <<= bits; - dit[3] <<= bits; - } - - for(y=ibuf->y;y>0;y--){ - if(y & 1){ - add1=dit[0]; - add2=dit[1]; - } - else{ - add1=dit[2]; - add2=dit[3]; - } - for(x=ibuf->x;x>0;x--){ - pix = *rect; - if (x & 1) pix += add1; - else pix += add2; - - if (pix>255) pix=255; - *rect = pix & and; - rect += 4; - } - } -} diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c index 4e8d61f8675..0cc4346041f 100644 --- a/source/blender/imbuf/intern/divers.c +++ b/source/blender/imbuf/intern/divers.c @@ -34,55 +34,12 @@ #include "BLI_math.h" #include "imbuf.h" -#include "imbuf_patch.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" #include "IMB_allocimbuf.h" -#include "IMB_divers.h" #include "BKE_utildefines.h" #include "BKE_colortools.h" -void imb_checkncols(struct ImBuf *ibuf) -{ - unsigned int i; - - if (ibuf==0) return; - - if (IS_amiga(ibuf)){ - if (IS_ham(ibuf)){ - if (ibuf->depth == 0) ibuf->depth = 6; - ibuf->mincol = 0; - ibuf->maxcol = 1 << (ibuf->depth - 2); - /*printf("%d %d\n", ibuf->maxcol, ibuf->depth);*/ - return; - } else if (IS_hbrite(ibuf)){ - ibuf->mincol = 0; - ibuf->maxcol = 64; - ibuf->depth = 6; - return; - } - } - - if (ibuf->maxcol == 0){ - if (ibuf->depth <= 8){ - ibuf->mincol = 0; - ibuf->maxcol = (1 << ibuf->depth); - return; - } else if (ibuf->depth == 0){ - ibuf->depth = 5; - ibuf->mincol = 0; - ibuf->maxcol = 32; - } - return; - } else { - /* ibuf->maxcol defines the depth */ - for (i=1 ; ibuf->maxcol > (1 << i); i++); - ibuf->depth = i; - return; - } -} - - void IMB_de_interlace(struct ImBuf *ibuf) { struct ImBuf * tbuf1, * tbuf2; @@ -138,43 +95,6 @@ void IMB_interlace(struct ImBuf *ibuf) } -void IMB_gamwarp(struct ImBuf *ibuf, double gamma) -{ - uchar gam[256]; - int i; - uchar *rect; - float *rectf; - - if (ibuf == 0) return; - if (gamma == 1.0) return; - - rect = (uchar *) ibuf->rect; - rectf = ibuf->rect_float; - - gamma = 1.0 / gamma; - - if (rect) { - for (i = 255 ; i >= 0 ; i--) - gam[i] = (255.0 * pow(i / 255.0 , - gamma)) + 0.5; - - for (i = ibuf->x * ibuf->y ; i>0 ; i--, rect+=4){ - rect[0] = gam[rect[0]]; - rect[1] = gam[rect[1]]; - rect[2] = gam[rect[2]]; - } - } - - if (rectf) { - for (i = ibuf->x * ibuf->y ; i>0 ; i--, rectf+=4){ - rectf[0] = pow(rectf[0] / 255.0, gamma); - rectf[1] = pow(rectf[1] / 255.0, gamma); - rectf[2] = pow(rectf[2] / 255.0, gamma); - } - } -} - - /* assume converting from linear float to sRGB byte */ void IMB_rect_from_float(struct ImBuf *ibuf) { diff --git a/source/blender/imbuf/intern/dynlibtiff.c b/source/blender/imbuf/intern/dynlibtiff.c index 31da262ffdb..eb1b5f8e10a 100644 --- a/source/blender/imbuf/intern/dynlibtiff.c +++ b/source/blender/imbuf/intern/dynlibtiff.c @@ -49,7 +49,6 @@ #include "BLI_blenlib.h" #include "imbuf.h" -#include "imbuf_patch.h" #include "IMB_imbuf.h" #include "BKE_global.h" @@ -172,6 +171,12 @@ void libtiff_init(void) } libtiff_loadlibtiff(); G.have_libtiff = ((libtiff != NULL) && (libtiff_load_symbols())); + + if (!G.have_libtiff && (G.f & G_DEBUG)) { + printf("Unable to load: libtiff.\n"); + printf("Try setting the BF_TIFF_LIB environment variable if you want this support.\n"); + printf("Example: setenv BF_TIFF_LIB /usr/lib/libtiff.so\n"); + } } void libtiff_exit(void) @@ -230,6 +235,26 @@ int libtiff_load_symbols(void) if (libtiff__TIFFmalloc == NULL) { return (0); } + /* Attempt to load TIFFSetDirectory */ + libtiff_TIFFSetDirectory = libtiff_findsymbol("TIFFSetDirectory"); + if (libtiff_TIFFSetDirectory == NULL) { + return (0); + } + /* Attempt to load TIFFNumberOfDirectories */ + libtiff_TIFFNumberOfDirectories = libtiff_findsymbol("TIFFNumberOfDirectories"); + if (libtiff_TIFFNumberOfDirectories == NULL) { + return (0); + } + /* Attempt to load TIFFIsTiled */ + libtiff_TIFFIsTiled = libtiff_findsymbol("TIFFIsTiled"); + if (libtiff_TIFFIsTiled == NULL) { + return (0); + } + /* Attempt to load TIFFReadRGBATile */ + libtiff_TIFFReadRGBATile = libtiff_findsymbol("TIFFReadRGBATile"); + if (libtiff_TIFFReadRGBATile == NULL) { + return (0); + } return (1); } @@ -247,3 +272,9 @@ int (*libtiff_TIFFSetField)(TIFF*, ttag_t, ...) = NULL; tsize_t (*libtiff_TIFFWriteEncodedStrip)(TIFF*, tstrip_t, tdata_t, tsize_t) = NULL; void (*libtiff__TIFFfree)(tdata_t) = NULL; tdata_t (*libtiff__TIFFmalloc)(tsize_t) = NULL; +int (*libtiff_TIFFSetDirectory)(TIFF*, tdir_t) = NULL; +tdir_t (*libtiff_TIFFNumberOfDirectories)(TIFF*) = NULL; +int (*libtiff_TIFFIsTiled)(TIFF*) = NULL; +int (*libtiff_TIFFReadRGBATile)(TIFF*, uint32, uint32, uint32 * ) = NULL; + + diff --git a/source/blender/imbuf/intern/dynlibtiff.h b/source/blender/imbuf/intern/dynlibtiff.h index 6c8cd184463..5fafafbcf94 100644 --- a/source/blender/imbuf/intern/dynlibtiff.h +++ b/source/blender/imbuf/intern/dynlibtiff.h @@ -51,5 +51,9 @@ extern int (*libtiff_TIFFSetField)(TIFF*, ttag_t, ...); extern tsize_t (*libtiff_TIFFWriteEncodedStrip)(TIFF*, tstrip_t, tdata_t, tsize_t); extern void (*libtiff__TIFFfree)(tdata_t); extern tdata_t (*libtiff__TIFFmalloc)(tsize_t); +extern int (*libtiff_TIFFSetDirectory)(TIFF*, tdir_t); +extern tdir_t (*libtiff_TIFFNumberOfDirectories)(TIFF*); +extern int (*libtiff_TIFFIsTiled)(TIFF*); +extern int (*libtiff_TIFFReadRGBATile)(TIFF*, uint32, uint32, uint32 * ); #endif /* DYN_LIBTIFF_H */ diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c new file mode 100644 index 00000000000..4a491ceba22 --- /dev/null +++ b/source/blender/imbuf/intern/filetype.c @@ -0,0 +1,105 @@ +/* + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Blender Foundation, 2010. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" +#include "IMB_filetype.h" + +#ifdef WITH_OPENEXR +#include "openexr/openexr_api.h" +#endif + +#ifdef WITH_DDS +#include "dds/dds_api.h" +#endif + +#ifdef WITH_QUICKTIME +#include "quicktime_import.h" +#endif + +#include "imbuf.h" + +static int imb_ftype_default(ImFileType *type, ImBuf *ibuf) { return (ibuf->ftype & type->filetype); } +#if defined(__APPLE__) && defined(IMBUF_COCOA) +static int imb_ftype_cocoa(ImFileType *type, ImBuf *ibuf) { return (ibuf->ftype & TIF); } +#endif +static int imb_ftype_iris(ImFileType *type, ImBuf *ibuf) { return (ibuf->ftype == IMAGIC); } +#ifdef WITH_QUICKTIME +static int imb_ftype_quicktime(ImFileType *type, ImBuf *ibuf) { return 0; } // XXX +#endif + +#ifdef WITH_QUICKTIME +void quicktime_init(void); +void quicktime_exit(void); +#endif + +void libtiff_init(void); +void libtiff_exit(void); + +ImFileType IMB_FILE_TYPES[]= { + {NULL, NULL, imb_is_a_iris, imb_ftype_iris, imb_loadiris, imb_saveiris, NULL, 0, IMAGIC}, + {NULL, NULL, imb_is_a_jpeg, imb_ftype_default, imb_load_jpeg, imb_savejpeg, NULL, 0, JPG}, + {NULL, NULL, imb_is_a_png, imb_ftype_default, imb_loadpng, imb_savepng, NULL, 0, PNG}, + {NULL, NULL, imb_is_a_bmp, imb_ftype_default, imb_bmp_decode, imb_savebmp, NULL, 0, BMP}, + {NULL, NULL, imb_is_a_targa, imb_ftype_default, imb_loadtarga, imb_savetarga, NULL, 0, TGA}, + {NULL, NULL, imb_is_dpx, imb_ftype_default, imb_loaddpx, imb_save_dpx, NULL, IM_FTYPE_FLOAT, DPX}, + {NULL, NULL, imb_is_cineon, imb_ftype_default, imb_loadcineon, imb_savecineon, NULL, IM_FTYPE_FLOAT, CINEON}, +#if defined(__APPLE__) && defined(IMBUF_COCOA) + {NULL, NULL, imb_is_a_cocoa, imb_ftype_cocoa, imb_imb_cocoaLoadImage, imb_savecocoa, NULL, 0, TIF}, +#else + {libtiff_init, libtiff_exit, imb_is_a_tiff, imb_ftype_default, imb_loadtiff, imb_savetiff, imb_loadtiletiff, 0, TIF}, +#endif + {NULL, NULL, imb_is_a_hdr, imb_ftype_default, imb_loadhdr, imb_savehdr, NULL, IM_FTYPE_FLOAT, RADHDR}, +#ifdef WITH_OPENEXR + {NULL, NULL, imb_is_a_openexr, imb_ftype_default, imb_load_openexr, imb_save_openexr, NULL, IM_FTYPE_FLOAT, OPENEXR}, +#endif +#ifdef WITH_OPENJPEG + {NULL, NULL, imb_is_a_jp2, imb_ftype_default, imb_jp2_decode, imb_savejp2, NULL, IM_FTYPE_FLOAT, JP2}, +#endif +#ifdef WITH_DDS + {NULL, NULL, imb_is_a_dds, imb_ftype_default, imb_load_dds, NULL, NULL, 0, DDS}, +#endif +#ifdef WITH_QUICKTIME + {quicktime_init, quicktime_exit, imb_is_a_quicktime, imb_ftype_quicktime, imb_quicktime_decode, NULL, NULL, 0, QUICKTIME}, +#endif + {NULL, NULL, NULL, NULL, NULL, NULL, 0}}; + +void imb_filetypes_init(void) +{ + ImFileType *type; + + for(type=IMB_FILE_TYPES; type->is_a; type++) + if(type->init) + type->init(); +} + +void imb_filetypes_exit(void) +{ + ImFileType *type; + + for(type=IMB_FILE_TYPES; type->is_a; type++) + if(type->exit) + type->exit(); +} + diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c index 5692686a9bc..3ee05da15c9 100644 --- a/source/blender/imbuf/intern/filter.c +++ b/source/blender/imbuf/intern/filter.c @@ -29,14 +29,13 @@ * $Id$ */ -#include "BLI_blenlib.h" +#include "BKE_utildefines.h" -#include "imbuf.h" -#include "imbuf_patch.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" #include "IMB_filter.h" +#include "imbuf.h" /************************************************************************/ /* FILTERS */ @@ -375,17 +374,97 @@ void IMB_makemipmap(ImBuf *ibuf, int use_filter) { ImBuf *hbuf = ibuf; int curmap = 0; - while (curmap < IB_MIPMAP_LEVELS) { - if (use_filter) { + + ibuf->miptot= 1; + + while(curmap < IB_MIPMAP_LEVELS) { + if(use_filter) { ImBuf *nbuf= IMB_allocImBuf(hbuf->x, hbuf->y, 32, IB_rect, 0); IMB_filterN(nbuf, hbuf); ibuf->mipmap[curmap] = IMB_onehalf(nbuf); IMB_freeImBuf(nbuf); } - else ibuf->mipmap[curmap] = IMB_onehalf(hbuf); - hbuf = ibuf->mipmap[curmap]; - if (hbuf->x == 1 && hbuf->y == 1) break; + else + ibuf->mipmap[curmap] = IMB_onehalf(hbuf); + + ibuf->miptot= curmap+2; + hbuf= ibuf->mipmap[curmap]; + hbuf->miplevel= curmap+1; + + if(!hbuf || (hbuf->x == 1 && hbuf->y == 1)) + break; + curmap++; } } +ImBuf *IMB_getmipmap(ImBuf *ibuf, int level) +{ + CLAMP(level, 0, ibuf->miptot-1); + return (level == 0)? ibuf: ibuf->mipmap[level-1]; +} + +void IMB_premultiply_rect(unsigned int *rect, int depth, int w, int h) +{ + char *cp; + int x, y, val; + + if(depth == 24) { /* put alpha at 255 */ + cp= (char *)(rect); + + for(y=0; y>8; + cp[1]= (cp[1]*val)>>8; + cp[2]= (cp[2]*val)>>8; + } + } + } +} + +void IMB_premultiply_rect_float(float *rect_float, int depth, int w, int h) +{ + float val, *cp; + int x, y; + + if(depth==24) { /* put alpha at 1.0 */ + cp= rect_float; + + for(y=0; yrect) + IMB_premultiply_rect(ibuf->rect, ibuf->depth, ibuf->x, ibuf->y); + + if(ibuf->rect_float) + IMB_premultiply_rect_float(ibuf->rect_float, ibuf->depth, ibuf->x, ibuf->y); +} + diff --git a/source/blender/imbuf/intern/gen_dynlibtiff.py b/source/blender/imbuf/intern/gen_dynlibtiff.py deleted file mode 100755 index fd69a353bfd..00000000000 --- a/source/blender/imbuf/intern/gen_dynlibtiff.py +++ /dev/null @@ -1,303 +0,0 @@ -#!/usr/bin/env python - -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# Contributor(s): Jonathan Merritt. -# -# ***** END GPL LICENSE BLOCK ***** - -# -# This script generates a C source file and a header file that implement -# dynamic loading functionality for libtiff. -# If you need to make more functions from libtiff available, then simply add -# them to the tiff_functions[] list below. -# - - -FILENAME = 'dynlibtiff' -C_FILENAME = '%s.c' % FILENAME -H_FILENAME = '%s.h' % FILENAME - - -COMMENT = \ -"""/** - * Dynamically loaded libtiff support. - * - * This file is automatically generated by the gen_dynlibtiff.py script. - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributor(s): Jonathan Merritt. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** - * To use the dynamic libtiff support, you must initialize the library using: - * libtiff_init() - * This attempts to load libtiff dynamically at runtime. G.have_libtiff will - * be set to indicate whether or not libtiff is available. If libtiff is - * not available, Blender can proceed with no ill effects, provided that - * it does not attempt to use any of the libtiff_ functions. When you're - * finished, close the library with: - * libtiff_exit() - * These functions are both declared in IMB_imbuf.h - * - * The functions provided by dyn_libtiff.h are the same as those in the - * normal static / shared libtiff, except that they are prefixed by the - * string "libtiff_" to indicate that they belong to a dynamically-loaded - * version. - */ -""" - - -C_EXTRA = \ -""" -#include -#include -#include - -#include "BLI_blenlib.h" - -#include "imbuf.h" -#include "imbuf_patch.h" -#include "IMB_imbuf.h" - -#include "BKE_global.h" -#include "PIL_dynlib.h" - -/********************* - * LOCAL DEFINITIONS * - *********************/ -PILdynlib *libtiff = NULL; -void libtiff_loadlibtiff(void); -void* libtiff_findsymbol(char*); -int libtiff_load_symbols(void); - - -/************************** - * LIBRARY INITIALIZATION * - **************************/ - -void libtiff_loadlibtiff(void) -{ - char *filename; - libtiff = NULL; - - filename = getenv("BF_TIFF_LIB"); - if (filename) libtiff = PIL_dynlib_open(filename); - if (libtiff != NULL) return; - - /* Try to find libtiff in a couple of standard places */ -#ifdef __APPLE__ - /* OSX has version specific library */ - //standard install location - libtiff = PIL_dynlib_open("/usr/local/lib/libtiff.dylib"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("/usr/local/lib/libtiff.3.dylib"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("/usr/local/lib/libtiff.4.dylib"); - if (libtiff != NULL) return; - //inside the blender app package contents/resources - libtiff = PIL_dynlib_open("@executable_path/../resources/libtiff.dylib"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("@executable_path/../resources/libtiff.3.dylib"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("@executable_path/../resources/libtiff.4.dylib"); - if (libtiff != NULL) return; - //inside the blender app package contents/frameworks - libtiff = PIL_dynlib_open("@executable_path/../frameworks/libtiff.dylib"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("@executable_path/../frameworks/libtiff.3.dylib"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("@executable_path/../frameworks/libtiff.4.dylib"); - if (libtiff != NULL) return; - //along side the blender app package - libtiff = PIL_dynlib_open("@executable_path/../../../libtiff.dylib"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("@executable_path/../../../libtiff.3.dylib"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("@executable_path/../../../libtiff.4.dylib"); - if (libtiff != NULL) return; - //inside the blender app package contents/MacOS - libtiff = PIL_dynlib_open("@executable_path/libtiff.dylib"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("@executable_path/libtiff.3.dylib"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("@executable_path/libtiff.4.dylib"); - if (libtiff != NULL) return; -#else - libtiff = PIL_dynlib_open("libtiff.so"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("libtiff.so.3"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("libtiff.so.4"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("libtiff.dll"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("/usr/lib/libtiff.so"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("/usr/lib/libtiff.so.3"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("/usr/lib/libtiff.so.4"); - if (libtiff != NULL) return; -#ifdef __x86_64__ - libtiff = PIL_dynlib_open("/usr/lib64/libtiff.so"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("/usr/lib64/libtiff.so.3"); - if (libtiff != NULL) return; - libtiff = PIL_dynlib_open("/usr/lib64/libtiff.so.4"); - if (libtiff != NULL) return; -#endif - libtiff = PIL_dynlib_open("/usr/local/lib/libtiff.so"); - if (libtiff != NULL) return; - /* For solaris */ - libtiff = PIL_dynlib_open("/usr/openwin/lib/libtiff.so"); -#endif - -} - -void *libtiff_findsymbol(char *name) -{ - void *symbol = NULL; - assert(libtiff != NULL); - symbol = PIL_dynlib_find_symbol(libtiff, name); - if (symbol == NULL) { - char *err = PIL_dynlib_get_error_as_string(libtiff); - - if (err) printf("libtiff_findsymbol: error %s\\n",err); - else printf("libtiff_findsymbol: error Unknown.\\n"); - - libtiff = NULL; - G.have_libtiff = (0); - return NULL; - } - return symbol; -} - -void libtiff_init(void) -{ - if (libtiff != NULL) { - printf("libtiff_init: Attempted to load libtiff twice!\\n"); - return; - } - libtiff_loadlibtiff(); - G.have_libtiff = ((libtiff != NULL) && (libtiff_load_symbols())); -} - -void libtiff_exit(void) -{ - if (libtiff != NULL) { - PIL_dynlib_close(libtiff); - libtiff = NULL; - } -} - - -""" - - -class CFun: - def __init__(self, name, retType, args): - self.name = name - self.retType = retType - self.args = args - def getDynamicName(self): - return ('libtiff_%s' % self.name) - def getDynamicDecl(self): - argstr = (('%s, '*len(self.args)) % tuple(self.args))[:-2] - return ('%s (*%s)(%s)' % (self.retType, - self.getDynamicName(), argstr)) - def getLoadSymbol(self): - dname = self.getDynamicName() - return ( - """\t/* Attempt to load %s */ - %s = libtiff_findsymbol("%s"); - if (%s == NULL) { - return (0); - }\n""" % (self.name, dname, self.name, dname)) - - -# If you need more functions, add them to the list below, based upon entries -# in either tiffio.h or tiff.h. -tiff_functions = [ - CFun('TIFFClientOpen', 'TIFF*', ['const char*', 'const char*', - 'thandle_t', 'TIFFReadWriteProc', 'TIFFReadWriteProc', - 'TIFFSeekProc', 'TIFFCloseProc', 'TIFFSizeProc', - 'TIFFMapFileProc', 'TIFFUnmapFileProc']), - CFun('TIFFClose', 'void', ['TIFF*']), - CFun('TIFFGetField', 'int', ['TIFF*', 'ttag_t', '...']), - CFun('TIFFOpen', 'TIFF*', ['const char*', 'const char*']), - CFun('TIFFReadRGBAImage', 'int', ['TIFF*', 'uint32', 'uint32', - 'uint32*', 'int']), - CFun('TIFFSetField', 'int', ['TIFF*', 'ttag_t', '...']), - CFun('TIFFWriteEncodedStrip', 'tsize_t', ['TIFF*', 'tstrip_t', - 'tdata_t', 'tsize_t']), - CFun('_TIFFfree', 'void', ['tdata_t']), - CFun('_TIFFmalloc', 'tdata_t', ['tsize_t']), -] - - -def outputDynCFile(outfile, header_file_name): - outfile.write(COMMENT) - outfile.write('#include "%s"\n' % header_file_name) - outfile.write(C_EXTRA) - outfile.write('int libtiff_load_symbols(void)\n') - outfile.write('{\n') - for function in tiff_functions: - outfile.write(function.getLoadSymbol()) - outfile.write('\treturn (1);\n') - outfile.write('}\n') - outfile.write(""" - -/******************* - * SYMBOL POINTERS * - *******************/\n\n""") - for function in tiff_functions: - outfile.write('%s = NULL;\n' % function.getDynamicDecl()) - - -def outputDynHFile(outfile): - outfile.write(COMMENT) - outfile.write('#ifndef DYN_LIBTIFF_H\n') - outfile.write('#include "tiffio.h"\n') - for function in tiff_functions: - outfile.write('extern %s;\n' % function.getDynamicDecl()) - outfile.write('#endif /* DYN_LIBTIFF_H */\n\n') - - -if __name__ == '__main__': - outfile = file(C_FILENAME, 'w') - outputDynCFile(outfile, H_FILENAME) - outfile.close() - outfile = file(H_FILENAME, 'w') - outputDynHFile(outfile) - outfile.close() diff --git a/source/blender/imbuf/intern/ham.c b/source/blender/imbuf/intern/ham.c deleted file mode 100644 index 27f6d9c691a..00000000000 --- a/source/blender/imbuf/intern/ham.c +++ /dev/null @@ -1,276 +0,0 @@ -/** - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * ham.c - * - * $Id$ - */ - -#include "BLI_blenlib.h" - -#include "imbuf.h" -#include "imbuf_patch.h" -#include "IMB_imbuf_types.h" -#include "IMB_imbuf.h" -#include "IMB_cmap.h" -#include "IMB_hamx.h" -#include "IMB_ham.h" - -extern short alpha_col0; - -#define HAMB 0x0100 -#define HAMG 0x0400 -#define HAMR 0x0200 -#define HAMC 0x1000 -#define HAMFREE 0x2000 - -static void addhamdither(short x, unsigned char *dit, - short dmax, unsigned char *rgb, - unsigned short *ham, - short type, short round, short shift) -{ - short dx = 0; - short c1, c2; - - for (;x>0;x--){ - if (ham[0] & (HAMFREE | type)){ - c2 = c1 = *rgb; - - /* wrap dither */ - while (dx >= dmax) dx -= dmax; - - c1 += dit[dx]; - if (c1 > 255) c1 = 255; - c2 += round; - if (c2 > 255) c2 = 255; - - if (c1 != c2){ - c1 >>= shift; c2 >>= shift; - if (ham[1] & HAMFREE){ - ham[0] = type + c1; - ham[1] = type + c2; - } else if (ham[1] & type){ - ham[0] = type + c1; - } else if ((ham[2] & (type | HAMFREE)) == type){ - ham[0] = type + c1; - } else if ((ham[1] & HAMC) | (ham[2] & HAMC)){ - ham[0] = type + c1; - } - } - } - rgb += 4; - ham ++; - dx ++; - } -} - -static void convhamscanl(short x, short y, - unsigned char *rgbbase, - unsigned char *coltab, - short *deltab, - short bits) -{ - int a, r, g, b, lr, lg, lb, dr, dg, db, col, fout, type, x2; - int round, shift; - uchar *rgb, dit[2]; - unsigned short *ham, *hambase; - - /* Concept: - first we check the entire image, where color transitions are coded: FGRB XXXX XXXX - F - free color value, can be changed by anyone - G/R/B - green/red/blue ham transition, only to be changed by this color - XXXX XXXX - N bits value. - - 0000 XXXX XXXX is palette color. - - after that first the green dither is added, then the red dither, and finally blue dither - */ - - if ((hambase = (unsigned short *) malloc((x+4) * sizeof(unsigned short)))==0) return; - - lb = coltab[1]; - lg = coltab[2]; - lr = coltab[3]; - type = col = 0; - - ham = hambase; - rgb = rgbbase; - - shift = 8 - bits; - round = 1 << (shift - 1); - - /* to prevent 'noise' at the end of the line */ - for (x2 = 3; x2 >= 0; x2 --) hambase[x + x2] = HAMFREE; - - for (x2 = x ;x2 > 0; x2--){ - r = rgb[0] + round; - g = rgb[1] + round; - b = rgb[2] + round; - a = rgb[3]; - - if (a < 128 && alpha_col0) { - a = 1; - } else a = 0; - - if (b > 255) b = 255; - if (g > 255) { - g = 255; - } - if (r > 255) r = 255; - - r >>= shift; - g >>= shift; - b >>= shift; - - if ((b-lb) | (g-lg) | (r-lr) | a){ - if (a) { - col = 0; - type = HAMC; - } else { - col = ((b << (2 * bits)) + (g << bits) + r) << 1; - fout = deltab[col + 1]; - col = deltab[col]; - type = HAMC; - - dr = quadr[lr-r]; - dg = quadr[lg-g]; - db = quadr[lb-b]; - - if ((dr+dg) <= fout){ - fout = dr+dg; - col = b; - type = HAMB; - } - if ((dg+db) <= fout){ - fout = dg+db; - col = r; - type = HAMR; - } - if ((dr+db) <= fout){ - fout = dr+db; - col = g; - type = HAMG; - } - } - - switch(type){ - case HAMG: - lg = g; - break; - case HAMR: - lr = r; - break; - case HAMB: - lb = b; - break; - default: - lb = coltab[col*4 + 1]; - lg = coltab[col*4 + 2]; - lr = coltab[col*4 + 3]; - } - *ham = type + col; - } else *ham = HAMG + HAMFREE + g; - - rgb += 4; - ham ++; - } - - - if (y & 1){ - dit[0] = 0 << (shift - 2); - dit[1] = 3 << (shift - 2); - } else { - dit[0] = 2 << (shift - 2); - dit[1] = 1 << (shift - 2); - } - - addhamdither(x,dit,2,rgbbase+2,hambase,HAMG, round, shift); - - if ((y & 1)==0){ - dit[0] = 3 << (shift - 2); - dit[1] = 0 << (shift - 2); - } else { - dit[0] = 1 << (shift - 2); - dit[1] = 2 << (shift - 2); - } - - addhamdither(x,dit,2,rgbbase+3,hambase,HAMR, round, shift); - addhamdither(x,dit,2,rgbbase+1,hambase,HAMB, round, shift); - - - ham = hambase; - rgb = rgbbase; - rgb += 3; - - for (x2=x;x2>0;x2--){ - type = *(ham++); - if (type & HAMG) type |= HAMR | HAMB; - - *rgb = (type & 0xff) | ((type & (HAMR | HAMB)) >> shift); - rgb += 4; - } - - free (hambase); -} - - -short imb_converttoham(struct ImBuf *ibuf) -{ - unsigned int coltab[256],*rect; - short x,y,* deltab; - int mincol; - - memcpy(coltab,ibuf->cmap,4 * ibuf->maxcol); - - mincol = ibuf->mincol; - if (alpha_col0 && mincol == 0) mincol = 1; - - if (ibuf->ftype == AN_hamx) { - deltab = imb_coldeltatab((uchar *) coltab, 0, ibuf->maxcol, 4); - } else { - ibuf->cbits = ibuf->depth - 2; - imb_losecmapbits(ibuf, coltab); - deltab = imb_coldeltatab((uchar *) coltab, mincol, ibuf->maxcol, ibuf->cbits); - } - - rect = ibuf->rect; - x=ibuf->x; - y=ibuf->y; - - if (ibuf->ftype == AN_hamx){ - IMB_dit2(ibuf, 2, 4); - IMB_dit2(ibuf, 1, 4); - IMB_dit2(ibuf, 0, 4); - imb_convhamx(ibuf, (uchar *)coltab, deltab); - } else { - for(;y > 0; y--){ - convhamscanl(x, y, (uchar *)rect, (uchar *)coltab, deltab, ibuf->cbits); - rect += x; - } - } - - return (TRUE); -} diff --git a/source/blender/imbuf/intern/hamx.c b/source/blender/imbuf/intern/hamx.c deleted file mode 100644 index 57672f54999..00000000000 --- a/source/blender/imbuf/intern/hamx.c +++ /dev/null @@ -1,581 +0,0 @@ -/** - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * hamx.c - * - * $Id$ - */ - -#include "BLI_blenlib.h" - -#include "imbuf.h" -#include "imbuf_patch.h" -#include "IMB_imbuf_types.h" -#include "IMB_imbuf.h" - -#include "IMB_allocimbuf.h" -#include "IMB_filter.h" -#include "IMB_ham.h" -#include "IMB_hamx.h" - -#ifdef WIN32 -#include -#include "BLI_winstuff.h" -#endif - -/* actually hard coded endianness */ -#define GET_BIG_LONG(x) (((uchar *) (x))[0] << 24 | ((uchar *) (x))[1] << 16 | ((uchar *) (x))[2] << 8 | ((uchar *) (x))[3]) -#define GET_LITTLE_LONG(x) (((uchar *) (x))[3] << 24 | ((uchar *) (x))[2] << 16 | ((uchar *) (x))[1] << 8 | ((uchar *) (x))[0]) -#define SWAP_L(x) (((x << 24) & 0xff000000) | ((x << 8) & 0xff0000) | ((x >> 8) & 0xff00) | ((x >> 24) & 0xff)) -#define SWAP_S(x) (((x << 8) & 0xff00) | ((x >> 8) & 0xff)) - -/* more endianness... should move to a separate file... */ -#if defined(__sgi) || defined (__sparc) || defined (__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__hppa__) || defined (__BIG_ENDIAN__) -#define GET_ID GET_BIG_LONG -#define LITTLE_LONG SWAP_LONG -#else -#define GET_ID GET_LITTLE_LONG -#define LITTLE_LONG ENDIAN_NOP -#endif - -#ifndef ABS -#define ABS(x) ((x) < 0 ? -(x) : (x)) -#endif - -static uchar hamx_array_char[] = { - 0x00,0x00,0xFF,0xFF, 0x00,0x00,0xFF,0xFF, 0x00,0x00,0xFF,0xFF, 0x00,0x00,0xFF,0xFF, 0x00,0x00,0xFF,0xFF, 0x00,0x00,0xFF,0xFF, 0x00,0x00,0xFF,0xFF, 0x00,0x00,0xFF,0xFF, - 0x00,0x00,0xFF,0xFF, 0x00,0x00,0xFF,0xFF, 0x00,0x00,0xFF,0xFF, 0x00,0x00,0xFF,0xFF, 0x00,0x00,0xFF,0xFF, 0x00,0x00,0xFF,0xFF, 0x00,0x00,0xFF,0xFF, 0x00,0x00,0xFF,0xFF, - 0x00,0xFF,0x00,0xFF, 0x00,0xFF,0x00,0xFF, 0x00,0xFF,0x00,0xFF, 0x00,0xFF,0x00,0xFF, 0x00,0xFF,0x00,0xFF, 0x00,0xFF,0x00,0xFF, 0x00,0xFF,0x00,0xFF, 0x00,0xFF,0x00,0xFF, - 0x00,0xFF,0x00,0xFF, 0x00,0xFF,0x00,0xFF, 0x00,0xFF,0x00,0xFF, 0x00,0xFF,0x00,0xFF, 0x00,0xFF,0x00,0xFF, 0x00,0xFF,0x00,0xFF, 0x00,0xFF,0x00,0xFF, 0x00,0xFF,0x00,0xFF, - 0x00,0xFF,0xFF,0x00, 0x00,0xFF,0xFF,0x00, 0x00,0xFF,0xFF,0x00, 0x00,0xFF,0xFF,0x00, 0x00,0xFF,0xFF,0x00, 0x00,0xFF,0xFF,0x00, 0x00,0xFF,0xFF,0x00, 0x00,0xFF,0xFF,0x00, - 0x00,0xFF,0xFF,0x00, 0x00,0xFF,0xFF,0x00, 0x00,0xFF,0xFF,0x00, 0x00,0xFF,0xFF,0x00, 0x00,0xFF,0xFF,0x00, 0x00,0xFF,0xFF,0x00, 0x00,0xFF,0xFF,0x00, 0x00,0xFF,0xFF,0x00, - - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - - 0x00,0x00,0x00,0x00, 0x00,0x10,0x00,0x00, 0x00,0x20,0x00,0x00, 0x00,0x30,0x00,0x00, 0x00,0x40,0x00,0x00, 0x00,0x50,0x00,0x00, 0x00,0x60,0x00,0x00, 0x00,0x70,0x00,0x00, - 0x00,0x80,0x00,0x00, 0x00,0x90,0x00,0x00, 0x00,0xA0,0x00,0x00, 0x00,0xB0,0x00,0x00, 0x00,0xC0,0x00,0x00, 0x00,0xD0,0x00,0x00, 0x00,0xE0,0x00,0x00, 0x00,0xF0,0x00,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x10,0x00, 0x00,0x00,0x20,0x00, 0x00,0x00,0x30,0x00, 0x00,0x00,0x40,0x00, 0x00,0x00,0x50,0x00, 0x00,0x00,0x60,0x00, 0x00,0x00,0x70,0x00, - 0x00,0x00,0x80,0x00, 0x00,0x00,0x90,0x00, 0x00,0x00,0xA0,0x00, 0x00,0x00,0xB0,0x00, 0x00,0x00,0xC0,0x00, 0x00,0x00,0xD0,0x00, 0x00,0x00,0xE0,0x00, 0x00,0x00,0xF0,0x00, - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x10, 0x00,0x00,0x00,0x20, 0x00,0x00,0x00,0x30, 0x00,0x00,0x00,0x40, 0x00,0x00,0x00,0x50, 0x00,0x00,0x00,0x60, 0x00,0x00,0x00,0x70, - 0x00,0x00,0x00,0x80, 0x00,0x00,0x00,0x90, 0x00,0x00,0x00,0xA0, 0x00,0x00,0x00,0xB0, 0x00,0x00,0x00,0xC0, 0x00,0x00,0x00,0xD0, 0x00,0x00,0x00,0xE0, 0x00,0x00,0x00,0xF0, - - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x30, 0x00,0x00,0x00,0x60, 0x00,0x00,0x00,0x90, 0x00,0x00,0x00,0xC0, 0x00,0x00,0x00,0xF0, - 0x00,0x00,0x20,0x00, 0x00,0x00,0x20,0x30, 0x00,0x00,0x20,0x60, 0x00,0x00,0x20,0x90, 0x00,0x00,0x20,0xC0, 0x00,0x00,0x20,0xF0, - 0x00,0x00,0x40,0x00, 0x00,0x00,0x40,0x30, 0x00,0x00,0x40,0x60, 0x00,0x00,0x40,0x90, 0x00,0x00,0x40,0xC0, 0x00,0x00,0x40,0xF0, - 0x00,0x00,0x60,0x00, 0x00,0x00,0x60,0x30, 0x00,0x00,0x60,0x60, 0x00,0x00,0x60,0x90, 0x00,0x00,0x60,0xC0, 0x00,0x00,0x60,0xF0, - 0x00,0x00,0x90,0x00, 0x00,0x00,0x90,0x30, 0x00,0x00,0x90,0x60, 0x00,0x00,0x90,0x90, 0x00,0x00,0x90,0xC0, 0x00,0x00,0x90,0xF0, - 0x00,0x00,0xB0,0x00, 0x00,0x00,0xB0,0x30, 0x00,0x00,0xB0,0x60, 0x00,0x00,0xB0,0x90, 0x00,0x00,0xB0,0xC0, 0x00,0x00,0xB0,0xF0, - 0x00,0x00,0xD0,0x00, 0x00,0x00,0xD0,0x30, 0x00,0x00,0xD0,0x60, 0x00,0x00,0xD0,0x90, 0x00,0x00,0xD0,0xC0, 0x00,0x00,0xD0,0xF0, - 0x00,0x00,0xF0,0x00, 0x00,0x00,0xF0,0x30, 0x00,0x00,0xF0,0x60, 0x00,0x00,0xF0,0x90, 0x00,0x00,0xF0,0xC0, 0x00,0x00,0xF0,0xF0, - 0x00,0x50,0x00,0x00, 0x00,0x50,0x00,0x30, 0x00,0x50,0x00,0x60, 0x00,0x50,0x00,0x90, 0x00,0x50,0x00,0xC0, 0x00,0x50,0x00,0xF0, - 0x00,0x50,0x20,0x00, 0x00,0x50,0x20,0x30, 0x00,0x50,0x20,0x60, 0x00,0x50,0x20,0x90, 0x00,0x50,0x20,0xC0, 0x00,0x50,0x20,0xF0, - 0x00,0x50,0x40,0x00, 0x00,0x50,0x40,0x30, 0x00,0x50,0x40,0x60, 0x00,0x50,0x40,0x90, 0x00,0x50,0x40,0xC0, 0x00,0x50,0x40,0xF0, - 0x00,0x50,0x60,0x00, 0x00,0x50,0x60,0x30, 0x00,0x50,0x60,0x60, 0x00,0x50,0x60,0x90, 0x00,0x50,0x60,0xC0, 0x00,0x50,0x60,0xF0, - 0x00,0x50,0x90,0x00, 0x00,0x50,0x90,0x30, 0x00,0x50,0x90,0x60, 0x00,0x50,0x90,0x90, 0x00,0x50,0x90,0xC0, 0x00,0x50,0x90,0xF0, - 0x00,0x50,0xB0,0x00, 0x00,0x50,0xB0,0x30, 0x00,0x50,0xB0,0x60, 0x00,0x50,0xB0,0x90, 0x00,0x50,0xB0,0xC0, 0x00,0x50,0xB0,0xF0, - 0x00,0x50,0xD0,0x00, 0x00,0x50,0xD0,0x30, 0x00,0x50,0xD0,0x60, 0x00,0x50,0xD0,0x90, 0x00,0x50,0xD0,0xC0, 0x00,0x50,0xD0,0xF0, - 0x00,0x50,0xF0,0x00, 0x00,0x50,0xF0,0x30, 0x00,0x50,0xF0,0x60, 0x00,0x50,0xF0,0x90, 0x00,0x50,0xF0,0xC0, 0x00,0x50,0xF0,0xF0, - 0x00,0xA0,0x00,0x00, 0x00,0xA0,0x00,0x30, 0x00,0xA0,0x00,0x60, 0x00,0xA0,0x00,0x90, 0x00,0xA0,0x00,0xC0, 0x00,0xA0,0x00,0xF0, - 0x00,0xA0,0x20,0x00, 0x00,0xA0,0x20,0x30, 0x00,0xA0,0x20,0x60, 0x00,0xA0,0x20,0x90, 0x00,0xA0,0x20,0xC0, 0x00,0xA0,0x20,0xF0, - 0x00,0xA0,0x40,0x00, 0x00,0xA0,0x40,0x30, 0x00,0xA0,0x40,0x60, 0x00,0xA0,0x40,0x90, 0x00,0xA0,0x40,0xC0, 0x00,0xA0,0x40,0xF0, - 0x00,0xA0,0x60,0x00, 0x00,0xA0,0x60,0x30, 0x00,0xA0,0x60,0x60, 0x00,0xA0,0x60,0x90, 0x00,0xA0,0x60,0xC0, 0x00,0xA0,0x60,0xF0, - 0x00,0xA0,0x90,0x00, 0x00,0xA0,0x90,0x30, 0x00,0xA0,0x90,0x60, 0x00,0xA0,0x90,0x90, 0x00,0xA0,0x90,0xC0, 0x00,0xA0,0x90,0xF0, - 0x00,0xA0,0xB0,0x00, 0x00,0xA0,0xB0,0x30, 0x00,0xA0,0xB0,0x60, 0x00,0xA0,0xB0,0x90, 0x00,0xA0,0xB0,0xC0, 0x00,0xA0,0xB0,0xF0, - 0x00,0xA0,0xD0,0x00, 0x00,0xA0,0xD0,0x30, 0x00,0xA0,0xD0,0x60, 0x00,0xA0,0xD0,0x90, 0x00,0xA0,0xD0,0xC0, 0x00,0xA0,0xD0,0xF0, - 0x00,0xA0,0xF0,0x00, 0x00,0xA0,0xF0,0x30, 0x00,0xA0,0xF0,0x60, 0x00,0xA0,0xF0,0x90, 0x00,0xA0,0xF0,0xC0, 0x00,0xA0,0xF0,0xF0, - 0x00,0xF0,0x00,0x00, 0x00,0xF0,0x00,0x30, 0x00,0xF0,0x00,0x60, 0x00,0xF0,0x00,0x90, 0x00,0xF0,0x00,0xC0, 0x00,0xF0,0x00,0xF0, - 0x00,0xF0,0x20,0x00, 0x00,0xF0,0x20,0x30, 0x00,0xF0,0x20,0x60, 0x00,0xF0,0x20,0x90, 0x00,0xF0,0x20,0xC0, 0x00,0xF0,0x20,0xF0, - 0x00,0xF0,0x40,0x00, 0x00,0xF0,0x40,0x30, 0x00,0xF0,0x40,0x60, 0x00,0xF0,0x40,0x90, 0x00,0xF0,0x40,0xC0, 0x00,0xF0,0x40,0xF0, - 0x00,0xF0,0x60,0x00, 0x00,0xF0,0x60,0x30, 0x00,0xF0,0x60,0x60, 0x00,0xF0,0x60,0x90, 0x00,0xF0,0x60,0xC0, 0x00,0xF0,0x60,0xF0, - 0x00,0xF0,0x90,0x00, 0x00,0xF0,0x90,0x30, 0x00,0xF0,0x90,0x60, 0x00,0xF0,0x90,0x90, 0x00,0xF0,0x90,0xC0, 0x00,0xF0,0x90,0xF0, - 0x00,0xF0,0xB0,0x00, 0x00,0xF0,0xB0,0x30, 0x00,0xF0,0xB0,0x60, 0x00,0xF0,0xB0,0x90, 0x00,0xF0,0xB0,0xC0, 0x00,0xF0,0xB0,0xF0, - 0x00,0xF0,0xD0,0x00, 0x00,0xF0,0xD0,0x30, 0x00,0xF0,0xD0,0x60, 0x00,0xF0,0xD0,0x90, 0x00,0xF0,0xD0,0xC0, 0x00,0xF0,0xD0,0xF0, - 0x00,0xF0,0xF0,0x00, 0x00,0xF0,0xF0,0x30, 0x00,0xF0,0xF0,0x60, 0x00,0xF0,0xF0,0x90, 0x00,0xF0,0xF0,0xC0, 0x00,0xF0,0xF0,0xF0, - - 0x00,0x10,0x10,0x10, 0x00,0x20,0x20,0x20, 0x00,0x30,0x30,0x30, 0x00,0x40,0x40,0x40, - 0x00,0x50,0x50,0x50, 0x00,0x60,0x60,0x60, 0x00,0x70,0x70,0x70, 0x00,0x80,0x80,0x80, - 0x00,0x90,0x90,0x90, 0x00,0xA0,0xA0,0xA0, 0x00,0xB0,0xB0,0xB0, 0x00,0xC0,0xC0,0xC0, - 0x00,0xD0,0xD0,0xD0, 0x00,0xE0,0xE0,0xE0 -}; - -static int * hamx_array = (int *) (hamx_array_char); - -static uchar cmap_hamx[] = { - 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x30, 0x00,0x00,0x00,0x60, 0x00,0x00,0x00,0x90, 0x00,0x00,0x00,0xC0, 0x00,0x00,0x00,0xF0, - 0x00,0x00,0x20,0x00, 0x00,0x00,0x20,0x30, 0x00,0x00,0x20,0x60, 0x00,0x00,0x20,0x90, 0x00,0x00,0x20,0xC0, 0x00,0x00,0x20,0xF0, - 0x00,0x00,0x40,0x00, 0x00,0x00,0x40,0x30, 0x00,0x00,0x40,0x60, 0x00,0x00,0x40,0x90, 0x00,0x00,0x40,0xC0, 0x00,0x00,0x40,0xF0, - 0x00,0x00,0x60,0x00, 0x00,0x00,0x60,0x30, 0x00,0x00,0x60,0x60, 0x00,0x00,0x60,0x90, 0x00,0x00,0x60,0xC0, 0x00,0x00,0x60,0xF0, - 0x00,0x00,0x90,0x00, 0x00,0x00,0x90,0x30, 0x00,0x00,0x90,0x60, 0x00,0x00,0x90,0x90, 0x00,0x00,0x90,0xC0, 0x00,0x00,0x90,0xF0, - 0x00,0x00,0xB0,0x00, 0x00,0x00,0xB0,0x30, 0x00,0x00,0xB0,0x60, 0x00,0x00,0xB0,0x90, 0x00,0x00,0xB0,0xC0, 0x00,0x00,0xB0,0xF0, - 0x00,0x00,0xD0,0x00, 0x00,0x00,0xD0,0x30, 0x00,0x00,0xD0,0x60, 0x00,0x00,0xD0,0x90, 0x00,0x00,0xD0,0xC0, 0x00,0x00,0xD0,0xF0, - 0x00,0x00,0xF0,0x00, 0x00,0x00,0xF0,0x30, 0x00,0x00,0xF0,0x60, 0x00,0x00,0xF0,0x90, 0x00,0x00,0xF0,0xC0, 0x00,0x00,0xF0,0xF0, - 0x00,0x50,0x00,0x00, 0x00,0x50,0x00,0x30, 0x00,0x50,0x00,0x60, 0x00,0x50,0x00,0x90, 0x00,0x50,0x00,0xC0, 0x00,0x50,0x00,0xF0, - 0x00,0x50,0x20,0x00, 0x00,0x50,0x20,0x30, 0x00,0x50,0x20,0x60, 0x00,0x50,0x20,0x90, 0x00,0x50,0x20,0xC0, 0x00,0x50,0x20,0xF0, - 0x00,0x50,0x40,0x00, 0x00,0x50,0x40,0x30, 0x00,0x50,0x40,0x60, 0x00,0x50,0x40,0x90, 0x00,0x50,0x40,0xC0, 0x00,0x50,0x40,0xF0, - 0x00,0x50,0x60,0x00, 0x00,0x50,0x60,0x30, 0x00,0x50,0x60,0x60, 0x00,0x50,0x60,0x90, 0x00,0x50,0x60,0xC0, 0x00,0x50,0x60,0xF0, - 0x00,0x50,0x90,0x00, 0x00,0x50,0x90,0x30, 0x00,0x50,0x90,0x60, 0x00,0x50,0x90,0x90, 0x00,0x50,0x90,0xC0, 0x00,0x50,0x90,0xF0, - 0x00,0x50,0xB0,0x00, 0x00,0x50,0xB0,0x30, 0x00,0x50,0xB0,0x60, 0x00,0x50,0xB0,0x90, 0x00,0x50,0xB0,0xC0, 0x00,0x50,0xB0,0xF0, - 0x00,0x50,0xD0,0x00, 0x00,0x50,0xD0,0x30, 0x00,0x50,0xD0,0x60, 0x00,0x50,0xD0,0x90, 0x00,0x50,0xD0,0xC0, 0x00,0x50,0xD0,0xF0, - 0x00,0x50,0xF0,0x00, 0x00,0x50,0xF0,0x30, 0x00,0x50,0xF0,0x60, 0x00,0x50,0xF0,0x90, 0x00,0x50,0xF0,0xC0, 0x00,0x50,0xF0,0xF0, - 0x00,0xA0,0x00,0x00, 0x00,0xA0,0x00,0x30, 0x00,0xA0,0x00,0x60, 0x00,0xA0,0x00,0x90, 0x00,0xA0,0x00,0xC0, 0x00,0xA0,0x00,0xF0, - 0x00,0xA0,0x20,0x00, 0x00,0xA0,0x20,0x30, 0x00,0xA0,0x20,0x60, 0x00,0xA0,0x20,0x90, 0x00,0xA0,0x20,0xC0, 0x00,0xA0,0x20,0xF0, - 0x00,0xA0,0x40,0x00, 0x00,0xA0,0x40,0x30, 0x00,0xA0,0x40,0x60, 0x00,0xA0,0x40,0x90, 0x00,0xA0,0x40,0xC0, 0x00,0xA0,0x40,0xF0, - 0x00,0xA0,0x60,0x00, 0x00,0xA0,0x60,0x30, 0x00,0xA0,0x60,0x60, 0x00,0xA0,0x60,0x90, 0x00,0xA0,0x60,0xC0, 0x00,0xA0,0x60,0xF0, - 0x00,0xA0,0x90,0x00, 0x00,0xA0,0x90,0x30, 0x00,0xA0,0x90,0x60, 0x00,0xA0,0x90,0x90, 0x00,0xA0,0x90,0xC0, 0x00,0xA0,0x90,0xF0, - 0x00,0xA0,0xB0,0x00, 0x00,0xA0,0xB0,0x30, 0x00,0xA0,0xB0,0x60, 0x00,0xA0,0xB0,0x90, 0x00,0xA0,0xB0,0xC0, 0x00,0xA0,0xB0,0xF0, - 0x00,0xA0,0xD0,0x00, 0x00,0xA0,0xD0,0x30, 0x00,0xA0,0xD0,0x60, 0x00,0xA0,0xD0,0x90, 0x00,0xA0,0xD0,0xC0, 0x00,0xA0,0xD0,0xF0, - 0x00,0xA0,0xF0,0x00, 0x00,0xA0,0xF0,0x30, 0x00,0xA0,0xF0,0x60, 0x00,0xA0,0xF0,0x90, 0x00,0xA0,0xF0,0xC0, 0x00,0xA0,0xF0,0xF0, - 0x00,0xF0,0x00,0x00, 0x00,0xF0,0x00,0x30, 0x00,0xF0,0x00,0x60, 0x00,0xF0,0x00,0x90, 0x00,0xF0,0x00,0xC0, 0x00,0xF0,0x00,0xF0, - 0x00,0xF0,0x20,0x00, 0x00,0xF0,0x20,0x30, 0x00,0xF0,0x20,0x60, 0x00,0xF0,0x20,0x90, 0x00,0xF0,0x20,0xC0, 0x00,0xF0,0x20,0xF0, - 0x00,0xF0,0x40,0x00, 0x00,0xF0,0x40,0x30, 0x00,0xF0,0x40,0x60, 0x00,0xF0,0x40,0x90, 0x00,0xF0,0x40,0xC0, 0x00,0xF0,0x40,0xF0, - 0x00,0xF0,0x60,0x00, 0x00,0xF0,0x60,0x30, 0x00,0xF0,0x60,0x60, 0x00,0xF0,0x60,0x90, 0x00,0xF0,0x60,0xC0, 0x00,0xF0,0x60,0xF0, - 0x00,0xF0,0x90,0x00, 0x00,0xF0,0x90,0x30, 0x00,0xF0,0x90,0x60, 0x00,0xF0,0x90,0x90, 0x00,0xF0,0x90,0xC0, 0x00,0xF0,0x90,0xF0, - 0x00,0xF0,0xB0,0x00, 0x00,0xF0,0xB0,0x30, 0x00,0xF0,0xB0,0x60, 0x00,0xF0,0xB0,0x90, 0x00,0xF0,0xB0,0xC0, 0x00,0xF0,0xB0,0xF0, - 0x00,0xF0,0xD0,0x00, 0x00,0xF0,0xD0,0x30, 0x00,0xF0,0xD0,0x60, 0x00,0xF0,0xD0,0x90, 0x00,0xF0,0xD0,0xC0, 0x00,0xF0,0xD0,0xF0, - 0x00,0xF0,0xF0,0x00, 0x00,0xF0,0xF0,0x30, 0x00,0xF0,0xF0,0x60, 0x00,0xF0,0xF0,0x90, 0x00,0xF0,0xF0,0xC0, 0x00,0xF0,0xF0,0xF0, - 0x00,0x10,0x10,0x10, 0x00,0x20,0x20,0x20, 0x00,0x30,0x30,0x30, 0x00,0x40,0x40,0x40, 0x00,0x50,0x50,0x50, 0x00,0x60,0x60,0x60, - 0x00,0x70,0x70,0x70, 0x00,0x80,0x80,0x80, 0x00,0x90,0x90,0x90, 0x00,0xA0,0xA0,0xA0, 0x00,0xB0,0xB0,0xB0, 0x00,0xC0,0xC0,0xC0, - 0x00,0xD0,0xD0,0xD0, 0x00,0xE0,0xE0,0xE0 -}; - - -float adat_gamma = 1.0; -float adat_distort = 1.0; - -/* - * - * New version: - * - * 32 brighntesses Y 15 with direct access (black and white are specials) - * 16 colors H ue - * 7 intensities S aturation - * - * Total 3584 'different' colors. First 512 colors free. - * - * - */ - -void imb_convhamx(struct ImBuf *ibuf, unsigned char *coltab, short *deltab) -{ - short r,g,b,lr,lg,lb,dr,dg,db,col,fout,type,step; - int i; - uchar *rect; - - /* - b = 0000 xxxx - g = 0001 xxxx - r = 0010 xxxx - cmap >= 48 - */ - - for (step = 0 ; step < 2 ; step ++){ - rect = (uchar *) ibuf->rect; - rect += 4*step; - i = ((ibuf->x * ibuf->y) + 2 - step - 1) / 2; - - lb = coltab[1]; - lg = coltab[2]; - lr = coltab[3]; - type = col = 0; - - for ( ;i>0;i--){ - b = rect[2] >> 4; - g = rect[1] >> 4; - r = rect[0] >> 4; - - if ((b-lb) | (g-lg) | (r-lr)){ - col = ((b<<8) + (g<<4) + r) << 1; - fout = deltab[col + 1]; - col = deltab[col]; - type = 0; - dr = quadr[lr-r] ; - dg = quadr[lg-g] ; - db = quadr[lb-b]; - - if ((dr+dg)<=fout) { - fout = dr+dg ; - type = 1; - } - if ((dg+db)<=fout) { - fout = dg+db; - type = 2; - } - if ((dr+db)<=fout) { - fout = dr+db; - type = 4; - } - - switch(type){ - case 1: - lb = b ; - col = b; - break; - case 4: - lg = g ; - col = g+16; - break; - case 2: - lr = r ; - col = r + 32; - break; - default: - /*printf("%04x %5d %5d ", (b<<8) + (g<<4) + r, col, fout);*/ - - lb = coltab[col*4 + 1]; - lg = coltab[col*4 + 2]; - lr = coltab[col*4 + 3]; - /*printf("%01x%01x%01x %01x%01x%01x\n", b, g, r, lb, lg, lr);*/ - col += 48; - } - } - rect[3] = col; - rect += 8; - } - } -} - -static short dec_hamx(struct ImBuf * ibuf, unsigned char *body, int cmap[]) -{ - int todo,i; - int j,step,col; - unsigned int *rect; - - for (step = 0 ; step < 2 ; step ++){ - rect = ibuf->rect; - rect += step; - todo = (ibuf->x * ibuf->y + 2 - step - 1) / 2; - col = cmap[0]; - while (todo>0){ - i = *body++; - - if (i & 128){ /* fill */ - - i = 257-i; - todo -= i; - j = *(body++); - - col = ((col & hamx_array[j]) | hamx_array[j + 256]); - - do{ - *rect = col; - rect += 2; - }while (--i); - } else{ /* copy */ - i++; - todo-=i; - - do{ - j = *(body++); - *rect = col = ((col & hamx_array[j]) | hamx_array[j + 256]); - rect += 2; - }while (--i); - } - } - if (todo) return (0); - } - return(1); -} - - -struct ImBuf *imb_loadanim(int *iffmem, int flags) -{ - int chunk, totlen, len, *mem, cmaplen = 0; - unsigned int *cmap = NULL; - uchar *body = 0; - struct Adat adat; - struct ImBuf *ibuf=0; - static int is_flipped = FALSE; - - mem=iffmem; - if (GET_ID(mem) != FORM) return (0); - if (GET_ID(mem + 2) != ANIM) return (0); - totlen= (GET_BIG_LONG(mem + 1) + 1) & ~1; - mem += 3; - totlen -= 4; - adat.w = 0; - adat.xorig = 0; - adat.yorig = 0; - adat.gamma = adat_gamma; - adat.distort = adat_distort; - - while(totlen > 0){ - chunk = GET_ID(mem); - len = (GET_BIG_LONG(mem + 1) + 1) & ~1; - mem += 2; - - totlen -= len+8; - switch (chunk){ - case ADAT: - if (len > sizeof(struct Adat)){ - memcpy(&adat,mem,sizeof(struct Adat)); - } else{ - memcpy(&adat,mem,len); - } - adat.w = BIG_SHORT(adat.w); - adat.h = BIG_SHORT(adat.h); - adat.type = BIG_SHORT(adat.type); - adat.xorig = BIG_SHORT(adat.xorig); - adat.yorig = BIG_SHORT(adat.yorig); - break; - case CMAP: - cmap = (unsigned int *) mem; - cmaplen = len; - break; - case BODY: - body = (uchar *) mem; - break; - } - mem = (int *)((uchar *)mem +len); - } - - if (body == 0) return (0); - if (adat.w == 0) return (0); - - adat_gamma = adat.gamma; - adat_distort = adat.distort; - - if (flags & IB_test) ibuf=IMB_allocImBuf(adat.w, adat.h, 24, 0, 0); - else ibuf=IMB_allocImBuf(adat.w, adat.h, 24, IB_rect, 0); - if (ibuf==0) return (0); - - ibuf->ftype = (Anim | adat.type); - ibuf->profile = IB_PROFILE_SRGB; - ibuf->xorig = adat.xorig; - ibuf->yorig = adat.yorig; - ibuf->flags = flags; - - if (cmaplen){ - ibuf->cmap = malloc(cmaplen); - memcpy(ibuf->cmap, cmap, cmaplen); - ibuf->maxcol = cmaplen >> 2; - } - - if (flags & IB_test){ - if (flags & IB_freem) free(iffmem); - return(ibuf); - } - - switch (adat.type){ - case HAMX: - if (flags & IB_rect){ - if (!is_flipped) { - int i; - unsigned int * t; - t = (unsigned int *) hamx_array_char; - for (i = 0; i < sizeof(hamx_array_char) / sizeof(int) ; i++) { - t[i] = SWAP_LONG(t[i]); - } - - t = (unsigned int *) cmap_hamx; - - for (i = 0; i < sizeof(cmap_hamx) / sizeof(int) ; i++) { - t[i] = SWAP_LONG(t[i]); - } - - is_flipped= TRUE; - } - - if (dec_hamx(ibuf,body,(int*) cmap_hamx) == 0){ - IMB_freeImBuf(ibuf); - ibuf = 0; - } - if (flags & IB_ttob) IMB_flipy(ibuf); - } - break; - default: - IMB_freeImBuf(ibuf); - ibuf = 0; - } - - if (flags & IB_freem) free(iffmem); - - return (ibuf); -} - - -static unsigned char *makebody_anim(int bytes, - unsigned char *buf, - unsigned char *rect) -{ - register uchar last,this; - register int copy; - register uchar *rectstart,*temp; - - bytes--; - rectstart = rect; - last = *rect++; - this = *rect++; - copy = last^this; - while (bytes>0){ - if (copy){ - do{ - last = this; - this = *rect++; - if (last == this){ - if (this == rect[-3]){ /* three the same? */ - bytes --; /* init bytes */ - break; - } - } - }while (--bytes != 0); - - copy = rect-rectstart; - copy --; - if (bytes) copy -= 2; - - temp = rect; - rect = rectstart; - - while (copy){ - last = copy; - if (copy>MAXDAT) last = MAXDAT; - copy -= last; - *buf++ = last-1; - do{ - *buf++ = *rect++; - }while(--last != 0); - } - rectstart = rect; - rect = temp; - last = this; - - copy = FALSE; - } else { - while (*rect++ == this){ /* seek first different byte */ - if (--bytes == 0) break; /* or end of line */ - } - rect --; - copy = rect-rectstart; - rectstart = rect; - bytes --; - this = *rect++; - - while (copy){ - if (copy>MAXRUN){ - *buf++ = -(MAXRUN-1); - *buf++ = last; - copy -= MAXRUN; - } else { - *buf++ = -(copy-1); - *buf++ = last; - break; - } - } - copy=TRUE; - } - } - return (buf); -} - - -short imb_enc_anim(struct ImBuf *ibuf, int file) -{ - int step, size, i, skip, steps = 0; - uchar *buf1, *crect, *_buf1, *_buf2, *bufend; - short ok = TRUE; - - if (ibuf == 0) return (0); - if (file < 0 ) return (0); - if (ibuf->rect == 0) return(0); - - /* add dither */ - - switch(ibuf->ftype){ - case AN_hamx: - ibuf->cmap = (unsigned int *) cmap_hamx; - ibuf->mincol = 0; - ibuf->maxcol = sizeof(cmap_hamx) / 4; - imb_converttoham(ibuf); - steps = 2; - break; - } - if (steps == 0) return 0; - - size = ((ibuf->x + 1)* (ibuf->y + 1)) / steps + 1024; - if ((_buf1 = malloc(size)) == 0) return(0); - if ((_buf2 = malloc(size)) == 0){ - free(_buf1); - return(0); - } - - skip = 4 * steps; - for (step = 0 ; step < steps ; step ++){ - crect = (uchar *) ibuf->rect; - crect += 4 * step; - size = (ibuf->x * ibuf->y + steps - step - 1) / steps; - buf1 = _buf1; - if ((ibuf->ftype == AN_hamx) || (ibuf->ftype == AN_yuvx)){ - crect += 3; - for (i = size ; i>0 ; i--){ - *(buf1 ++) = *crect; - crect += skip; - } - } else{ - for (i = size ; i>0 ; i--){ - *(buf1 ++) = crect[1] + (crect[2] >> 2) + (crect[3] >> 5); - crect += skip; - } - } - bufend = makebody_anim(size,_buf2,_buf1); - if (bufend == 0){ - ok = FALSE; - break; - } - size = bufend - _buf2; - if (write(file, _buf2, size) != size){ - ok = FALSE; - break; - } - } - free(_buf1); - free(_buf2); - return (ok); -} diff --git a/source/blender/imbuf/intern/iff.c b/source/blender/imbuf/intern/iff.c deleted file mode 100644 index 7297d7d6dd1..00000000000 --- a/source/blender/imbuf/intern/iff.c +++ /dev/null @@ -1,224 +0,0 @@ -/** - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * iff.c - * - * $Id$ - */ - -#include "BLI_blenlib.h" -#include "imbuf.h" -#include "imbuf_patch.h" -#include "IMB_imbuf_types.h" -#include "IMB_iff.h" -#ifdef WIN32 -#include -#include "BLI_winstuff.h" -#endif - -unsigned short imb_start_iff(struct ImBuf *ibuf, int file) -{ - unsigned int *point, size, *buf; - - if ((point=buf=(unsigned int *)malloc(32768))==0) return FALSE; - - *point++ = FORM; /* FORMxxxxILBM in buffer */ - *point++ = 0; - - if (IS_amiga(ibuf)){ - struct BitMapHeader *bmhd; - - *point++ = ILBM; - *point++ = CAMG; - *point++ = 4; - *point++ = (ibuf->ftype & 0xffff); - - *point++=BMHD; - *point++=sizeof(struct BitMapHeader); - - bmhd=(struct BitMapHeader *)point; /* bmhd points to location where bmhd will be */ - point=(unsigned int *)((char *)point+sizeof(struct BitMapHeader)); /* advance pointer already */ - - bmhd->w=ibuf->x; - bmhd->h=ibuf->y; - bmhd->pageWidth=ibuf->x; - bmhd->pageHeight=ibuf->y; - bmhd->x=0; - bmhd->y=0; - bmhd->nPlanes=ibuf->depth; - bmhd->masking=0; - if (ibuf->flags & IB_vert){ - bmhd->compression=2; - } - else{ - bmhd->compression=1; - } - bmhd->pad1=0; - bmhd->transparentColor=0; - bmhd->xAspect=1; - bmhd->yAspect=1; - } else if (IS_anim(ibuf)){ - struct Adat *adat; - extern float adat_gamma; - extern float adat_distort; - - *point++ = ANIM; - *point++ = ADAT; - *point++ = BIG_LONG(sizeof(struct Adat)); - - adat = (struct Adat *)point; - point = (unsigned int *)((char *)point+sizeof(struct Adat)); /* advance pointer already */ - - adat->w = BIG_SHORT(ibuf->x); - adat->h = BIG_SHORT(ibuf->y); - - adat->type = BIG_SHORT(ibuf->ftype); - adat->xorig = BIG_SHORT(ibuf->xorig); - adat->yorig = BIG_SHORT(ibuf->yorig); - adat->pad = 0; - adat->gamma = adat_gamma; - adat->distort = adat_distort; - } - - size=((uchar *)point-(uchar *)buf); - if (write(file,buf,size)!=size){ - free(buf); - return (FALSE); - } - - if (ibuf->cmap){ - if (IS_anim(ibuf)){ - size = ibuf->maxcol * sizeof(int); - buf[0] = CMAP; - buf[1] = BIG_LONG(size); - if (write(file,buf,8) != 8){ - free(buf); - return (FALSE); - } - if (write(file,ibuf->cmap,size) != size){ - free(buf); - return (FALSE); - } - } else{ - uchar *cpoint,*cols; - unsigned int i,bits; - - point = buf; - if (IS_amiga(ibuf)){ - *(point++) = CMAP; - *(point++) = BIG_LONG(3*ibuf->maxcol); - } - - cpoint = (uchar *) point; - cols = (uchar *)ibuf->cmap; - if ((ibuf->cbits > 0) && (ibuf->cbits < 8)){ - bits = ~((1 << (8-ibuf->cbits)) - 1); - } else bits = -1; - - if (IS_ham(ibuf)) bits = -1; - - for (i=0 ; imaxcol ; i++){ - *(cpoint++) = cols[0] & bits; - *(cpoint++) = cols[1] & bits; - *(cpoint++) = cols[2] & bits; - cols += 4; - } - if (ibuf->maxcol & 1) *(cpoint++)=0; - - size=(cpoint-(uchar *)buf); - if (write(file,buf,size)!=size){ - free(buf); - return (FALSE); - } - } - } - - if (IS_amiga(ibuf)) buf[0] = BODY; - if (IS_anim(ibuf)) buf[0] = BODY; - buf[1]=0; - - if (write(file,buf,8)!=8){ - free(buf); - return(FALSE); - } - - free(buf); - return (TRUE); -} - - -unsigned short imb_update_iff(int file, int code) -{ - int buf[2], filelen, skip; - uchar nop; - - if (file<=0) return (FALSE); - - filelen = BLI_filesize(file)-8; /* calc filelength */ - - lseek(file,0L,2); /* seek end */ - - if (filelen & 1){ /* make length 'even' */ - switch(code){ - case BODY: - nop = IFFNOP; - break; - } - if (write(file,&nop,1)!=1) return (FALSE); - filelen++; - } - lseek(file,4L,0); - - buf[0] = BIG_LONG(filelen); - - if (write(file, buf, 4) != 4) return (FALSE); - if (code == 0) return (TRUE); - - filelen-=4; - if(lseek(file,4L,1) == -1) return (FALSE); - - while (filelen>0){ /* seek BODY */ - if(read(file, buf, 8) != 8) return (FALSE); - filelen -= 8; - if (buf[0] == code) break; - - skip = (BIG_LONG(buf[1]) + 1) & ~1; - filelen -= skip; - if(lseek(file, skip, 1) == -1) return (FALSE); - } - if (filelen <= 0) { - printf("update_iff: couldn't find chunk\n"); - return (FALSE); - } - - lseek(file, -4L, 1); - - buf[0] = BIG_LONG(filelen); - - if (write(file, buf, 4)!=4) return (FALSE); - - return (TRUE); -} diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c index e52cab0bdd3..4450394e9e6 100644 --- a/source/blender/imbuf/intern/imageprocess.c +++ b/source/blender/imbuf/intern/imageprocess.c @@ -37,6 +37,8 @@ * $Id$ */ +#include + #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" #include "math.h" diff --git a/source/blender/imbuf/intern/imbuf.h b/source/blender/imbuf/intern/imbuf.h index aba4784d7d7..047795355b3 100644 --- a/source/blender/imbuf/intern/imbuf.h +++ b/source/blender/imbuf/intern/imbuf.h @@ -51,6 +51,8 @@ #include #endif +#include "MEM_guardedalloc.h" + #if !defined(WIN32) #define O_BINARY 0 #endif @@ -72,97 +74,10 @@ #define BIG_LONG SWAP_LONG #endif -#define malloc(x) MEM_mallocN(x, __FILE__) -#define free(x) MEM_freeN(x) -#define calloc(x,y) MEM_callocN((x)*(y), __FILE__) -#define freelist(x) BLI_freelistN(x) - -#ifdef SHLIB -void *(*ib_calloc)(); -#define calloc(x,y) ib_calloc((x),(y)) -void *(*ib_malloc)(); -#define malloc(x) ib_malloc(x) -void (*ib_free)(); -#define free(x) ib_free(x) -void (*ib_memcpy)(); -#define memcpy(x,y,z) ib_memcpy((x),(y),(z)) -int (*ib_abs)(); -#define abs(x) ib_abs(x) -void (*ib_fprin_tf)(); -#define fprintf ib_fprin_tf -int (*ib_sprin_tf)(); -#define sprintf ib_sprin_tf -void (*ib_prin_tf)(); -#define printf ib_prin_tf -int (*ib_lseek)(); -#define lseek(x,y,z) ib_lseek((x),(y),(z)) -void *(*ib_mmap)(); -#define mmap(u,v,w,x,y,z) ib_mmap((u),(v),(w),(x),(y),(z)) -int (*ib_munmap)(); -#define munmap(x,y) ib_munmap((x),(y)) -int (*ib_open)(); -#define open(x,y) ib_open((x),(y)) -void (*ib_close)(); -#define close(x) ib_close(x) -int (*ib_write)(); -#define write(x,y,z) ib_write((x),(y),(z)) -int (*ib_read)(); -#define read(x,y,z) ib_read((x),(y),(z)) -int (*ib_fchmod)(); -#define fchmod(x,y) ib_fchmod((x),(y)) -int (*ib_remove)(); -#define remove(x) ib_remove(x) -size_t (*ib_strlen)(); -#define strlen(x) ib_strlen(x) -int (*ib_isdigit)(); -#define isdigit(x) ib_isdigit(x) -char *(*ib_strcpy)(); -#define strcpy(x,y) ib_strcpy((x),(y)) -int (*ib_atoi)(); -#define atoi(x) ib_atoi(x) -char *(*ib_strcat)(); -#define strcat(x,y) ib_strcat((x),(y)) -int (*ib_stat)(); -/* #define stat(x,y) ib_stat((x),(y)) */ -FILE *ib_iob; -#define _iob ib_iob - -#else - -#define ib_stat stat - -#endif /* SHLIB */ - - -#define WIDTHB(x) (((x+15)>>4)<<1) - -extern unsigned short *quadr; -extern float dyuvrgb[4][4]; -extern float rgbdyuv[4][4]; - - -typedef struct Adat -{ - unsigned short w, h; - unsigned short type; - unsigned short xorig, yorig; - unsigned short pad; - float gamma; - float distort; -}Adat; +typedef unsigned char uchar; -struct BitMapHeader -{ - unsigned short w, h; /* in pixels */ - unsigned short x, y; - char nPlanes; - char masking; - char compression; - char pad1; - unsigned short transparentColor; - char xAspect, yAspect; - short pageWidth, pageHeight; -}; +#define TRUE 1 +#define FALSE 0 #endif /* IMBUF_H */ diff --git a/source/blender/imbuf/intern/imbuf_cocoa.m b/source/blender/imbuf/intern/imbuf_cocoa.m index 44ce8e061ce..02c90c5bd09 100644 --- a/source/blender/imbuf/intern/imbuf_cocoa.m +++ b/source/blender/imbuf/intern/imbuf_cocoa.m @@ -34,7 +34,6 @@ #import #include "imbuf.h" -#include "imbuf_patch.h" #include "IMB_cocoa.h" @@ -185,6 +184,9 @@ struct ImBuf *imb_cocoaLoadImage(unsigned char *mem, int size, int flags) if (ENDIAN_ORDER == B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf); + ibuf->ftype = TIF; + ibuf->profile = IB_PROFILE_SRGB; + /* return successfully */ return (ibuf); } diff --git a/source/blender/imbuf/intern/imbuf_patch.h b/source/blender/imbuf/intern/imbuf_patch.h deleted file mode 100644 index 2c8d9efbfbd..00000000000 --- a/source/blender/imbuf/intern/imbuf_patch.h +++ /dev/null @@ -1,111 +0,0 @@ -/** - * imbuf_patch.h - * - * These are some definitions to make imbuf more independent from the - * rest of the blender code. Most of these are dirty and should not - * really exist. - * - * $Id$ * - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -#ifndef IMBUF_PATCH_H -#define IMBUF_PATCH_H - -/* most of imbuf uses this aloc, and it will disappear soon - * (hopefully) (25-10-2001 nzc) */ -#include "MEM_guardedalloc.h" - -struct ImBuf; - -/* originally, these were defines ... */ -typedef unsigned char uchar; - -/* should not be used at all */ -#define TRUE 1 -#define FALSE 0 - -/* Endianness: flip the byte order. It's strange that this is needed.. - * After all, there is an internal endian.{c,h}... */ -#if defined(__sgi) || defined (__sparc) || defined(__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__hppa__) || defined (__BIG_ENDIAN__) -#define MAKE_ID(a,b,c,d) ( (int)(a)<<24 | (int)(b)<<16 | (c)<<8 | (d) ) -#else -#define MAKE_ID(a,b,c,d) ( (int)(d)<<24 | (int)(c)<<16 | (b)<<8 | (a) ) -#endif - -/* These defines loop back to the internal Blender memory management - * system, implemented in blenlib. */ -#define NEW(x) (x*)MEM_mallocN(sizeof(x),# x) -#define mallocstruct(x,y) (x*)malloc((y)* sizeof(x)) -#define callocstruct(x,y) (x*)calloc((y), sizeof(x)) - -/* These vars are used thoughout the image buffer for conversions. */ -extern float rgbyuv[4][4]; -extern float yuvrgb[4][4]; -extern float rgbbeta[4][4]; - -/* This one helps debugging. */ -extern int IB_verbose; - -/* These ID's are used for checking memory blocks. See blenlib for - * more details. This set is only used in the imbuf internally. */ - -#define CAT MAKE_ID('C','A','T',' ') -#define FORM MAKE_ID('F','O','R','M') -#define ILBM MAKE_ID('I','L','B','M') -#define BMHD MAKE_ID('B','M','H','D') -#define CMAP MAKE_ID('C','M','A','P') -#define CAMG MAKE_ID('C','A','M','G') -#define BODY MAKE_ID('B','O','D','Y') - -#define ANIM MAKE_ID('A','N','I','M') -#define ADAT MAKE_ID('A','D','A','T') -#define CODE MAKE_ID('C','O','D','E') -#define ANHD MAKE_ID('A','N','H','D') -#define DLTA MAKE_ID('D','L','T','A') -#define BLCK MAKE_ID('B','L','C','K') - -#define MAXRUN 126 -#define MAXDAT 126 -#define IFFNOP 128 - -#define camg ftype - -#define LI_rect IB_rect -#define LI_planes IB_planes -#define LI_kcmap IB_cmap -#define LI_cmap IB_cmap -#define LI_freem IB_freem -#define LI_test IB_test - -#define SI_rect IB_rect -#define SI_planes IB_planes -#define SI_kcmap IB_cmap -#define SI_cmap IB_cmap -#define SI_vert IB_vert - -#endif - diff --git a/source/blender/imbuf/intern/imginfo.c b/source/blender/imbuf/intern/imginfo.c deleted file mode 100644 index 4101045b45e..00000000000 --- a/source/blender/imbuf/intern/imginfo.c +++ /dev/null @@ -1,158 +0,0 @@ -/** - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Austin Benesh. Ton Roosendaal. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include -#include - -#include "BLI_blenlib.h" -#include "MEM_guardedalloc.h" - -#include "IMB_imbuf_types.h" -#include "IMB_imbuf.h" - -#include "IMB_imginfo.h" - - - -void IMB_imginfo_free(struct ImBuf* img) -{ - ImgInfo *info; - - if (!img) - return; - if (!img->img_info) { - return; - } - info = img->img_info; - while (info) { - ImgInfo* next = info->next; - MEM_freeN(info->key); - MEM_freeN(info->value); - MEM_freeN(info); - info = next; - } -} - -int IMB_imginfo_get_field(struct ImBuf* img, const char* key, char* field, int len) -{ - ImgInfo *info; - int retval = 0; - - if (!img) - return 0; - if (!img->img_info) { - return 0; - } - info = img->img_info; - while (info) { - if (strcmp(key, info->key) == 0) { - BLI_strncpy(field, info->value, len); - retval = 1; - break; - } - info = info->next; - } - return retval; -} - -int IMB_imginfo_add_field(struct ImBuf* img, const char* key, const char* field) -{ - ImgInfo *info; - ImgInfo *last; - - if (!img) - return 0; - - if (!img->img_info) { - img->img_info = MEM_callocN(sizeof(ImgInfo), "ImgInfo"); - info = img->img_info; - } else { - info = img->img_info; - last = info; - while (info) { - last = info; - info = info->next; - } - info = MEM_callocN(sizeof(ImgInfo), "ImgInfo"); - last->next = info; - } - info->key = BLI_strdup(key); - info->value = BLI_strdup(field); - return 1; -} - -int IMB_imginfo_del_field(struct ImBuf *img, const char *key) -{ - ImgInfo *p, *p1; - - if ((!img) || (!img->img_info)) - return (0); - - p = img->img_info; - p1 = NULL; - while (p) { - if (!strcmp (key, p->key)) { - if (p1) - p1->next = p->next; - else - img->img_info = p->next; - - MEM_freeN(p->key); - MEM_freeN(p->value); - MEM_freeN(p); - return (1); - } - p1 = p; - p = p->next; - } - return (0); -} - -int IMB_imginfo_change_field(struct ImBuf *img, const char *key, const char *field) -{ - ImgInfo *p; - - if (!img) - return (0); - - if (!img->img_info) - return (IMB_imginfo_add_field (img, key, field)); - - p = img->img_info; - while (p) { - if (!strcmp (key, p->key)) { - MEM_freeN (p->value); - p->value = BLI_strdup (field); - return (1); - } - p = p->next; - } - - return (IMB_imginfo_add_field (img, key, field)); -} diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c index 01232786070..dc9c7a1dc3b 100644 --- a/source/blender/imbuf/intern/iris.c +++ b/source/blender/imbuf/intern/iris.c @@ -32,11 +32,10 @@ #include #include "BLI_blenlib.h" #include "imbuf.h" -#include "imbuf_patch.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" #include "IMB_allocimbuf.h" -#include "IMB_iris.h" +#include "IMB_filetype.h" typedef struct { unsigned short imagic; /* stuff saved on disk . . */ @@ -224,6 +223,16 @@ static void test_endian_zbuf(struct ImBuf *ibuf) } } +/* from misc_util: flip the bytes from x */ +#define GS(x) (((unsigned char *)(x))[0] << 8 | ((unsigned char *)(x))[1]) + +/* this one is only def-ed once, strangely... */ +#define GSS(x) (((uchar *)(x))[1] << 8 | ((uchar *)(x))[0]) + +int imb_is_a_iris(unsigned char *mem) +{ + return ((GS(mem) == IMAGIC) || (GSS(mem) == IMAGIC)); +} /* * longimagedata - @@ -232,7 +241,7 @@ static void test_endian_zbuf(struct ImBuf *ibuf) * */ -struct ImBuf *imb_loadiris(unsigned char *mem, int flags) +struct ImBuf *imb_loadiris(unsigned char *mem, int size, int flags) { unsigned int *base, *lptr = NULL; float *fbase, *fptr = NULL; @@ -245,7 +254,9 @@ struct ImBuf *imb_loadiris(unsigned char *mem, int flags) int xsize, ysize, zsize; int bpp, rle, cur, badorder; ImBuf * ibuf; - + + if(!imb_is_a_iris(mem)) return NULL; + /*printf("new iris\n");*/ file_data = mem; @@ -277,8 +288,8 @@ struct ImBuf *imb_loadiris(unsigned char *mem, int flags) if (rle) { tablen = ysize*zsize*sizeof(int); - starttab = (unsigned int *)malloc(tablen); - lengthtab = (unsigned int *)malloc(tablen); + starttab = (unsigned int *)MEM_mallocN(tablen, "iris starttab"); + lengthtab = (unsigned int *)MEM_mallocN(tablen, "iris endtab"); file_offset = 512; readtab(inf,starttab,tablen); @@ -379,8 +390,8 @@ struct ImBuf *imb_loadiris(unsigned char *mem, int flags) } } - free(starttab); - free(lengthtab); + MEM_freeN(starttab); + MEM_freeN(lengthtab); } else { if (bpp == 1) { @@ -495,7 +506,6 @@ struct ImBuf *imb_loadiris(unsigned char *mem, int flags) ibuf->ftype = IMAGIC; ibuf->profile = IB_PROFILE_SRGB; - if (flags & IB_ttob) IMB_flipy(ibuf); test_endian_zbuf(ibuf); @@ -661,12 +671,12 @@ static int output_iris(unsigned int *lptr, int xsize, int ysize, int zsize, char tablen = ysize*zsize*sizeof(int); - image = (IMAGE *)malloc(sizeof(IMAGE)); - starttab = (unsigned int *)malloc(tablen); - lengthtab = (unsigned int *)malloc(tablen); + image = (IMAGE *)MEM_mallocN(sizeof(IMAGE), "iris image"); + starttab = (unsigned int *)MEM_mallocN(tablen, "iris starttab"); + lengthtab = (unsigned int *)MEM_mallocN(tablen, "iris lengthtab"); rlebuflen = 1.05*xsize+10; - rlebuf = (unsigned char *)malloc(rlebuflen); - lumbuf = (unsigned int *)malloc(xsize*sizeof(int)); + rlebuf = (unsigned char *)MEM_mallocN(rlebuflen, "iris rlebuf"); + lumbuf = (unsigned int *)MEM_mallocN(xsize*sizeof(int), "iris lumbuf"); memset(image, 0, sizeof(IMAGE)); image->imagic = IMAGIC; @@ -715,11 +725,11 @@ static int output_iris(unsigned int *lptr, int xsize, int ysize, int zsize, char fseek(outf,512,SEEK_SET); goodwrite *= writetab(outf,starttab,tablen); goodwrite *= writetab(outf,lengthtab,tablen); - free(image); - free(starttab); - free(lengthtab); - free(rlebuf); - free(lumbuf); + MEM_freeN(image); + MEM_freeN(starttab); + MEM_freeN(lengthtab); + MEM_freeN(rlebuf); + MEM_freeN(lumbuf); fclose(outf); if(goodwrite) return 1; @@ -799,7 +809,7 @@ static int compressrow(unsigned char *lbuf, unsigned char *rlebuf, int z, int cn return optr - (unsigned char *)rlebuf; } -short imb_saveiris(struct ImBuf * ibuf, char *name, int flags) +int imb_saveiris(struct ImBuf * ibuf, char *name, int flags) { short zsize; int ret; diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index d45b023fe0a..9d045aff3bf 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -26,12 +26,11 @@ #include "BLI_blenlib.h" #include "imbuf.h" -#include "imbuf_patch.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" #include "IMB_allocimbuf.h" -#include "IMB_jp2.h" +#include "IMB_filetype.h" #include "openjpeg.h" @@ -58,7 +57,7 @@ static int checkj2p(unsigned char *mem) /* J2K_CFMT */ return memcmp(JP2_HEAD, mem, 12) ? 0 : 1; } -int imb_is_a_jp2(void *buf) +int imb_is_a_jp2(unsigned char *buf) { return checkj2p(buf); } @@ -642,7 +641,7 @@ static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) { /* Found write info at http://users.ece.gatech.edu/~slabaugh/personal/c/bitmapUnix.c */ -short imb_savejp2(struct ImBuf *ibuf, char *name, int flags) { +int imb_savejp2(struct ImBuf *ibuf, char *name, int flags) { int quality = ibuf->ftype & 0xff; diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c index 127145c967d..3803aa9a8b2 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.c @@ -34,17 +34,24 @@ #include #include +#include "MEM_guardedalloc.h" + #include "BLI_blenlib.h" #include "imbuf.h" -#include "imbuf_patch.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" -#include "IMB_imginfo.h" -#include "IMB_jpeg.h" +#include "IMB_metadata.h" +#include "IMB_filetype.h" #include "jpeglib.h" #include "jerror.h" +#define IS_jpg(x) (x->ftype & JPG) +#define IS_stdjpg(x) ((x->ftype & JPG_MSK) == JPG_STD) +#define IS_vidjpg(x) ((x->ftype & JPG_MSK) == JPG_VID) +#define IS_jstjpg(x) ((x->ftype & JPG_MSK) == JPG_JST) +#define IS_maxjpg(x) ((x->ftype & JPG_MSK) == JPG_MAX) + /* the types are from the jpeg lib */ static void jpeg_error (j_common_ptr cinfo); static void init_source(j_decompress_ptr cinfo); @@ -297,11 +304,7 @@ static ImBuf * ibJpegImageFromCinfo(struct jpeg_decompress_struct * cinfo, int f for (y = ibuf->y - 1; y >= 0; y--) { jpeg_read_scanlines(cinfo, row_pointer, 1); - if (flags & IB_ttob) { - rect = (uchar *) (ibuf->rect + (ibuf->y - 1 - y) * ibuf->x); - } else { - rect = (uchar *) (ibuf->rect + y * ibuf->x); - } + rect = (uchar *) (ibuf->rect + y * ibuf->x); buffer = row_pointer[0]; switch(depth) { @@ -378,8 +381,8 @@ static ImBuf * ibJpegImageFromCinfo(struct jpeg_decompress_struct * cinfo, int f * the information when we write * it back to disk. */ - IMB_imginfo_add_field(ibuf, "None", (char *) marker->data); - ibuf->flags |= IB_imginfo; + IMB_metadata_add_field(ibuf, "None", (char *) marker->data); + ibuf->flags |= IB_metadata; goto next_stamp_marker; } @@ -404,8 +407,8 @@ static ImBuf * ibJpegImageFromCinfo(struct jpeg_decompress_struct * cinfo, int f *value = '\0'; /* need finish the key string */ value++; - IMB_imginfo_add_field(ibuf, key, value); - ibuf->flags |= IB_imginfo; + IMB_metadata_add_field(ibuf, key, value); + ibuf->flags |= IB_metadata; MEM_freeN(str); next_stamp_marker: marker= marker->next; @@ -453,11 +456,13 @@ ImBuf * imb_ibJpegImageFromFilename (const char * filename, int flags) return(ibuf); } -ImBuf * imb_ibJpegImageFromMemory (unsigned char * buffer, int size, int flags) +ImBuf * imb_load_jpeg (unsigned char * buffer, int size, int flags) { struct jpeg_decompress_struct _cinfo, *cinfo = &_cinfo; struct my_error_mgr jerr; ImBuf * ibuf; + + if(!imb_is_a_jpeg(buffer)) return NULL; cinfo->err = jpeg_std_error(&jerr.pub); jerr.pub.error_exit = jpeg_error; @@ -487,7 +492,7 @@ static void write_jpeg(struct jpeg_compress_struct * cinfo, struct ImBuf * ibuf) uchar * rect; int x, y; char neogeo[128]; - ImgInfo *iptr; + ImMetaData *iptr; char *text; jpeg_start_compress(cinfo, TRUE); @@ -498,10 +503,10 @@ static void write_jpeg(struct jpeg_compress_struct * cinfo, struct ImBuf * ibuf) memcpy(neogeo + 6, &ibuf_ftype, 4); jpeg_write_marker(cinfo, 0xe1, (JOCTET*) neogeo, 10); - if(ibuf->img_info) { + if(ibuf->metadata) { /* key + max value + "Blender" */ text= MEM_mallocN(530, "stamp info read"); - iptr= ibuf->img_info; + iptr= ibuf->metadata; while(iptr) { if (!strcmp (iptr->key, "None")) { jpeg_write_marker(cinfo, JPEG_COM, (JOCTET *) iptr->value, strlen (iptr->value) + 1); @@ -526,9 +531,9 @@ next_stamp_info: } row_pointer[0] = - mallocstruct(JSAMPLE, + MEM_mallocN(sizeof(JSAMPLE) * cinfo->input_components * - cinfo->image_width); + cinfo->image_width, "jpeg row_pointer"); for(y = ibuf->y - 1; y >= 0; y--){ rect = (uchar *) (ibuf->rect + y * ibuf->x); @@ -561,7 +566,7 @@ next_stamp_info: } jpeg_finish_compress(cinfo); - free(row_pointer[0]); + MEM_freeN(row_pointer[0]); } @@ -580,7 +585,7 @@ static int init_jpeg(FILE * outfile, struct jpeg_compress_struct * cinfo, struct cinfo->image_height = ibuf->y; cinfo->in_color_space = JCS_RGB; - if (ibuf->depth == 8 && ibuf->cmap == 0) cinfo->in_color_space = JCS_GRAYSCALE; + if (ibuf->depth == 8) cinfo->in_color_space = JCS_GRAYSCALE; if (ibuf->depth == 32) cinfo->in_color_space = JCS_UNKNOWN; switch(cinfo->in_color_space){ diff --git a/source/blender/imbuf/intern/matrix.h b/source/blender/imbuf/intern/matrix.h deleted file mode 100644 index 79b9b2dbc14..00000000000 --- a/source/blender/imbuf/intern/matrix.h +++ /dev/null @@ -1,84 +0,0 @@ -/** - * matrix.c - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/* rgbyuv is identiek aan rgbbeta */ - -float rgbyuv[4][4]={ /* afgeleid uit videoframer = Y Cr Cb in kopieen van Francois*/ - /* is identriek aan matrix van jpeg */ - { .50000, .11400, -.08131, 0.0,}, /* b */ - {-.33126, .58700, -.41869, 0.0,}, /* g */ - {-.16874, .29900, .50000, 0.0,}, /* r */ - { 128.0, 0.0, 128.0, 1.0}}; - - /* b-y (u) y r-y (v) */ - - -float rgbbeta[4][4]={ /* afgeleid uit videoframer = Y Cr Cb in kopieen van Francois*/ - /* is identriek aan matrix van jpeg */ - {.50000, .11400, -.08131, 0.0,}, /* b-y -> b */ - {-.33126, .58700, -.41869, 0.0,}, /* y -> g */ - {-.16874, .29900, .50000, 0.0,}, /* r-y -> r */ - { 128.0, 0.0, 128.0, 1.0}}; - - /* b-y y r-y */ - - - -float yuvrgb[4][4]={ - {1.77200, -0.34414, 0.0, 0.0, }, - {1.0, 1.0, 1.0, 0.0, }, - {0.0, -0.71414, 1.40200, 0.0, }, - {-226.816, 135.460, -179.456, 1.0}}; - -float rgb_to_bw[4][4]={ - {.299, .299, .299, 0.0,}, - {.587, .587, .587, 0.0,}, - {.114, .114, .114, 0.0,}, - { 0.5, 0.5, 0.5, 1.0}}; - -float dyuvrgb_oud[4][4]={ - {1.0 , 1.0 , 1.0, 0.0,}, - {1.733, -0.337, 0.0, 0.0,}, - {0.0, -.698, 1.371, 0.0,}, - {-221.8, 132.47, -175.5, 1.0}}; - -float dyuvrgb[4][4]={ - {1.164 , 1.164 , 1.164, 0.0,}, - {2.018, -0.391, 0.0, 0.0,}, - {0.0, -0.813, 1.596, 0.0,}, - {-276.7, 135.6, -222.7, 1.0}}; - -float rgbdyuv[4][4]={ - {0.439, 0.098, -0.071, 0.0,}, - {-0.291, 0.504, -0.368, 0.0,}, - {-0.148, 0.257, 0.439, 0.0,}, - {128.0, 16.0, 128.0, 1.0}}; - diff --git a/source/blender/imbuf/intern/metadata.c b/source/blender/imbuf/intern/metadata.c new file mode 100644 index 00000000000..66fe1089aea --- /dev/null +++ b/source/blender/imbuf/intern/metadata.c @@ -0,0 +1,159 @@ +/** + * $Id: metadata.c 28209 2010-04-15 15:49:48Z blendix $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2005 Blender Foundation + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Austin Benesh. Ton Roosendaal. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include +#include + +#include "BLI_blenlib.h" +#include "MEM_guardedalloc.h" + +#include "IMB_imbuf_types.h" +#include "IMB_imbuf.h" + +#include "IMB_metadata.h" + + + +void IMB_metadata_free(struct ImBuf* img) +{ + ImMetaData *info; + + if (!img) + return; + if (!img->metadata) { + return; + } + info = img->metadata; + while (info) { + ImMetaData* next = info->next; + MEM_freeN(info->key); + MEM_freeN(info->value); + MEM_freeN(info); + info = next; + } +} + +int IMB_metadata_get_field(struct ImBuf* img, const char* key, char* field, int len) +{ + ImMetaData *info; + int retval = 0; + + if (!img) + return 0; + if (!img->metadata) { + return 0; + } + info = img->metadata; + while (info) { + if (strcmp(key, info->key) == 0) { + BLI_strncpy(field, info->value, len); + retval = 1; + break; + } + info = info->next; + } + return retval; +} + +int IMB_metadata_add_field(struct ImBuf* img, const char* key, const char* field) +{ + ImMetaData *info; + ImMetaData *last; + + if (!img) + return 0; + + if (!img->metadata) { + img->metadata = MEM_callocN(sizeof(ImMetaData), "ImMetaData"); + info = img->metadata; + } else { + info = img->metadata; + last = info; + while (info) { + last = info; + info = info->next; + } + info = MEM_callocN(sizeof(ImMetaData), "ImMetaData"); + last->next = info; + } + info->key = BLI_strdup(key); + info->value = BLI_strdup(field); + return 1; +} + +int IMB_metadata_del_field(struct ImBuf *img, const char *key) +{ + ImMetaData *p, *p1; + + if ((!img) || (!img->metadata)) + return (0); + + p = img->metadata; + p1 = NULL; + while (p) { + if (!strcmp (key, p->key)) { + if (p1) + p1->next = p->next; + else + img->metadata = p->next; + + MEM_freeN(p->key); + MEM_freeN(p->value); + MEM_freeN(p); + return (1); + } + p1 = p; + p = p->next; + } + return (0); +} + +int IMB_metadata_change_field(struct ImBuf *img, const char *key, const char *field) +{ + ImMetaData *p; + + if (!img) + return (0); + + if (!img->metadata) + return (IMB_metadata_add_field (img, key, field)); + + p = img->metadata; + while (p) { + if (!strcmp (key, p->key)) { + MEM_freeN (p->value); + p->value = BLI_strdup (field); + return (1); + } + p = p->next; + } + + return (IMB_metadata_add_field (img, key, field)); +} + diff --git a/source/blender/imbuf/intern/module.c b/source/blender/imbuf/intern/module.c new file mode 100644 index 00000000000..5438066d164 --- /dev/null +++ b/source/blender/imbuf/intern/module.c @@ -0,0 +1,40 @@ +/* + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Blender Foundation, 2010. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "IMB_imbuf.h" +#include "IMB_filetype.h" + +void IMB_init(void) +{ + imb_filetypes_init(); + imb_tile_cache_init(); +} + +void IMB_exit(void) +{ + IMB_free_cache_limiter(); + imb_tile_cache_exit(); + imb_filetypes_exit(); +} + diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index c9859f8d5bd..72d2dd01ffe 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -50,6 +50,7 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void) #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" #include "IMB_allocimbuf.h" +#include "IMB_metadata.h" #include "openexr_multi.h" } @@ -177,7 +178,15 @@ static void openexr_header_compression(Header *header, int compression) } } -static short imb_save_openexr_half(struct ImBuf *ibuf, char *name, int flags) +static void openexr_header_metadata(Header *header, struct ImBuf *ibuf) +{ + ImMetaData* info; + + for(info= ibuf->metadata; info; info= info->next) + header->insert(info->key, StringAttribute(info->value)); +} + +static int imb_save_openexr_half(struct ImBuf *ibuf, char *name, int flags) { int channels = ibuf->channels; int width = ibuf->x; @@ -189,6 +198,7 @@ static short imb_save_openexr_half(struct ImBuf *ibuf, char *name, int flags) Header header (width, height); openexr_header_compression(&header, ibuf->ftype & OPENEXR_COMPRESS); + openexr_header_metadata(&header, ibuf); header.channels().insert ("R", Channel (HALF)); header.channels().insert ("G", Channel (HALF)); @@ -269,7 +279,7 @@ static short imb_save_openexr_half(struct ImBuf *ibuf, char *name, int flags) return (1); } -static short imb_save_openexr_float(struct ImBuf *ibuf, char *name, int flags) +static int imb_save_openexr_float(struct ImBuf *ibuf, char *name, int flags) { int channels = ibuf->channels; int width = ibuf->x; @@ -281,6 +291,7 @@ static short imb_save_openexr_float(struct ImBuf *ibuf, char *name, int flags) Header header (width, height); openexr_header_compression(&header, ibuf->ftype & OPENEXR_COMPRESS); + openexr_header_metadata(&header, ibuf); header.channels().insert ("R", Channel (FLOAT)); header.channels().insert ("G", Channel (FLOAT)); @@ -326,7 +337,7 @@ static short imb_save_openexr_float(struct ImBuf *ibuf, char *name, int flags) } -short imb_save_openexr(struct ImBuf *ibuf, char *name, int flags) +int imb_save_openexr(struct ImBuf *ibuf, char *name, int flags) { if (flags & IB_mem) { @@ -435,6 +446,7 @@ void IMB_exr_add_channel(void *handle, const char *layname, const char *passname BLI_addtail(&data->channels, echan); } +/* only used for writing temp. render results (not image files) */ void IMB_exr_begin_write(void *handle, char *filename, int width, int height, int compress) { ExrHandle *data= (ExrHandle *)handle; @@ -448,6 +460,7 @@ void IMB_exr_begin_write(void *handle, char *filename, int width, int height, in header.channels().insert (echan->name, Channel (FLOAT)); openexr_header_compression(&header, compress); + // openexr_header_metadata(&header, ibuf); // no imbuf. cant write /* header.lineOrder() = DECREASING_Y; this crashes in windows for file read! */ header.insert ("BlenderMultiChannel", StringAttribute ("Blender V2.43 and newer")); @@ -575,7 +588,12 @@ void IMB_exr_write_channels(void *handle) echan->xstride*sizeof(float), echan->ystride*sizeof(float))); data->ofile->setFrameBuffer (frameBuffer); - data->ofile->writePixels (data->height); + try { + data->ofile->writePixels (data->height); + } + catch (const std::exception &exc) { + std::cerr << "OpenEXR-writePixels: ERROR: " << exc.what() << std::endl; + } } else { printf("Error: attempt to save MultiLayer without layers.\n"); @@ -598,7 +616,13 @@ void IMB_exr_read_channels(void *handle) } data->ifile->setFrameBuffer (frameBuffer); - data->ifile->readPixels (0, data->height-1); + + try { + data->ifile->readPixels (0, data->height-1); + } + catch (const std::exception &exc) { + std::cerr << "OpenEXR-readPixels: ERROR: " << exc.what() << std::endl; + } } void IMB_exr_multilayer_convert(void *handle, void *base, diff --git a/source/blender/imbuf/intern/openexr/openexr_api.h b/source/blender/imbuf/intern/openexr/openexr_api.h index a6892dcbaed..c23b47d1480 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.h +++ b/source/blender/imbuf/intern/openexr/openexr_api.h @@ -46,7 +46,7 @@ extern "C" { int imb_is_a_openexr (unsigned char *mem); -short imb_save_openexr (struct ImBuf *ibuf, char *name, int flags); +int imb_save_openexr (struct ImBuf *ibuf, char *name, int flags); struct ImBuf *imb_load_openexr (unsigned char *mem, int size, int flags); diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index 2dafa043da6..68a3324816c 100644 --- a/source/blender/imbuf/intern/png.c +++ b/source/blender/imbuf/intern/png.c @@ -33,15 +33,13 @@ #include "BLI_blenlib.h" #include "imbuf.h" -#include "imbuf_patch.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" #include "IMB_allocimbuf.h" -#include "IMB_cmap.h" -#include "IMB_imginfo.h" -#include "IMB_png.h" +#include "IMB_metadata.h" +#include "IMB_filetype.h" typedef struct PNGReadStruct { unsigned char *data; @@ -53,7 +51,7 @@ static void ReadData( png_structp png_ptr, png_bytep data, png_size_t length); static void WriteData( png_structp png_ptr, png_bytep data, png_size_t length); static void Flush( png_structp png_ptr); -int imb_is_a_png(void *mem) +int imb_is_a_png(unsigned char *mem) { int ret_val = 0; @@ -94,7 +92,7 @@ static void ReadData( png_structp png_ptr, png_bytep data, png_size_t length) longjmp(png_jmpbuf(png_ptr), 1); } -short imb_savepng(struct ImBuf *ibuf, char *name, int flags) +int imb_savepng(struct ImBuf *ibuf, char *name, int flags) { png_structp png_ptr; png_infop info_ptr; @@ -219,30 +217,30 @@ short imb_savepng(struct ImBuf *ibuf, char *name, int flags) PNG_FILTER_TYPE_DEFAULT); /* image text info */ - if (ibuf->img_info) { - png_text* imginfo; - ImgInfo* iptr; + if (ibuf->metadata) { + png_text* metadata; + ImMetaData* iptr; int num_text = 0; - iptr = ibuf->img_info; + iptr = ibuf->metadata; while (iptr) { num_text++; iptr = iptr->next; } - imginfo = MEM_callocN(num_text*sizeof(png_text), "png_imginfo"); - iptr = ibuf->img_info; + metadata = MEM_callocN(num_text*sizeof(png_text), "png_metadata"); + iptr = ibuf->metadata; num_text = 0; while (iptr) { - imginfo[num_text].compression = PNG_TEXT_COMPRESSION_NONE; - imginfo[num_text].key = iptr->key; - imginfo[num_text].text = iptr->value; + metadata[num_text].compression = PNG_TEXT_COMPRESSION_NONE; + metadata[num_text].key = iptr->key; + metadata[num_text].text = iptr->value; num_text++; iptr = iptr->next; } - png_set_text(png_ptr, info_ptr, imginfo, num_text); - MEM_freeN(imginfo); + png_set_text(png_ptr, info_ptr, metadata, num_text); + MEM_freeN(metadata); } @@ -437,12 +435,12 @@ struct ImBuf *imb_loadpng(unsigned char *mem, int size, int flags) break; } - if (flags & IB_imginfo) { + if (flags & IB_metadata) { png_text* text_chunks; int count = png_get_text(png_ptr, info_ptr, &text_chunks, NULL); for(i = 0; i < count; i++) { - IMB_imginfo_add_field(ibuf, text_chunks[i].key, text_chunks[i].text); - ibuf->flags |= IB_imginfo; + IMB_metadata_add_field(ibuf, text_chunks[i].key, text_chunks[i].text); + ibuf->flags |= IB_metadata; } } diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c index 9ad28abeae4..dabb6780ea3 100644 --- a/source/blender/imbuf/intern/radiance_hdr.c +++ b/source/blender/imbuf/intern/radiance_hdr.c @@ -43,14 +43,12 @@ #include "BLI_blenlib.h" #include "imbuf.h" -#include "imbuf_patch.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" #include "IMB_allocimbuf.h" -#include "IMB_cmap.h" -#include "IMB_radiance_hdr.h" +#include "IMB_filetype.h" /* needed constants */ #define MINELEN 8 @@ -160,7 +158,7 @@ static void FLOAT2RGBE(fCOLOR fcol, RGBE rgbe) /* ImBuf read */ -int imb_is_a_hdr(void *buf) +int imb_is_a_hdr(unsigned char *buf) { // For recognition, Blender only loads first 32 bytes, so use #?RADIANCE id instead // update: actually, the 'RADIANCE' part is just an optional program name, the magic word is really only the '#?' part @@ -205,7 +203,6 @@ struct ImBuf *imb_loadhdr(unsigned char *mem, int size, int flags) if (ibuf==NULL) return NULL; ibuf->ftype = RADHDR; ibuf->profile = IB_PROFILE_LINEAR_RGB; - ibuf->xorig = ibuf->yorig = 0; if (flags & IB_test) return ibuf; @@ -331,7 +328,7 @@ static void writeHeader(FILE *file, int width, int height) fputc(10, file); } -short imb_savehdr(struct ImBuf *ibuf, char *name, int flags) +int imb_savehdr(struct ImBuf *ibuf, char *name, int flags) { FILE* file = fopen(name, "wb"); float *fp= NULL; diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c index c23daacb919..3f4e177c78b 100644 --- a/source/blender/imbuf/intern/readimage.c +++ b/source/blender/imbuf/intern/readimage.c @@ -42,275 +42,159 @@ #include "BLI_blenlib.h" #include "imbuf.h" -#include "imbuf_patch.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" +#include "IMB_filetype.h" -#include "IMB_amiga.h" -#include "IMB_iris.h" -#include "IMB_targa.h" -#include "IMB_png.h" -#include "IMB_hamx.h" -#include "IMB_jpeg.h" -#include "IMB_bmp.h" -#include "IMB_radiance_hdr.h" -#include "IMB_dpxcineon.h" -#include "BKE_global.h" - -#if defined(__APPLE__) && defined(IMBUF_COCOA) -#include "IMB_cocoa.h" -#else -#include "IMB_tiff.h" -#endif - -#ifdef WITH_OPENJPEG -#include "IMB_jp2.h" -#endif - -#ifdef WITH_OPENEXR -#include "openexr/openexr_api.h" -#endif - -#ifdef WITH_DDS -#include "dds/dds_api.h" -#endif +ImBuf *IMB_ibImageFromMemory(unsigned char *mem, int size, int flags) +{ + ImBuf *ibuf; + ImFileType *type; -#ifdef WITH_QUICKTIME -#if defined(_WIN32) || defined (__APPLE__) -#include "quicktime_import.h" -#endif -#endif - -/* actually hard coded endianness */ -#define GET_BIG_LONG(x) (((uchar *) (x))[0] << 24 | ((uchar *) (x))[1] << 16 | ((uchar *) (x))[2] << 8 | ((uchar *) (x))[3]) -#define GET_LITTLE_LONG(x) (((uchar *) (x))[3] << 24 | ((uchar *) (x))[2] << 16 | ((uchar *) (x))[1] << 8 | ((uchar *) (x))[0]) -#define SWAP_L(x) (((x << 24) & 0xff000000) | ((x << 8) & 0xff0000) | ((x >> 8) & 0xff00) | ((x >> 24) & 0xff)) -#define SWAP_S(x) (((x << 8) & 0xff00) | ((x >> 8) & 0xff)) - -/* more endianness... should move to a separate file... */ -#if defined(__sgi) || defined (__sparc) || defined (__sparc__) || defined (__PPC__) || defined (__ppc__) || defined(__hppa__) || defined (__BIG_ENDIAN__) -#define GET_ID GET_BIG_LONG -#define LITTLE_LONG SWAP_LONG -#else -#define GET_ID GET_LITTLE_LONG -#define LITTLE_LONG ENDIAN_NOP -#endif - -/* from misc_util: flip the bytes from x */ -#define GS(x) (((unsigned char *)(x))[0] << 8 | ((unsigned char *)(x))[1]) - -/* this one is only def-ed once, strangely... */ -#define GSS(x) (((uchar *)(x))[1] << 8 | ((uchar *)(x))[0]) - -int IB_verbose = TRUE; + if(mem == NULL) { + printf("Error in ibImageFromMemory: NULL pointer\n"); + return NULL; + } -ImBuf *IMB_ibImageFromMemory(int *mem, int size, int flags) { - int len; - struct ImBuf *ibuf; + for(type=IMB_FILE_TYPES; type->is_a; type++) { + if(type->load) { + ibuf= type->load(mem, size, flags); + if(ibuf) { + if(flags & IB_premul) { + IMB_premultiply_alpha(ibuf); + ibuf->flags |= IB_premul; + } - if (mem == NULL) { - printf("Error in ibImageFromMemory: NULL pointer\n"); - } else { - if ((GS(mem) == IMAGIC) || (GSS(mem) == IMAGIC)){ - return (imb_loadiris((uchar *) mem, flags)); - } else if (imb_is_a_jpeg((uchar *)mem)) { - return (imb_ibJpegImageFromMemory((uchar *)mem, size, flags)); - } - - if (GET_ID(mem) == CAT){ - mem += 3; - size -= 4; - while (size > 0){ - if (GET_ID(mem) == FORM){ - len = ((GET_BIG_LONG(mem+1) + 1) & ~1) + 8; - if ((GET_ID(mem+2) == ILBM) || (GET_ID(mem+2) == ANIM)) break; - mem = (int *)((uchar *)mem +len); - size -= len; - } else return(0); + return ibuf; } } + } + + fprintf(stderr, "Unknown fileformat\n"); - if (size > 0){ - if (GET_ID(mem) == FORM){ - if (GET_ID(mem+2) == ILBM){ - return (imb_loadamiga(mem, flags)); - } else if (GET_ID(mem+5) == ILBM){ /* animaties */ - return (imb_loadamiga(mem+3, flags)); - } else if (GET_ID(mem+2) == ANIM){ - return (imb_loadanim(mem, flags)); - } - } - } + return NULL; +} - ibuf = imb_loadpng((uchar *)mem, size, flags); - if (ibuf) return(ibuf); +ImBuf *IMB_loadifffile(int file, int flags) +{ + ImBuf *ibuf; + unsigned char *mem; + int size; - ibuf = imb_bmp_decode((uchar *)mem, size, flags); - if (ibuf) return(ibuf); + if(file == -1) return 0; - ibuf = imb_loadtarga((uchar *)mem, size, flags); - if (ibuf) return(ibuf); + size= BLI_filesize(file); - ibuf = imb_loaddpx((uchar *)mem, size, flags); - if (ibuf) return(ibuf); + mem= mmap(0, size, PROT_READ, MAP_SHARED, file, 0); + if(mem==(unsigned char*)-1) { + fprintf(stderr, "Couldn't get mapping\n"); + return 0; + } - ibuf = imb_loadcineon((uchar *)mem, size, flags); - if (ibuf) return(ibuf); - -#if defined(__APPLE__) && defined(IMBUF_COCOA) - ibuf = imb_cocoaLoadImage((uchar *)mem, size, flags); - if(ibuf) { - ibuf->ftype = TIF; - ibuf->profile = IB_PROFILE_SRGB; - return ibuf; - } -#else - if (G.have_libtiff) { - ibuf = imb_loadtiff((uchar *)mem, size, flags); - if (ibuf) return(ibuf); - } -#endif - - ibuf = imb_loadhdr((uchar*)mem, size, flags); - if (ibuf) return (ibuf); + ibuf= IMB_ibImageFromMemory(mem, size, flags); -#ifdef WITH_OPENEXR - ibuf = imb_load_openexr((uchar *)mem, size, flags); - if (ibuf) return (ibuf); -#endif + if(munmap(mem, size)) + fprintf(stderr, "Couldn't unmap file.\n"); -#ifdef WITH_OPENJPEG - ibuf = imb_jp2_decode((uchar *)mem, size, flags); - if (ibuf) return (ibuf); -#endif + return ibuf; +} -#ifdef WITH_DDS - ibuf = imb_load_dds((uchar *)mem, size, flags); - if (ibuf) return (ibuf); -#endif - -#ifdef WITH_QUICKTIME -#if defined(_WIN32) || defined (__APPLE__) - if(G.have_quicktime) { - ibuf = imb_quicktime_decode((uchar *)mem, size, flags); - if (ibuf) return(ibuf); - } -#endif -#endif +static void imb_cache_filename(char *filename, const char *name, int flags) +{ + /* read .tx instead if it exists and is not older */ + if(flags & IB_tilecache) { + BLI_strncpy(filename, name, IB_FILENAME_SIZE); + if(!BLI_replace_extension(filename, IB_FILENAME_SIZE, ".tx")) + return; - if (IB_verbose) fprintf(stderr, "Unknown fileformat\n"); + if(BLI_file_older(name, filename)) + return; } - - return (0); + + BLI_strncpy(filename, name, IB_FILENAME_SIZE); } +ImBuf *IMB_loadiffname(const char *name, int flags) +{ + ImBuf *ibuf; + int file, a; + char filename[IB_FILENAME_SIZE]; -struct ImBuf *IMB_loadiffmem(int *mem, int flags) { - int len,maxlen; - struct ImBuf *ibuf; + imb_cache_filename(filename, name, flags); - // IMB_loadiffmem shouldn't be used anymore in new development - // it's still here to be backwards compatible... + file = open(filename, O_BINARY|O_RDONLY); + if(file < 0) return 0; - maxlen= (GET_BIG_LONG(mem+1) + 1) & ~1; + ibuf= IMB_loadifffile(file, flags); - if (GET_ID(mem) == CAT){ - mem += 3; - maxlen -= 4; - while(maxlen > 0){ - if (GET_ID(mem) == FORM){ - len = ((GET_BIG_LONG(mem+1) + 1) & ~1) + 8; - if ((GET_ID(mem+2) == ILBM) || (GET_ID(mem+2) == ANIM)) break; - mem = (int *)((uchar *)mem +len); - maxlen -= len; - } else return(0); - } + if(ibuf) { + BLI_strncpy(ibuf->name, name, sizeof(ibuf->name)); + BLI_strncpy(ibuf->cachename, filename, sizeof(ibuf->cachename)); + for(a=1; amiptot; a++) + BLI_strncpy(ibuf->mipmap[a-1]->cachename, filename, sizeof(ibuf->cachename)); + if(flags & IB_fields) IMB_de_interlace(ibuf); } - if (maxlen > 0){ - if (GET_ID(mem) == FORM){ - if (GET_ID(mem+2) == ILBM){ - return (imb_loadamiga(mem, flags)); - } else if (GET_ID(mem+5) == ILBM){ /* animaties */ - return (imb_loadamiga(mem+3, flags)); - } else if (GET_ID(mem+2) == ANIM){ - return (imb_loadanim(mem, flags)); - } - } else if ((GS(mem) == IMAGIC) || (GSS(mem) == IMAGIC)){ - return (imb_loadiris((uchar *) mem,flags)); - } else if ((BIG_LONG(mem[0]) & 0xfffffff0) == 0xffd8ffe0) { - return (0); - } - } - - ibuf = imb_loadtarga((uchar *) mem,maxlen,flags); - if (ibuf) return(ibuf); + close(file); - if (IB_verbose) fprintf(stderr,"Unknown fileformat\n"); - return (0); + return ibuf; } -struct ImBuf *IMB_loadifffile(int file, int flags) { - struct ImBuf *ibuf; - int size, *mem; +ImBuf *IMB_testiffname(char *name, int flags) +{ + ImBuf *ibuf; + int file; + char filename[IB_FILENAME_SIZE]; - if (file == -1) return (0); + imb_cache_filename(filename, name, flags); - size = BLI_filesize(file); + file = open(filename,O_BINARY|O_RDONLY); + if(file < 0) return 0; - mem= (int *)mmap(0,size,PROT_READ,MAP_SHARED,file,0); - if (mem==(int *)-1){ - printf("Couldn't get mapping\n"); - return (0); + ibuf=IMB_loadifffile(file, flags|IB_test); + if(ibuf) { + BLI_strncpy(ibuf->name, name, sizeof(ibuf->name)); + BLI_strncpy(ibuf->cachename, filename, sizeof(ibuf->cachename)); } - ibuf = IMB_ibImageFromMemory(mem, size, flags); + close(file); - if (munmap( (void *) mem, size)){ - printf("Couldn't unmap file.\n"); - } - return(ibuf); + return ibuf; } +static void imb_loadtilefile(ImBuf *ibuf, int file, int tx, int ty, unsigned int *rect) +{ + ImFileType *type; + unsigned char *mem; + int size; -struct ImBuf *IMB_loadiffname(const char *naam, int flags) { - int file; - struct ImBuf *ibuf; - int buf[1]; - - file = open(naam, O_BINARY|O_RDONLY); - - if (file < 0) return (0); + if(file == -1) return; - ibuf= IMB_loadifffile(file, flags); + size= BLI_filesize(file); - if (ibuf == NULL) { - if (read(file, buf, 4) != 4) buf[0] = 0; - if ((BIG_LONG(buf[0]) & 0xfffffff0) == 0xffd8ffe0) - ibuf = imb_ibJpegImageFromFilename(naam, flags); + mem= mmap(0, size, PROT_READ, MAP_SHARED, file, 0); + if(mem==(unsigned char*)-1) { + fprintf(stderr, "Couldn't get memory mapping for %s\n", ibuf->cachename); + return; } - if (ibuf) { - strncpy(ibuf->name, naam, sizeof(ibuf->name)); - if (flags & IB_fields) IMB_de_interlace(ibuf); - } - close(file); - return(ibuf); + for(type=IMB_FILE_TYPES; type->is_a; type++) + if(type->load_tile && type->ftype(type, ibuf)) + type->load_tile(ibuf, mem, size, tx, ty, rect); + + if(munmap(mem, size)) + fprintf(stderr, "Couldn't unmap memory for %s.\n", ibuf->cachename); } -struct ImBuf *IMB_testiffname(char *naam,int flags) { +void imb_loadtile(ImBuf *ibuf, int tx, int ty, unsigned int *rect) +{ int file; - struct ImBuf *ibuf; - flags |= IB_test; - file = open(naam,O_BINARY|O_RDONLY); + file = open(ibuf->cachename, O_BINARY|O_RDONLY); + if(file < 0) return; - if (file < 0) return (0); + imb_loadtilefile(ibuf, file, tx, ty, rect); - ibuf=IMB_loadifffile(file,flags); - if (ibuf) { - strncpy(ibuf->name, naam, sizeof(ibuf->name)); - } close(file); - return(ibuf); } + diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index 3202413a494..53385743bb8 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -32,7 +32,6 @@ #include "BLI_blenlib.h" #include "imbuf.h" -#include "imbuf_patch.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" diff --git a/source/blender/imbuf/intern/rotate.c b/source/blender/imbuf/intern/rotate.c index 2369c83bbd3..e0e52bb7094 100644 --- a/source/blender/imbuf/intern/rotate.c +++ b/source/blender/imbuf/intern/rotate.c @@ -33,7 +33,6 @@ #include "BKE_utildefines.h" #include "imbuf.h" -#include "imbuf_patch.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index b3e25b52140..335e16402f9 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -32,7 +32,6 @@ #include "BLI_blenlib.h" #include "imbuf.h" -#include "imbuf_patch.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" @@ -347,142 +346,6 @@ struct ImBuf *IMB_onehalf(struct ImBuf *ibuf1) } - -struct ImBuf *IMB_onethird(struct ImBuf *ibuf1) -{ - struct ImBuf *ibuf2; - uchar *p1,*p2,*p3,*dest; - float *p1f, *p2f, *p3f, *destf; - int do_rect, do_float; - short a,r,g,b,x,y,i; - float af,rf,gf,bf; - - p2= p3= NULL; - p2f= p3f= NULL; - if (ibuf1==NULL) return (0); - if (ibuf1->rect==NULL && ibuf1->rect_float==NULL) return (0); - - do_rect= (ibuf1->rect != NULL); - do_float= (ibuf1->rect_float != NULL); - - ibuf2=IMB_allocImBuf((ibuf1->x)/3, (ibuf1->y)/3, ibuf1->depth, ibuf1->flags, 0); - if (ibuf2==NULL) return (0); - - p1f = ibuf1->rect_float; - destf = ibuf2->rect_float; - p1 = (uchar *) ibuf1->rect; - dest=(uchar *) ibuf2->rect; - - for(y=ibuf2->y;y>0;y--){ - if (do_rect) { - p2 = p1 + (ibuf1->x << 2); - p3 = p2 + (ibuf1->x << 2); - } - if (do_float) { - p2f = p1f + (ibuf1->x <<2); - p3f = p2f + (ibuf1->x <<2); - } - for(x=ibuf2->x;x>0;x--){ - a=r=g=b=0; - af=rf=gf=bf=0; - for (i=3;i>0;i--){ - if (do_rect) { - a += *(p1++) + *(p2++) + *(p3++); - b += *(p1++) + *(p2++) + *(p3++); - g += *(p1++) + *(p2++) + *(p3++); - r += *(p1++) + *(p2++) + *(p3++); - } - if (do_float) { - af += *(p1f++) + *(p2f++) + *(p3f++); - bf += *(p1f++) + *(p2f++) + *(p3f++); - gf += *(p1f++) + *(p2f++) + *(p3f++); - rf += *(p1f++) + *(p2f++) + *(p3f++); - } - } - if (do_rect) { - *(dest++) = a/9; - *(dest++) = b/9; - *(dest++) = g/9; - *(dest++) = r/9; - } - if (do_float) { - *(destf++) = af/9.0f; - *(destf++) = bf/9.0f; - *(destf++) = gf/9.0f; - *(destf++) = rf/9.0f; - } - } - if (do_rect) p1=p3; - if (do_float) p1f = p3f; - } - return (ibuf2); -} - - -struct ImBuf *IMB_halflace(struct ImBuf *ibuf1) -{ - struct ImBuf *ibuf2; - uchar *p1,*p2,*dest; - float *p1f,*p2f,*destf; - short a,r,g,b,x,y,i; - float af,rf,gf,bf; - int do_rect, do_float; - - p2= NULL; - p2f= NULL; - if (ibuf1==NULL) return (0); - if (ibuf1->rect==NULL && ibuf1->rect_float==NULL) return (0); - - do_rect= (ibuf1->rect != NULL); - do_float= (ibuf1->rect_float != NULL); - - ibuf2=IMB_allocImBuf((ibuf1->x)/4, (ibuf1->y)/2, ibuf1->depth, ibuf1->flags, 0); - if (ibuf2==NULL) return (0); - - p1f = ibuf1->rect_float; - destf= ibuf2->rect_float; - p1 = (uchar *) ibuf1->rect; - dest=(uchar *) ibuf2->rect; - - for(y= ibuf2->y / 2 ; y>0;y--){ - if (do_rect) p2 = p1 + (ibuf1->x << 3); - if (do_float) p2f = p1f + (ibuf1->x << 3); - for(x = 2 * ibuf2->x;x>0;x--){ - a=r=g=b=0; - af=rf=gf=bf=0; - for (i=4;i>0;i--){ - if (do_rect) { - a += *(p1++) + *(p2++); - b += *(p1++) + *(p2++); - g += *(p1++) + *(p2++); - r += *(p1++) + *(p2++); - } - if (do_float) { - af += *(p1f++) + *(p2f++); - bf += *(p1f++) + *(p2f++); - gf += *(p1f++) + *(p2f++); - rf += *(p1f++) + *(p2f++); - } - } - if (do_rect) { - *(dest++) = a >> 3; - *(dest++) = b >> 3; - *(dest++) = g >> 3; - *(dest++) = r >> 3; - } - if (do_float) { - *(destf++) = 0.125f*af; - *(destf++) = 0.125f*bf; - *(destf++) = 0.125f*gf; - *(destf++) = 0.125f*rf; - } - } - if (do_rect) p1 = p2; - if (do_float) p1f = p2f; - } - return (ibuf2); -} - /* q_scale_linear_interpolation helper functions */ static void enlarge_picture_byte( @@ -1687,55 +1550,3 @@ struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, short newx, short newy) return(ibuf); } - -static struct ImBuf *generic_fieldscale(struct ImBuf *ibuf, short newx, short newy, struct ImBuf *(*scalefunc)(ImBuf *, short, short) ) -{ - struct ImBuf *sbuf1, *sbuf2; - - sbuf1 = IMB_allocImBuf(ibuf->x, ibuf->y / 2, ibuf->depth, ibuf->flags, 0); - sbuf2 = IMB_allocImBuf(ibuf->x, ibuf->y / 2, ibuf->depth, ibuf->flags, 0); - - ibuf->x *= 2; - - /* more args needed, 0 assumed... (nzc) */ - IMB_rectcpy(sbuf1, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y); - IMB_rectcpy(sbuf2, ibuf, 0, 0, sbuf2->x, 0, ibuf->x, ibuf->y); - - imb_freerectImBuf(ibuf); - imb_freerectfloatImBuf(ibuf); - - ibuf->x = newx; - ibuf->y = newy; - - imb_addrectImBuf(ibuf); - if(ibuf->flags & IB_rectfloat) - imb_addrectfloatImBuf(ibuf); - - scalefunc(sbuf1, newx, newy / 2); - scalefunc(sbuf2, newx, newy / 2); - - ibuf->x *= 2; - - /* more args needed, 0 assumed... (nzc) */ - IMB_rectcpy(ibuf, sbuf1, 0, 0, 0, 0, sbuf1->x, sbuf1->y); - IMB_rectcpy(ibuf, sbuf2, sbuf2->x, 0, 0, 0, sbuf2->x, sbuf2->y); - - ibuf->x /= 2; - - IMB_freeImBuf(sbuf1); - IMB_freeImBuf(sbuf2); - - return(ibuf); -} - - -struct ImBuf *IMB_scalefastfieldImBuf(struct ImBuf *ibuf, short newx, short newy) -{ - return(generic_fieldscale(ibuf, newx, newy, IMB_scalefastImBuf)); -} - -struct ImBuf *IMB_scalefieldImBuf(struct ImBuf *ibuf, short newx, short newy) -{ - return(generic_fieldscale(ibuf, newx, newy, IMB_scaleImBuf)); -} - diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c index 092c52d427b..3c14189a292 100644 --- a/source/blender/imbuf/intern/targa.c +++ b/source/blender/imbuf/intern/targa.c @@ -33,14 +33,12 @@ #include "BLI_blenlib.h" #include "imbuf.h" -#include "imbuf_patch.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" #include "IMB_allocimbuf.h" -#include "IMB_cmap.h" -#include "IMB_targa.h" +#include "IMB_filetype.h" /* this one is only def-ed once, strangely... related to GS? */ @@ -234,11 +232,10 @@ static int dumptarga(struct ImBuf * ibuf, FILE * file) } -short imb_savetarga(struct ImBuf * ibuf, char *name, int flags) +int imb_savetarga(struct ImBuf * ibuf, char *name, int flags) { char buf[20]; FILE *fildes; - int i; short ok = 0; if (ibuf == 0) return (0); @@ -249,19 +246,7 @@ short imb_savetarga(struct ImBuf * ibuf, char *name, int flags) /* buf[0] = 0; length string */ buf[16] = (ibuf->depth + 0x7 ) & ~0x7; - if (ibuf->cmap) { - buf[1] = 1; - buf[2] = 9; - buf[3] = ibuf->mincol & 0xff; - buf[4] = ibuf->mincol >> 8; - buf[5] = ibuf->maxcol & 0xff; - buf[6] = ibuf->maxcol >> 8; - buf[7] = 24; - if ((flags & IB_ttob) == 0) { - IMB_flipy(ibuf); - buf[17] = 0x20; - } - } else if (ibuf->depth > 8 ){ + if (ibuf->depth > 8 ){ buf[2] = 10; } else{ buf[2] = 11; @@ -269,18 +254,16 @@ short imb_savetarga(struct ImBuf * ibuf, char *name, int flags) if (ibuf->ftype == RAWTGA) buf[2] &= ~8; - buf[8] = ibuf->xorig & 0xff; - buf[9] = ibuf->xorig >> 8; - buf[10] = ibuf->yorig & 0xff; - buf[11] = ibuf->yorig >> 8; + buf[8] = 0; + buf[9] = 0; + buf[10] = 0; + buf[11] = 0; buf[12] = ibuf->x & 0xff; buf[13] = ibuf->x >> 8; buf[14] = ibuf->y & 0xff; buf[15] = ibuf->y >> 8; - if (flags & IB_ttob) buf[17] ^= 0x20; - /* Don't forget to indicate that your 32 bit * targa uses 8 bits for the alpha channel! */ if (ibuf->depth==32) { @@ -294,17 +277,6 @@ short imb_savetarga(struct ImBuf * ibuf, char *name, int flags) return (0); } - if (ibuf->cmap){ - for (i = 0 ; imaxcol ; i++){ - if (fwrite(((uchar *)(ibuf->cmap + i)) + 1,1,3,fildes) != 3) { - fclose(fildes); - return (0); - } - } - } - - if (ibuf->cmap && (flags & IB_cmap) == 0) IMB_converttocmap(ibuf); - if (ibuf->ftype == RAWTGA) { ok = dumptarga(ibuf, fildes); } else { @@ -365,7 +337,7 @@ static int checktarga(TARGA *tga, unsigned char *mem) return(1); } -int imb_is_a_targa(void *buf) { +int imb_is_a_targa(unsigned char *buf) { TARGA tga; return checktarga(&tga, buf); @@ -559,7 +531,7 @@ struct ImBuf *imb_loadtarga(unsigned char *mem, int mem_size, int flags) TARGA tga; struct ImBuf * ibuf; int col, count, size; - unsigned int * rect; + unsigned int *rect, *cmap= NULL, mincol= 0, maxcol= 0; uchar * cp = (uchar *) &col; if (checktarga(&tga,mem) == 0) return(0); @@ -570,19 +542,18 @@ struct ImBuf *imb_loadtarga(unsigned char *mem, int mem_size, int flags) if (ibuf == 0) return(0); ibuf->ftype = TGA; ibuf->profile = IB_PROFILE_SRGB; - ibuf->xorig = tga.xorig; - ibuf->yorig = tga.yorig; mem = mem + 18 + tga.numid; cp[0] = 0xff; cp[1] = cp[2] = 0; if (tga.mapsize){ - ibuf->mincol = tga.maporig; - ibuf->maxcol = tga.mapsize; - imb_addcmapImBuf(ibuf); - ibuf->cbits = 8; - for (count = 0 ; count < ibuf->maxcol ; count ++) { + /* load color map */ + mincol = tga.maporig; + maxcol = tga.mapsize; + cmap = MEM_callocN(sizeof(unsigned int)*maxcol, "targa cmap"); + + for (count = 0 ; count < maxcol ; count ++) { switch (tga.mapbits >> 3) { case 4: cp[0] = mem[3]; @@ -606,21 +577,24 @@ struct ImBuf *imb_loadtarga(unsigned char *mem, int mem_size, int flags) col = *mem++; break; } - ibuf->cmap[count] = col; + cmap[count] = col; } size = 0; - for (col = ibuf->maxcol - 1; col > 0; col >>= 1) size++; + for (col = maxcol - 1; col > 0; col >>= 1) size++; ibuf->depth = size; if (tga.mapbits != 32) { /* set alpha bits */ - ibuf->cmap[0] &= BIG_LONG(0x00ffffff); + cmap[0] &= BIG_LONG(0x00ffffff); } } if (flags & IB_test) return (ibuf); - if (tga.imgtyp != 1 && tga.imgtyp != 9) IMB_freecmapImBuf(ibuf); /* happens sometimes (beuh) */ + if (tga.imgtyp != 1 && tga.imgtyp != 9) { /* happens sometimes (beuh) */ + MEM_freeN(cmap); + cmap= NULL; + } switch(tga.imgtyp){ case 1: @@ -641,11 +615,18 @@ struct ImBuf *imb_loadtarga(unsigned char *mem, int mem_size, int flags) break; } - if (ibuf->cmap){ - if ((flags & IB_cmap) == 0) IMB_applycmap(ibuf); + if(cmap) { + /* apply color map */ + rect = ibuf->rect; + for(size = ibuf->x * ibuf->y; size>0; --size, ++rect) { + col = *rect; + if (col >= 0 && col < maxcol) *rect = cmap[col]; + } + + MEM_freeN(cmap); } - if (tga.pixsize == 16 && ibuf->cmap == 0){ + if (tga.pixsize == 16) { rect = ibuf->rect; for (size = ibuf->x * ibuf->y; size > 0; --size, ++rect){ col = *rect; @@ -679,13 +660,10 @@ struct ImBuf *imb_loadtarga(unsigned char *mem, int mem_size, int flags) } } - if (flags & IB_ttob) tga.imgdes ^= 0x20; if (tga.imgdes & 0x20) IMB_flipy(ibuf); - if (ibuf) { - if (ibuf->rect && (flags & IB_cmap)==0) - IMB_convert_rgba_to_abgr(ibuf); - } + if (ibuf && ibuf->rect) + IMB_convert_rgba_to_abgr(ibuf); return(ibuf); } diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c index 5e0504155dc..45fbf49dbbd 100644 --- a/source/blender/imbuf/intern/thumbs.c +++ b/source/blender/imbuf/intern/thumbs.c @@ -37,7 +37,7 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" #include "IMB_thumbs.h" -#include "IMB_imginfo.h" +#include "IMB_metadata.h" #include "md5.h" @@ -282,11 +282,11 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source) return NULL; } if (size == THB_FAIL) { - img = IMB_allocImBuf(0,0,32, IB_rect | IB_imginfo, 0); + img = IMB_allocImBuf(0,0,32, IB_rect | IB_metadata, 0); if (!img) return 0; } else { if (THB_SOURCE_IMAGE == source) { - img = IMB_loadiffname(path, IB_rect | IB_imginfo); + img = IMB_loadiffname(path, IB_rect | IB_metadata); if (img != NULL) { stat(path, &info); sprintf(mtime, "%ld", info.st_mtime); @@ -295,7 +295,7 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source) } } else if (THB_SOURCE_MOVIE == source) { struct anim * anim = NULL; - anim = IMB_open_anim(path, IB_rect | IB_imginfo); + anim = IMB_open_anim(path, IB_rect | IB_metadata); if (anim != NULL) { img = IMB_anim_absolute(anim, 0); if (img == NULL) { @@ -325,17 +325,17 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source) IMB_scaleImBuf(img, ex, ey); } sprintf(desc, "Thumbnail for %s", uri); - IMB_imginfo_change_field(img, "Description", desc); - IMB_imginfo_change_field(img, "Software", "Blender"); - IMB_imginfo_change_field(img, "Thumb::URI", uri); - IMB_imginfo_change_field(img, "Thumb::MTime", mtime); + IMB_metadata_change_field(img, "Description", desc); + IMB_metadata_change_field(img, "Software", "Blender"); + IMB_metadata_change_field(img, "Thumb::URI", uri); + IMB_metadata_change_field(img, "Thumb::MTime", mtime); if (THB_SOURCE_IMAGE == source) { - IMB_imginfo_change_field(img, "Thumb::Image::Width", cwidth); - IMB_imginfo_change_field(img, "Thumb::Image::Height", cheight); + IMB_metadata_change_field(img, "Thumb::Image::Width", cwidth); + IMB_metadata_change_field(img, "Thumb::Image::Height", cheight); } img->ftype = PNG; img->depth = 32; - if (IMB_saveiff(img, temp, IB_rect | IB_imginfo)) { + if (IMB_saveiff(img, temp, IB_rect | IB_metadata)) { #ifndef WIN32 chmod(temp, S_IRUSR | S_IWUSR); #endif @@ -358,7 +358,7 @@ ImBuf* IMB_thumb_read(const char* path, ThumbSize size) return NULL; } if (thumbpath_from_uri(uri, thumb, size)) { - img = IMB_loadiffname(thumb, IB_rect | IB_imginfo); + img = IMB_loadiffname(thumb, IB_rect | IB_metadata); } return img; @@ -409,10 +409,10 @@ ImBuf* IMB_thumb_manage(const char* path, ThumbSize size, ThumbSource source) if (strncmp(path, thumb, strlen(thumb)) == 0) { img = IMB_loadiffname(path, IB_rect); } else { - img = IMB_loadiffname(thumb, IB_rect | IB_imginfo); + img = IMB_loadiffname(thumb, IB_rect | IB_metadata); if (img) { char mtime[40]; - if (!IMB_imginfo_get_field(img, "Thumb::MTime", mtime, 40)) { + if (!IMB_metadata_get_field(img, "Thumb::MTime", mtime, 40)) { /* illegal thumb, forget it! */ IMB_freeImBuf(img); img = 0; diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index dd18c77c5c6..e7309eefb56 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -43,16 +43,17 @@ #include #include "imbuf.h" -#include "imbuf_patch.h" #include "BKE_global.h" +#include "BLI_string.h" + #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" #include "IMB_allocimbuf.h" -#include "IMB_cmap.h" -#include "IMB_tiff.h" +#include "IMB_filetype.h" +#include "IMB_filter.h" #include "dynlibtiff.h" @@ -72,12 +73,12 @@ static void imb_tiff_DummyUnmapProc(thandle_t fd, tdata_t base, toff_t size); /* Structure for in-memory TIFF file. */ -struct ImbTIFFMemFile { +typedef struct ImbTIFFMemFile { unsigned char *mem; /* Location of first byte of TIFF file. */ toff_t offset; /* Current offset within the file. */ tsize_t size; /* Size of the TIFF file. */ -}; -#define IMB_TIFF_GET_MEMFILE(x) ((struct ImbTIFFMemFile*)(x)); +} ImbTIFFMemFile; +#define IMB_TIFF_GET_MEMFILE(x) ((ImbTIFFMemFile*)(x)); @@ -108,28 +109,28 @@ static int imb_tiff_DummyMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) static tsize_t imb_tiff_ReadProc(thandle_t handle, tdata_t data, tsize_t n) { tsize_t nRemaining, nCopy; - struct ImbTIFFMemFile* mfile; + ImbTIFFMemFile* mfile; void *srcAddr; /* get the pointer to the in-memory file */ mfile = IMB_TIFF_GET_MEMFILE(handle); - if (!mfile || !mfile->mem) { + if(!mfile || !mfile->mem) { fprintf(stderr, "imb_tiff_ReadProc: !mfile || !mfile->mem!\n"); return 0; } /* find the actual number of bytes to read (copy) */ nCopy = n; - if ((tsize_t)mfile->offset >= mfile->size) + if((tsize_t)mfile->offset >= mfile->size) nRemaining = 0; else nRemaining = mfile->size - mfile->offset; - if (nCopy > nRemaining) + if(nCopy > nRemaining) nCopy = nRemaining; /* on EOF, return immediately and read (copy) nothing */ - if (nCopy <= 0) + if(nCopy <= 0) return (0); /* all set -> do the read (copy) */ @@ -171,12 +172,12 @@ static tsize_t imb_tiff_WriteProc(thandle_t handle, tdata_t data, tsize_t n) */ static toff_t imb_tiff_SeekProc(thandle_t handle, toff_t ofs, int whence) { - struct ImbTIFFMemFile *mfile; + ImbTIFFMemFile *mfile; toff_t new_offset; /* get the pointer to the in-memory file */ mfile = IMB_TIFF_GET_MEMFILE(handle); - if (!mfile || !mfile->mem) { + if(!mfile || !mfile->mem) { fprintf(stderr, "imb_tiff_SeekProc: !mfile || !mfile->mem!\n"); return (-1); } @@ -218,11 +219,11 @@ static toff_t imb_tiff_SeekProc(thandle_t handle, toff_t ofs, int whence) */ static int imb_tiff_CloseProc(thandle_t handle) { - struct ImbTIFFMemFile *mfile; + ImbTIFFMemFile *mfile; /* get the pointer to the in-memory file */ mfile = IMB_TIFF_GET_MEMFILE(handle); - if (!mfile || !mfile->mem) { + if(!mfile || !mfile->mem) { fprintf(stderr,"imb_tiff_CloseProc: !mfile || !mfile->mem!\n"); return (0); } @@ -244,11 +245,11 @@ static int imb_tiff_CloseProc(thandle_t handle) */ static toff_t imb_tiff_SizeProc(thandle_t handle) { - struct ImbTIFFMemFile* mfile; + ImbTIFFMemFile* mfile; /* get the pointer to the in-memory file */ mfile = IMB_TIFF_GET_MEMFILE(handle); - if (!mfile || !mfile->mem) { + if(!mfile || !mfile->mem) { fprintf(stderr,"imb_tiff_SizeProc: !mfile || !mfile->mem!\n"); return (0); } @@ -257,14 +258,23 @@ static toff_t imb_tiff_SizeProc(thandle_t handle) return (toff_t)(mfile->size); } +static TIFF *imb_tiff_client_open(ImbTIFFMemFile *memFile, unsigned char *mem, int size) +{ + /* open the TIFF client layer interface to the in-memory file */ + memFile->mem = mem; + memFile->offset = 0; + memFile->size = size; + return libtiff_TIFFClientOpen("(Blender TIFF Interface Layer)", + "r", (thandle_t)(memFile), + imb_tiff_ReadProc, imb_tiff_WriteProc, + imb_tiff_SeekProc, imb_tiff_CloseProc, + imb_tiff_SizeProc, imb_tiff_DummyMapProc, imb_tiff_DummyUnmapProc); +} /** * Checks whether a given memory buffer contains a TIFF file. * - * FIXME: Possible memory leak if mem is less than IMB_TIFF_NCB bytes long. - * However, changing this will require up-stream modifications. - * * This method uses the format identifiers from: * http://www.faqs.org/faqs/graphics/fileformats-faq/part4/section-9.html * The first four bytes of big-endian and little-endian TIFF files @@ -278,7 +288,7 @@ static toff_t imb_tiff_SizeProc(thandle_t handle) * hence my manual comparison. - Jonathan Merritt (lancelet) 4th Sept 2005. */ #define IMB_TIFF_NCB 4 /* number of comparison bytes used */ -int imb_is_a_tiff(void *mem) +int imb_is_a_tiff(unsigned char *mem) { char big_endian[IMB_TIFF_NCB] = { 0x4d, 0x4d, 0x00, 0x2a }; char lil_endian[IMB_TIFF_NCB] = { 0x49, 0x49, 0x2a, 0x00 }; @@ -287,7 +297,31 @@ int imb_is_a_tiff(void *mem) (memcmp(lil_endian, mem, IMB_TIFF_NCB) == 0) ); } +static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul) +{ + ImBuf *tmpibuf; + int success; + + tmpibuf= IMB_allocImBuf(ibuf->x, ibuf->y, 32, IB_rect, 0); + success= libtiff_TIFFReadRGBAImage(image, ibuf->x, ibuf->y, tmpibuf->rect, 0); + + if(ENDIAN_ORDER == B_ENDIAN) + IMB_convert_rgba_to_abgr(tmpibuf); + if(premul) { + IMB_premultiply_alpha(tmpibuf); + ibuf->flags |= IB_premul; + } + + /* assign rect last */ + ibuf->rect= tmpibuf->rect; + ibuf->mall |= IB_rect; + ibuf->flags |= IB_rect; + tmpibuf->mall &= ~IB_rect; + IMB_freeImBuf(tmpibuf); + + return success; +} /** * Loads a TIFF file. @@ -303,52 +337,42 @@ int imb_is_a_tiff(void *mem) * * @return: A newly allocated ImBuf structure if successful, otherwise NULL. */ -struct ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags) +ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags) { TIFF *image = NULL; - struct ImBuf *ibuf = NULL; - struct ImbTIFFMemFile memFile; + ImBuf *ibuf = NULL, *hbuf; + ImbTIFFMemFile memFile; uint32 width, height; - int bytesperpixel, bitspersample; - int success; - unsigned int pixel_i, byte_i; - uint32 *raster = NULL; - uint32 pixel; - unsigned char *to = NULL; + char *format = NULL; + int level; - memFile.mem = mem; - memFile.offset = 0; - memFile.size = size; + if(!G.have_libtiff) + return NULL; /* check whether or not we have a TIFF file */ - if (size < IMB_TIFF_NCB) { + if(size < IMB_TIFF_NCB) { fprintf(stderr, "imb_loadtiff: size < IMB_TIFF_NCB\n"); return NULL; } - if (imb_is_a_tiff(mem) == 0) + if(imb_is_a_tiff(mem) == 0) return NULL; - /* open the TIFF client layer interface to the in-memory file */ - image = libtiff_TIFFClientOpen("(Blender TIFF Interface Layer)", - "r", (thandle_t)(&memFile), - imb_tiff_ReadProc, imb_tiff_WriteProc, - imb_tiff_SeekProc, imb_tiff_CloseProc, - imb_tiff_SizeProc, imb_tiff_DummyMapProc, imb_tiff_DummyUnmapProc); - if (image == NULL) { + image = imb_tiff_client_open(&memFile, mem, size); + + if(image == NULL) { printf("imb_loadtiff: could not open TIFF IO layer.\n"); return NULL; } /* allocate the image buffer */ - bytesperpixel = 4; /* 1 byte per channel, 4 channels */ libtiff_TIFFGetField(image, TIFFTAG_IMAGEWIDTH, &width); libtiff_TIFFGetField(image, TIFFTAG_IMAGELENGTH, &height); - libtiff_TIFFGetField(image, TIFFTAG_BITSPERSAMPLE, &bitspersample); - ibuf = IMB_allocImBuf(width, height, 8*bytesperpixel, 0, 0); - if (ibuf) { + ibuf = IMB_allocImBuf(width, height, 32, 0, 0); + if(ibuf) { ibuf->ftype = TIF; ibuf->profile = IB_PROFILE_SRGB; - } else { + } + else { fprintf(stderr, "imb_loadtiff: could not allocate memory for TIFF " \ "image.\n"); @@ -356,65 +380,109 @@ struct ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags) return NULL; } - /* read in the image data */ - if (!(flags & IB_test)) { + /* if testing, we're done */ + if(flags & IB_test) { + libtiff_TIFFClose(image); + return ibuf; + } - /* allocate memory for the ibuf->rect */ - imb_addrectImBuf(ibuf); + /* detect if we are reading a tiled/mipmapped texture, in that case + we don't read pixels but leave it to the cache to load tiles */ + if(flags & IB_tilecache) { + format= NULL; + libtiff_TIFFGetField(image, TIFFTAG_PIXAR_TEXTUREFORMAT, &format); - /* perform actual read */ - raster = (uint32*)libtiff__TIFFmalloc( - width*height * sizeof(uint32)); - if (raster == NULL) { - libtiff_TIFFClose(image); - return NULL; - } - success = libtiff_TIFFReadRGBAImage( - image, width, height, raster, 0); - if (!success) { - fprintf(stderr, - "imb_loadtiff: This TIFF format is not " - "currently supported by Blender.\n"); - libtiff__TIFFfree(raster); - libtiff_TIFFClose(image); - return NULL; - } + if(format && strcmp(format, "Plain Texture")==0 && libtiff_TIFFIsTiled(image)) { + int numlevel = libtiff_TIFFNumberOfDirectories(image); - /* copy raster to ibuf->rect; we do a fast copy if possible, - * otherwise revert to a slower component-wise copy */ - if (sizeof(unsigned int) == sizeof(uint32)) { - memcpy(ibuf->rect, raster, - width*height*sizeof(uint32)); - } else { - /* this may not be entirely necessary, but is put here - * in case sizeof(unsigned int) is not a 32-bit - * quantity */ - fprintf(stderr, - "imb_loadtiff: using (slower) component-wise " - "buffer copy.\n"); - to = (unsigned char*)ibuf->rect; - for (pixel_i=0; pixel_i < width*height; pixel_i++) - { - byte_i = sizeof(unsigned int)*pixel_i; - pixel = raster[pixel_i]; - - to[byte_i++] = (unsigned char)TIFFGetR(pixel); - to[byte_i++] = (unsigned char)TIFFGetG(pixel); - to[byte_i++] = (unsigned char)TIFFGetB(pixel); - to[byte_i++] = (unsigned char)TIFFGetA(pixel); + /* create empty mipmap levels in advance */ + for(level=0; level 0) { + width= (width > 1)? width/2: 1; + height= (height > 1)? height/2: 1; + + hbuf= IMB_allocImBuf(width, height, 32, 0, 0); + hbuf->miplevel= level; + hbuf->flags |= IB_tilecache; + hbuf->ftype= ibuf->ftype; + ibuf->mipmap[level-1] = hbuf; + + if(flags & IB_premul) + hbuf->flags |= IB_premul; + } + else + hbuf= ibuf; + + libtiff_TIFFGetField(image, TIFFTAG_TILEWIDTH, &hbuf->tilex); + libtiff_TIFFGetField(image, TIFFTAG_TILELENGTH, &hbuf->tiley); + + hbuf->xtiles= ceil(hbuf->x/(float)hbuf->tilex); + hbuf->ytiles= ceil(hbuf->y/(float)hbuf->tiley); + + imb_addtilesImBuf(hbuf); + + ibuf->miptot++; } } + } - libtiff__TIFFfree(raster); + /* read pixels */ + if(!(ibuf->flags & IB_tilecache) && !imb_read_tiff_pixels(ibuf, image, 0)) { + fprintf(stderr, "imb_loadtiff: Failed to read tiff image.\n"); + libtiff_TIFFClose(image); + return NULL; } /* close the client layer interface to the in-memory file */ libtiff_TIFFClose(image); - if (ENDIAN_ORDER == B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf); - /* return successfully */ - return (ibuf); + return ibuf; +} + +void imb_loadtiletiff(ImBuf *ibuf, unsigned char *mem, int size, int tx, int ty, unsigned int *rect) +{ + TIFF *image = NULL; + uint32 width, height; + ImbTIFFMemFile memFile; + + image = imb_tiff_client_open(&memFile, mem, size); + + if(image == NULL) { + printf("imb_loadtiff: could not open TIFF IO layer for loading mipmap level.\n"); + return; + } + + if(libtiff_TIFFSetDirectory(image, ibuf->miplevel)) { + /* allocate the image buffer */ + libtiff_TIFFGetField(image, TIFFTAG_IMAGEWIDTH, &width); + libtiff_TIFFGetField(image, TIFFTAG_IMAGELENGTH, &height); + + if(width == ibuf->x && height == ibuf->y) { + if(rect) { + /* tiff pixels are bottom to top, tiles are top to bottom */ + if(libtiff_TIFFReadRGBATile(image, tx*ibuf->tilex, (ibuf->ytiles - 1 - ty)*ibuf->tiley, rect) == 1) { + if(ibuf->tiley > ibuf->y) + memmove(rect, rect+ibuf->tilex*(ibuf->tiley - ibuf->y), sizeof(int)*ibuf->tilex*ibuf->y); + + if(ibuf->flags & IB_premul) + IMB_premultiply_rect(rect, 32, ibuf->tilex, ibuf->tiley); + } + else + printf("imb_loadtiff: failed to read tiff tile at mipmap level %d\n", ibuf->miplevel); + } + } + else + printf("imb_loadtiff: mipmap level %d has unexpected size %dx%d instead of %dx%d\n", ibuf->miplevel, width, height, ibuf->x, ibuf->y); + } + else + printf("imb_loadtiff: could not find mipmap level %d\n", ibuf->miplevel); + + /* close the client layer interface to the in-memory file */ + libtiff_TIFFClose(image); } /** @@ -435,7 +503,7 @@ struct ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags) #define FTOUSHORT(val) ((val >= 1.0f-0.5f/65535)? 65535: (val <= 0.0f)? 0: (unsigned short)(val*65535.0f + 0.5f)) -short imb_savetiff(struct ImBuf *ibuf, char *name, int flags) +int imb_savetiff(ImBuf *ibuf, char *name, int flags) { TIFF *image = NULL; uint16 samplesperpixel, bitspersample; @@ -446,12 +514,17 @@ short imb_savetiff(struct ImBuf *ibuf, char *name, int flags) float *fromf = NULL; int x, y, from_i, to_i, i; int extraSampleTypes[1] = { EXTRASAMPLE_ASSOCALPHA }; + + if(!G.have_libtiff) { + fprintf(stderr, "imb_savetiff: no tiff library available.\n"); + return (0); + } /* check for a valid number of bytes per pixel. Like the PNG writer, * the TIFF writer supports 1, 3 or 4 bytes per pixel, corresponding * to gray, RGB, RGBA respectively. */ samplesperpixel = (uint16)((ibuf->depth + 7) >> 3); - if ((samplesperpixel > 4) || (samplesperpixel == 2)) { + if((samplesperpixel > 4) || (samplesperpixel == 2)) { fprintf(stderr, "imb_savetiff: unsupported number of bytes per " "pixel: %d\n", samplesperpixel); @@ -464,17 +537,18 @@ short imb_savetiff(struct ImBuf *ibuf, char *name, int flags) bitspersample = 8; /* open TIFF file for writing */ - if (flags & IB_mem) { + if(flags & IB_mem) { /* bork at the creation of a TIFF in memory */ fprintf(stderr, "imb_savetiff: creation of in-memory TIFF files is " "not yet supported.\n"); return (0); - } else { + } + else { /* create image as a file */ image = libtiff_TIFFOpen(name, "w"); } - if (image == NULL) { + if(image == NULL) { fprintf(stderr, "imb_savetiff: could not open TIFF for writing.\n"); return (0); @@ -489,7 +563,7 @@ short imb_savetiff(struct ImBuf *ibuf, char *name, int flags) pixels = (unsigned char*)libtiff__TIFFmalloc(npixels * samplesperpixel * sizeof(unsigned char)); - if (pixels == NULL && pixels16 == NULL) { + if(pixels == NULL && pixels16 == NULL) { fprintf(stderr, "imb_savetiff: could not allocate pixels array.\n"); libtiff_TIFFClose(image); @@ -529,17 +603,17 @@ short imb_savetiff(struct ImBuf *ibuf, char *name, int flags) } /* copy pixel data. While copying, we flip the image vertically. */ - for (x = 0; x < ibuf->x; x++) { - for (y = 0; y < ibuf->y; y++) { + for(x = 0; x < ibuf->x; x++) { + for(y = 0; y < ibuf->y; y++) { from_i = 4*(y*ibuf->x+x); to_i = samplesperpixel*((ibuf->y-y-1)*ibuf->x+x); if(pixels16) { - for (i = 0; i < samplesperpixel; i++, to_i++, from_i++) + for(i = 0; i < samplesperpixel; i++, to_i++, from_i++) to16[to_i] = FTOUSHORT(fromf[from_i]); } else { - for (i = 0; i < samplesperpixel; i++, to_i++, from_i++) + for(i = 0; i < samplesperpixel; i++, to_i++, from_i++) to[to_i] = from[from_i]; } } @@ -555,7 +629,7 @@ short imb_savetiff(struct ImBuf *ibuf, char *name, int flags) libtiff_TIFFSetField(image, TIFFTAG_XRESOLUTION, 150.0); libtiff_TIFFSetField(image, TIFFTAG_YRESOLUTION, 150.0); libtiff_TIFFSetField(image, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); - if (libtiff_TIFFWriteEncodedStrip(image, 0, + if(libtiff_TIFFWriteEncodedStrip(image, 0, (bitspersample == 16)? (unsigned char*)pixels16: pixels, ibuf->x*ibuf->y*samplesperpixel*bitspersample/8) == -1) { fprintf(stderr, diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index b1ca414434f..aff05b4eaff 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -42,36 +42,16 @@ #include "BKE_global.h" #include "imbuf.h" -#include "imbuf_patch.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" - -#include "IMB_targa.h" -#include "IMB_png.h" - -#ifdef WITH_DDS -#include "dds/dds_api.h" -#endif - -#include "IMB_bmp.h" -#include "IMB_tiff.h" -#include "IMB_radiance_hdr.h" -#include "IMB_dpxcineon.h" +#include "IMB_filetype.h" #include "IMB_anim.h" -#ifdef WITH_OPENEXR -#include "openexr/openexr_api.h" -#endif - #ifdef WITH_QUICKTIME #include "quicktime_import.h" #endif -#ifdef WITH_OPENJPEG -#include "IMB_jp2.h" -#endif - #ifdef WITH_FFMPEG #include #include @@ -88,90 +68,46 @@ #define UTIL_DEBUG 0 -/* from misc_util: flip the bytes from x */ -#define GS(x) (((unsigned char *)(x))[0] << 8 | ((unsigned char *)(x))[1]) - -/* this one is only def-ed once, strangely... */ -#define GSS(x) (((uchar *)(x))[1] << 8 | ((uchar *)(x))[0]) - static int IMB_ispic_name(char *name) { + ImFileType *type; struct stat st; int fp, buf[10]; - int ofs = 0; if(UTIL_DEBUG) printf("IMB_ispic_name: loading %s\n", name); - if (ib_stat(name,&st) == -1) return(0); - if (((st.st_mode) & S_IFMT) == S_IFREG){ - if ((fp = open(name,O_BINARY|O_RDONLY)) >= 0){ - if (read(fp,buf,32)==32){ - close(fp); - if (buf[ofs] == CAT) ofs += 3; - if (buf[ofs] == FORM){ - if (buf[ofs + 2] == ILBM) return(AMI); - if (buf[ofs + 2] == ANIM){ - if (buf[ofs + 3] == FORM){ - return(ANIM); - }else{ - return(Anim); - } - } - } else { - if (GS(buf) == IMAGIC) return(IMAGIC); - if (GSS(buf) == IMAGIC) return(IMAGIC); - if ((BIG_LONG(buf[0]) & 0xfffffff0) == 0xffd8ffe0) return(JPG); - - /* at windows there are ".ffl" files with the same magic numnber... - besides that, tim images are not really important anymore! */ - /* if ((BIG_LONG(buf[0]) == 0x10000000) && ((BIG_LONG(buf[1]) & 0xf0ffffff) == 0)) return(TIM); */ - - } - if (imb_is_a_png(buf)) return(PNG); -#ifdef WITH_DDS - if (imb_is_a_dds((uchar *)buf)) return(DDS); -#endif - if (imb_is_a_targa(buf)) return(TGA); -#ifdef WITH_OPENEXR - if (imb_is_a_openexr((uchar *)buf)) return(OPENEXR); -#endif - if (imb_is_a_tiff(buf)) return(TIF); - if (imb_is_dpx(buf)) return (DPX); - if (imb_is_cineon(buf)) return(CINEON); - /* radhdr: check if hdr format */ - if (imb_is_a_hdr(buf)) return(RADHDR); - -/* - if (imb_is_a_bmp(buf)) return(BMP); -*/ - -#ifdef WITH_OPENJPEG - if (imb_is_a_jp2(buf)) return(JP2); -#endif - -#ifdef WITH_QUICKTIME -#if defined(_WIN32) || defined(__APPLE__) - if(G.have_quicktime) { - if (imb_is_a_quicktime(name)) return(QUICKTIME); - } -#endif -#endif + if(stat(name,&st) == -1) + return FALSE; + if(((st.st_mode) & S_IFMT) != S_IFREG) + return FALSE; - return(FALSE); - } - close(fp); - } + if((fp = open(name,O_BINARY|O_RDONLY)) < 0) + return FALSE; + + if(read(fp, buf, 32) != 32) { + close(fp); + return FALSE; } - return(FALSE); -} + close(fp); + + /* XXX move this exception */ + if((BIG_LONG(buf[0]) & 0xfffffff0) == 0xffd8ffe0) + return JPG; + for(type=IMB_FILE_TYPES; type->is_a; type++) + if(type->is_a((uchar*)buf)) + return type->filetype; + + return FALSE; +} int IMB_ispic(char *filename) { if(U.uiflag & USER_FILTERFILEEXTS) { if (G.have_libtiff && (BLI_testextensie(filename, ".tif") - || BLI_testextensie(filename, ".tiff"))) { + || BLI_testextensie(filename, ".tiff") + || BLI_testextensie(filename, ".tx"))) { return IMB_ispic_name(filename); } if (G.have_quicktime){ @@ -179,6 +115,7 @@ int IMB_ispic(char *filename) || BLI_testextensie(filename, ".jpeg") || BLI_testextensie(filename, ".tif") || BLI_testextensie(filename, ".tiff") + || BLI_testextensie(filename, ".tx") || BLI_testextensie(filename, ".hdr") || BLI_testextensie(filename, ".tga") || BLI_testextensie(filename, ".rgb") @@ -391,14 +328,14 @@ int imb_get_anim_type(char * name) { /* stat test below fails on large files > 4GB */ if (isffmpeg(name)) return (ANIM_FFMPEG); # endif - if (ib_stat(name,&st) == -1) return(0); + if (stat(name,&st) == -1) return(0); if (((st.st_mode) & S_IFMT) != S_IFREG) return(0); if (isavi(name)) return (ANIM_AVI); if (ismovie(name)) return (ANIM_MOVIE); #else - if (ib_stat(name,&st) == -1) return(0); + if (stat(name,&st) == -1) return(0); if (((st.st_mode) & S_IFMT) != S_IFREG) return(0); if (ismovie(name)) return (ANIM_MOVIE); @@ -414,7 +351,6 @@ int imb_get_anim_type(char * name) { if (isredcode(name)) return (ANIM_REDCODE); #endif type = IMB_ispic(name); - if (type == ANIM) return (ANIM_ANIM5); if (type) return(ANIM_SEQUENCE); return(0); } diff --git a/source/blender/imbuf/intern/writeimage.c b/source/blender/imbuf/intern/writeimage.c index 808fbc25c24..b55ce4b1df4 100644 --- a/source/blender/imbuf/intern/writeimage.c +++ b/source/blender/imbuf/intern/writeimage.c @@ -31,180 +31,32 @@ #include -#include "BKE_global.h" -#include "BLI_blenlib.h" - -#include "imbuf.h" -#include "imbuf_patch.h" - #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" +#include "IMB_filetype.h" -#include "IMB_allocimbuf.h" - -#include "IMB_dpxcineon.h" -#include "IMB_targa.h" -#include "IMB_jpeg.h" -#include "IMB_iris.h" -#include "IMB_ham.h" -#include "IMB_hamx.h" -#include "IMB_amiga.h" -#include "IMB_png.h" -#include "IMB_bmp.h" -#include "IMB_radiance_hdr.h" - -#if defined(__APPLE__) && defined(IMBUF_COCOA) -#include "IMB_cocoa.h" -#else -#include "IMB_tiff.h" -#endif - -#ifdef WITH_OPENJPEG -#include "IMB_jp2.h" -#endif - -#ifdef WITH_OPENEXR -#include "openexr/openexr_api.h" -#endif - -#ifdef WITH_DDS -#include "dds/dds_api.h" -#endif - -#include "IMB_iff.h" -#include "IMB_bitplanes.h" -#include "IMB_divers.h" - -#ifdef WIN32 -#include -#include "BLI_winstuff.h" -#endif -/* added facility to copy with saving non-float rects */ +#include "imbuf.h" short IMB_saveiff(struct ImBuf *ibuf, char *name, int flags) { - short ok=TRUE,delpl=FALSE; - int file = -1; + ImFileType *type; - if (ibuf==0) return (FALSE); + if(ibuf == NULL) return (FALSE); ibuf->flags = flags; - /* Put formats that take a filename here */ - if (IS_jpg(ibuf)) { - if(ibuf->rect==NULL && ibuf->rect_float) - IMB_rect_from_float(ibuf); - return imb_savejpeg(ibuf, name, flags); - } - if (IS_radhdr(ibuf)) { - return imb_savehdr(ibuf, name, flags); - } - if (IS_png(ibuf)) { - if(ibuf->rect==NULL && ibuf->rect_float) - IMB_rect_from_float(ibuf); - return imb_savepng(ibuf, name, flags); - } - if (IS_bmp(ibuf)) { - if(ibuf->rect==NULL && ibuf->rect_float) - IMB_rect_from_float(ibuf); - return imb_savebmp(ibuf, name, flags); - } - if (IS_tga(ibuf)) { - if(ibuf->rect==NULL && ibuf->rect_float) - IMB_rect_from_float(ibuf); - return imb_savetarga(ibuf, name, flags); - } - if (IS_iris(ibuf)) { - if(ibuf->rect==NULL && ibuf->rect_float) - IMB_rect_from_float(ibuf); - return imb_saveiris(ibuf, name, flags); - } - -#if defined(__APPLE__) && defined(IMBUF_COCOA) - if (IS_tiff(ibuf)) { - if(ibuf->rect==NULL && ibuf->rect_float) - IMB_rect_from_float(ibuf); - return imb_cocoaSaveImage(ibuf, name, flags); - } -#else - if (G.have_libtiff && IS_tiff(ibuf)) { - if(ibuf->rect==NULL && ibuf->rect_float) - IMB_rect_from_float(ibuf); - return imb_savetiff(ibuf, name, flags); - } -#endif - -#ifdef WITH_OPENEXR - if (IS_openexr(ibuf)) { - return imb_save_openexr(ibuf, name, flags); - } -#endif -/* not supported yet -#ifdef WITH_DDS - if (IS_dds(ibuf)) { - return imb_save_dds(ibuf, name, flags); - } -#endif -*/ - if (IS_cineon(ibuf)) { - return imb_savecineon(ibuf, name, flags); - - } - if (IS_dpx(ibuf)) { - return imb_save_dpx(ibuf, name, flags); - } -#ifdef WITH_OPENJPEG - if (IS_jp2(ibuf)) { - return imb_savejp2(ibuf, name, flags); - } -#endif - file = open(name, O_BINARY | O_RDWR | O_CREAT | O_TRUNC, 0666); - if (file < 0) return (FALSE); - - if (flags & IB_rect){ - if (ibuf->cmap){ - imb_checkncols(ibuf); - } - } - - /* Put formats that take a filehandle here */ - ok = imb_start_iff(ibuf,file); - if (IS_amiga(ibuf)){ - IMB_flipy(ibuf); - if (flags & IB_rect){ - if ((flags & IB_cmap) == 0) { - if (IS_ham(ibuf)){ - if (ok) ok = imb_converttoham(ibuf); - }else if (ibuf->cmap){ - if (ok) ok = IMB_converttocmap(ibuf); - } + for(type=IMB_FILE_TYPES; type->is_a; type++) { + if(type->save && type->ftype(type, ibuf)) { + if(!(type->flag & IM_FTYPE_FLOAT)) { + if(ibuf->rect==NULL && ibuf->rect_float) + IMB_rect_from_float(ibuf); } - if (ok){ - if (ibuf->planes==0){ - delpl=TRUE; - ok=imb_addplanesImBuf(ibuf); - } - imb_longtobp(ibuf); - } - } - if (flags & IB_vert){ - if (ok) ok = imb_encodebodyv(ibuf,file); - } - else{ - if (ok) ok = imb_encodebodyh(ibuf,file); + return type->save(ibuf, name, flags); } - if (ok) ok = imb_update_iff(file,BODY); - }else if (IS_anim(ibuf)) { - if (ok) ok = imb_enc_anim(ibuf, file); - if (ok) ok = imb_update_iff(file, BODY); } - close(file); - if (ok==FALSE) { - fprintf(stderr,"Couldn't save picture.\n"); - } - if (delpl) imb_freeplanesImBuf(ibuf); + fprintf(stderr, "Couldn't save picture.\n"); - return (ok); + return FALSE; } diff --git a/source/blender/makesdna/DNA_image_types.h b/source/blender/makesdna/DNA_image_types.h index 5aed1d0c2d0..1695ceb73a5 100644 --- a/source/blender/makesdna/DNA_image_types.h +++ b/source/blender/makesdna/DNA_image_types.h @@ -112,7 +112,7 @@ typedef struct Image { #define IMA_REFLECT 16 #define IMA_NOCOLLECT 32 -#define IMA_ANTIALI 64 +#define IMA_DEPRECATED 64 #define IMA_OLD_PREMUL 128 /* tpageflag */ diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index f13bdd4ceee..52f4b289368 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -339,11 +339,6 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Fields", "Use fields of the image"); RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_fields_update"); - prop= RNA_def_property(srna, "antialias", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_ANTIALI); - RNA_def_property_ui_text(prop, "Anti-alias", "Toggles image anti-aliasing, only works with solid colors"); - RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); - prop= RNA_def_property(srna, "premultiply", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_DO_PREMUL); RNA_def_property_ui_text(prop, "Premultiply", "Convert RGB from key alpha to premultiplied alpha"); diff --git a/source/blender/quicktime/apple/qtkit_import.m b/source/blender/quicktime/apple/qtkit_import.m index 322f2757419..80b97066b61 100644 --- a/source/blender/quicktime/apple/qtkit_import.m +++ b/source/blender/quicktime/apple/qtkit_import.m @@ -376,7 +376,11 @@ int imb_is_a_quicktime (char *name) { NSImage *image; int result; - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSAutoreleasePool *pool; + + if(!G.have_quicktime) return 0; + + pool = [[NSAutoreleasePool alloc] init]; // dont let quicktime image import handle these if( BLI_testextensie(name, ".swf") || @@ -412,6 +416,9 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags) NSBitmapImageRep *bitmapImage; NSBitmapImageRep *blBitmapFormatImageRGB,*blBitmapFormatImageRGBA; NSAutoreleasePool *pool; + + if(!G.have_quicktime) + return NULL; pool = [[NSAutoreleasePool alloc] init]; diff --git a/source/blender/quicktime/apple/quicktime_import.c b/source/blender/quicktime/apple/quicktime_import.c index 10b45cafa91..75f77dccbfa 100644 --- a/source/blender/quicktime/apple/quicktime_import.c +++ b/source/blender/quicktime/apple/quicktime_import.c @@ -559,6 +559,8 @@ int imb_is_a_quicktime (char *name) #endif OSErr err = noErr; + if(!G.have_quicktime) return 0; + if(QTIME_DEBUG) printf("qt: checking as image %s\n", name); // dont let quicktime image import handle these diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 1726b35b0e4..ed2ba460e9d 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -301,12 +301,6 @@ void WM_exit(bContext *C) BPY_end_python(); #endif - libtiff_exit(); - -#ifdef WITH_QUICKTIME - quicktime_exit(); -#endif - if (!G.background) { // XXX UI_filelist_free_icons(); } diff --git a/source/creator/creator.c b/source/creator/creator.c index 24523342866..3070bf0462d 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -72,7 +72,7 @@ #include "BKE_report.h" #include "BKE_sound.h" -#include "IMB_imbuf.h" // for quicktime_init +#include "IMB_imbuf.h" // for IMB_init #ifndef DISABLE_PYTHON #include "BPY_extern.h" @@ -217,7 +217,7 @@ static int print_help(int argc, char **argv, void *data) printf (" use -E help to list available engines.\n"); printf ("\nFormat options:\n"); printf (" -F \tSet the render format, Valid options are...\n"); - printf (" \tTGA IRIS HAMX JPEG MOVIE IRIZ RAWTGA\n"); + printf (" \tTGA IRIS JPEG MOVIE IRIZ RAWTGA\n"); printf (" \tAVIRAW AVIJPEG PNG BMP FRAMESERVER\n"); printf (" (formats that can be compiled into blender, not available on all systems)\n"); printf (" \tHDR TIFF EXR MULTILAYER MPEG AVICODEC QUICKTIME CINEON DPX DDS\n"); @@ -367,8 +367,6 @@ static int playback_mode(int argc, char **argv, void *data) { /* not if -b was given first */ if (G.background == 0) { - /* exception here, see below, it probably needs happens after qt init? */ - libtiff_init(); // XXX playanim(argc, argv); /* not the same argc and argv as before */ exit(0); @@ -532,12 +530,10 @@ static int set_image_type(int argc, char **argv, void *data) Scene *scene= CTX_data_scene(C); if (!strcmp(imtype,"TGA")) scene->r.imtype = R_TARGA; else if (!strcmp(imtype,"IRIS")) scene->r.imtype = R_IRIS; - else if (!strcmp(imtype,"HAMX")) scene->r.imtype = R_HAMX; #ifdef WITH_DDS else if (!strcmp(imtype,"DDS")) scene->r.imtype = R_DDS; #endif else if (!strcmp(imtype,"JPEG")) scene->r.imtype = R_JPEG90; - else if (!strcmp(imtype,"MOVIE")) scene->r.imtype = R_MOVIE; else if (!strcmp(imtype,"IRIZ")) scene->r.imtype = R_IRIZ; else if (!strcmp(imtype,"RAWTGA")) scene->r.imtype = R_RAWTGA; else if (!strcmp(imtype,"AVIRAW")) scene->r.imtype = R_AVIRAW; @@ -972,6 +968,8 @@ int main(int argc, char **argv) initglobals(); /* blender.c */ + IMB_init(); + syshandle = SYS_GetSystem(); GEN_init_messaging_system(); @@ -1042,20 +1040,6 @@ int main(int argc, char **argv) CTX_py_init_set(C, 1); WM_keymap_init(C); -#ifdef WITH_QUICKTIME - - quicktime_init(); - -#endif /* WITH_QUICKTIME */ - - /* dynamically load libtiff, if available */ - libtiff_init(); - if (!G.have_libtiff && (G.f & G_DEBUG)) { - printf("Unable to load: libtiff.\n"); - printf("Try setting the BF_TIFF_LIB environment variable if you want this support.\n"); - printf("Example: setenv BF_TIFF_LIB /usr/lib/libtiff.so\n"); - } - /* OK we are ready for it */ BLI_argsParse(ba, 4, load_file, C); diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 7c3a6adf881..71507642226 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -794,10 +794,7 @@ void GPG_Application::exitEngine() m_canvas = 0; } - libtiff_exit(); -#ifdef WITH_QUICKTIME - quicktime_exit(); -#endif + IMB_exit(); GPU_extensions_exit(); m_exitRequested = 0; diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 9d87adb7400..b7ed8666325 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -376,11 +376,7 @@ int main(int argc, char** argv) GEN_init_messaging_system(); -#ifdef WITH_QUICKTIME - quicktime_init(); -#endif - - libtiff_init(); + IMB_init(); // Parse command line options #ifndef NDEBUG -- cgit v1.2.3 From d972b8488e5c2b119731bfbb2b0921cb7775064a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 7 May 2010 15:49:21 +0000 Subject: fix for segfault when reading bad multilayer EXR's --- source/blender/imbuf/intern/openexr/openexr_api.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 72d2dd01ffe..214cccd77c3 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -1015,9 +1015,13 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, int size, int flags) } delete file; - + if(ibuf) { + if(ibuf->rect_float) { + MEM_freeN(ibuf->rect_float); + ibuf->rect_float= NULL; + } + } return(ibuf); - } catch (const std::exception &exc) { -- cgit v1.2.3 From 5774e61f4a4b7ebbc12017eebf454847bc5ab25a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 7 May 2010 15:52:16 +0000 Subject: shouldnt have committed this, was local hack to workaround float buffer bug. --- source/blender/imbuf/intern/openexr/openexr_api.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 214cccd77c3..c495508558e 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -1015,12 +1015,6 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, int size, int flags) } delete file; - if(ibuf) { - if(ibuf->rect_float) { - MEM_freeN(ibuf->rect_float); - ibuf->rect_float= NULL; - } - } return(ibuf); } catch (const std::exception &exc) -- cgit v1.2.3 From 22978ebfdc8a4506431492ac39d0ffd5d975093f Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Fri, 7 May 2010 18:53:28 +0000 Subject: Logic UI - fixing missing rna default values there are some cases (i.e. Constraint Actuator) where the same DNA property is being used by different RNAs with different ranges. It's easy to change (reset the values to their default in the set func of the constrant type rna). Not sure it's necessary though. --- source/blender/blenkernel/intern/sca.c | 14 ++++++++++++++ source/blender/editors/space_logic/logic_window.c | 4 +++- source/blender/makesdna/DNA_actuator_types.h | 4 ++++ source/blender/makesrna/intern/rna_actuator.c | 7 ++----- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index 060c9312f99..5a06c251b88 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -98,6 +98,8 @@ void init_sensor(bSensor *sens) /* also use when sensor changes type */ bNearSensor *ns; bMouseSensor *ms; + bJoystickSensor *js; + bRaySensor *rs; if(sens->data) MEM_freeN(sens->data); sens->data= NULL; @@ -145,12 +147,18 @@ void init_sensor(bSensor *sens) break; case SENS_RAY: sens->data= MEM_callocN(sizeof(bRaySensor), "raysens"); + rs = sens->data; + rs->range = 0.01f; break; case SENS_MESSAGE: sens->data= MEM_callocN(sizeof(bMessageSensor), "messagesens"); break; case SENS_JOYSTICK: sens->data= MEM_callocN(sizeof(bJoystickSensor), "joysticksens"); + js= sens->data; + js->hatf = SENS_JOY_HAT_UP; + js->axis = 1; + js->hat = 1; break; default: ; /* this is very severe... I cannot make any memory for this */ @@ -383,7 +391,9 @@ void copy_actuators(ListBase *lbn, ListBase *lbo) void init_actuator(bActuator *act) { /* also use when actuator changes type */ + bCameraActuator *ca; bObjectActuator *oa; + bRandomActuator *ra; bSoundActuator *sa; if(act->data) MEM_freeN(act->data); @@ -417,6 +427,8 @@ void init_actuator(bActuator *act) break; case ACT_CAMERA: act->data= MEM_callocN(sizeof(bCameraActuator), "camact"); + ca = act->data; + ca->axis = ACT_CAMERA_X; break; case ACT_EDIT_OBJECT: act->data= MEM_callocN(sizeof(bEditObjectActuator), "editobact"); @@ -432,6 +444,8 @@ void init_actuator(bActuator *act) break; case ACT_RANDOM: act->data= MEM_callocN(sizeof(bRandomActuator), "random act"); + ra=act->data; + ra->float_arg_1 = 0.1f; break; case ACT_MESSAGE: act->data= MEM_callocN(sizeof(bMessageActuator), "message act"); diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index daeb3df908a..aab4f948401 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -3284,7 +3284,7 @@ static void draw_sensor_joystick(uiLayout *layout, PointerRNA *ptr) col = uiLayoutColumn(layout, 0); uiLayoutSetActive(col, RNA_boolean_get(ptr, "all_events")==0); - uiItemR(col, ptr, "hat_direction", 0, NULL, 0); //XXXSENSOR - needs a default value (somewhere else in the code) + uiItemR(col, ptr, "hat_direction", 0, NULL, 0); break; case SENS_JOY_AXIS_SINGLE: row = uiLayoutRow(layout, 0); @@ -3924,6 +3924,8 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) uiItemR(subcol, ptr, "force_min_z", 0, NULL, 0); //XXXACTUATOR missing labels from original 2.49 ui (e.g. Servo, Min, Max, Fast) + //Layout designers willing to help on that, please compare with 2.49 ui + // (since the old code is going to be deleted ... soon) col = uiLayoutColumn(layout, 1); uiItemR(col, ptr, "proportional_coefficient", UI_ITEM_R_SLIDER, NULL, 0); diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h index 923f7f232e0..03200b784b4 100644 --- a/source/blender/makesdna/DNA_actuator_types.h +++ b/source/blender/makesdna/DNA_actuator_types.h @@ -498,6 +498,10 @@ typedef struct FreeCamera { #define ACT_STATE_REMOVE 2 #define ACT_STATE_CHANGE 3 +/* cameraactuator->axis */ +#define ACT_CAMERA_X (float)'x' +#define ACT_CAMERA_Y (float)'y' + #endif diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 5e5ca2cd2b1..f83cf4a296c 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -776,8 +776,8 @@ static void rna_def_camera_actuator(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_axis_items[] ={ - {(float)'x', "X", 0, "X", "Camera tries to get behind the X axis"}, - {(float)'y', "Y", 0, "Y", "Camera tries to get behind the Y axis"}, + {ACT_CAMERA_X, "X", 0, "X", "Camera tries to get behind the X axis"}, + {ACT_CAMERA_Y, "Y", 0, "Y", "Camera tries to get behind the Y axis"}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "CameraActuator", "Actuator"); @@ -808,14 +808,11 @@ static void rna_def_camera_actuator(BlenderRNA *brna) RNA_def_property_update(prop, NC_LOGIC, NULL); /* x/y */ - // It could be changed to be a regular ENUM instead of this weird "(float)string enum" prop= RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "axis"); RNA_def_property_enum_items(prop, prop_axis_items); RNA_def_property_ui_text(prop, "Axis", "Specify the axis the Camera will try to get behind"); RNA_def_property_update(prop, NC_LOGIC, NULL); - //XXX it's not working (no default value) - // probably need to make a get/set function } static void rna_def_sound_actuator(BlenderRNA *brna) -- cgit v1.2.3 From 672044cd497093cc7a2971f75359626010b3150e Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Fri, 7 May 2010 21:35:10 +0000 Subject: CMake + MSVC building fix (PTHREADS_INC needed in imbuf) again, I know that the header shouldnt' be included there. But since it's still there at least let's make it build. --- source/blender/imbuf/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt index 9cb98c258de..5af39cea832 100644 --- a/source/blender/imbuf/CMakeLists.txt +++ b/source/blender/imbuf/CMakeLists.txt @@ -37,6 +37,10 @@ SET(INC ${OPENJPEG_INC} ) +IF(WIN32) + SET(INC ${INC} ${PTHREADS_INC}) +ENDIF(WIN32) + IF(WITH_OPENEXR) ADD_DEFINITIONS(-DWITH_OPENEXR) ENDIF(WITH_OPENEXR) -- cgit v1.2.3 From b2b780f2fe9a97ce4ed97e9fc93ec05b6c4d906d Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Fri, 7 May 2010 22:04:48 +0000 Subject: SVN maintenance. --- source/blender/imbuf/intern/IMB_metadata.h | 2 +- source/blender/imbuf/intern/metadata.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/imbuf/intern/IMB_metadata.h b/source/blender/imbuf/intern/IMB_metadata.h index 751978a88da..625e0791e07 100644 --- a/source/blender/imbuf/intern/IMB_metadata.h +++ b/source/blender/imbuf/intern/IMB_metadata.h @@ -1,5 +1,5 @@ /** - * $Id: IMB_metadata.h 28607 2010-05-06 07:10:56Z campbellbarton $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/imbuf/intern/metadata.c b/source/blender/imbuf/intern/metadata.c index 66fe1089aea..38ffa2fe2fa 100644 --- a/source/blender/imbuf/intern/metadata.c +++ b/source/blender/imbuf/intern/metadata.c @@ -1,5 +1,5 @@ /** - * $Id: metadata.c 28209 2010-04-15 15:49:48Z blendix $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * -- cgit v1.2.3 From 14b41f907803a1383075f497dfc7ab9bcb843ad8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 7 May 2010 23:34:03 +0000 Subject: bugfix [#22276] filemanager autocompleate based on current path also added autocomp to filename in fileselector --- source/blender/blenlib/intern/bpath.c | 2 +- source/blender/editors/space_file/file_draw.c | 3 +- source/blender/editors/space_file/file_intern.h | 1 + source/blender/editors/space_file/file_ops.c | 19 ++----- source/blender/editors/space_file/filesel.c | 70 ++++++++++++++++++++----- 5 files changed, 66 insertions(+), 29 deletions(-) diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c index 2367af470fe..afe73a53e5b 100644 --- a/source/blender/blenlib/intern/bpath.c +++ b/source/blender/blenlib/intern/bpath.c @@ -622,7 +622,7 @@ static int findFileRecursive(char *filename_new, const char *dirname, const char while ((de = readdir(dir)) != NULL) { - if (strncmp(".", de->d_name, 2)==0 || strncmp("..", de->d_name, 3)==0) + if (strcmp(".", de->d_name)==0 || strcmp("..", de->d_name)==0) continue; BLI_join_dirfile(path, dirname, de->d_name); diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 0773ad96a7c..ac09ce6861a 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -180,10 +180,11 @@ void file_draw_buttons(const bContext *C, ARegion *ar) params->dir, 0.0, (float)FILE_MAX-1, 0, 0, "File path."); uiButSetCompleteFunc(but, autocomplete_directory, NULL); - uiDefBut(block, TEX, B_FS_FILENAME, "", + but = uiDefBut(block, TEX, B_FS_FILENAME, "", min_x, line2_y, line2_w-chan_offs, btn_h, params->file, 0.0, (float)FILE_MAXFILE-1, 0, 0, "File name."); + uiButSetCompleteFunc(but, autocomplete_file, NULL); } /* Filename number increment / decrement buttons. */ diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h index a7aeaa1d365..ef05e6cac76 100644 --- a/source/blender/editors/space_file/file_intern.h +++ b/source/blender/editors/space_file/file_intern.h @@ -90,6 +90,7 @@ float file_font_pointsize(); void file_change_dir(bContext *C, int checkdir); int file_select_match(struct SpaceFile *sfile, const char *pattern); void autocomplete_directory(struct bContext *C, char *str, void *arg_v); +void autocomplete_file(struct bContext *C, char *str, void *arg_v); /* file_panels.c */ void file_panels_register(struct ARegionType *art); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 85b3cee354b..ed098d2d44e 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -816,26 +816,15 @@ void FILE_OT_directory_new(struct wmOperatorType *ot) int file_directory_exec(bContext *C, wmOperator *unused) { - char tmpstr[FILE_MAX]; - SpaceFile *sfile= CTX_wm_space_file(C); if(sfile->params) { if ( sfile->params->dir[0] == '~' ) { - if (sfile->params->dir[1] == '\0') { - BLI_strncpy(sfile->params->dir, BLI_gethome(), sizeof(sfile->params->dir) ); - } else { - /* replace ~ with home */ - char homestr[FILE_MAX]; - char *d = &sfile->params->dir[1]; - - while ( (*d == '\\') || (*d == '/') ) - d++; - BLI_strncpy(homestr, BLI_gethome(), FILE_MAX); - BLI_join_dirfile(tmpstr, homestr, d); - BLI_strncpy(sfile->params->dir, tmpstr, sizeof(sfile->params->dir)); - } + char tmpstr[sizeof(sfile->params->dir)-1]; + strncpy(tmpstr, sfile->params->dir+1, sizeof(tmpstr)); + BLI_join_dirfile(sfile->params->dir, BLI_gethome(), tmpstr); } + #ifdef WIN32 if (sfile->params->dir[0] == '\0') get_default_root(sfile->params->dir); diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index ea098ffcdb4..916f8dfcd62 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -42,6 +42,15 @@ #include #endif +/* path/file handeling stuff */ +#ifndef WIN32 + #include + #include +#else + #include + #include "BLI_winstuff.h" +#endif + #include "DNA_space_types.h" #include "DNA_screen_types.h" #include "DNA_userdef_types.h" @@ -432,10 +441,55 @@ int file_select_match(struct SpaceFile *sfile, const char *pattern) return match; } - void autocomplete_directory(struct bContext *C, char *str, void *arg_v) { - char tmp[FILE_MAX]; + SpaceFile *sfile= CTX_wm_space_file(C); + + /* search if str matches the beginning of name */ + if(str[0] && sfile->files) { + char dirname[FILE_MAX]; + + DIR *dir; + struct dirent *de; + + BLI_split_dirfile(str, dirname, NULL); + + dir = opendir(dirname); + + if(dir) { + AutoComplete *autocpl= autocomplete_begin(str, FILE_MAX); + + while ((de = readdir(dir)) != NULL) { + if (strcmp(".", de->d_name)==0 || strcmp("..", de->d_name)==0) { + /* pass */ + } + else { + char path[FILE_MAX]; + struct stat status; + + BLI_join_dirfile(path, dirname, de->d_name); + + if (stat(path, &status) == 0) { + if (S_ISDIR(status.st_mode)) { /* is subdir */ + autocomplete_do_name(autocpl, path); + } + } + } + } + closedir(dir); + + autocomplete_end(autocpl, str); + if (BLI_exists(str)) { + BLI_add_slash(str); + } else { + BLI_make_exist(str); + } + } + } +} + +void autocomplete_file(struct bContext *C, char *str, void *arg_v) +{ SpaceFile *sfile= CTX_wm_space_file(C); /* search if str matches the beginning of name */ @@ -446,19 +500,11 @@ void autocomplete_directory(struct bContext *C, char *str, void *arg_v) for(i= 0; ifiles, i); - const char* dir = filelist_dir(sfile->files); - if (file && S_ISDIR(file->type)) { - // BLI_make_file_string(G.sce, tmp, dir, file->relname); - BLI_join_dirfile(tmp, dir, file->relname); - autocomplete_do_name(autocpl,tmp); + if (file && S_ISREG(file->type)) { + autocomplete_do_name(autocpl, file->relname); } } autocomplete_end(autocpl, str); - if (BLI_exists(str)) { - BLI_add_slash(str); - } else { - BLI_make_exist(str); - } } } -- cgit v1.2.3 From 0511086d5fc6915288fb35743b9eab0f04b0c306 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Fri, 7 May 2010 23:56:26 +0000 Subject: adjusment to constraint actuator layout (forgot to expose normal and before) --- source/blender/editors/space_logic/logic_window.c | 29 ++++++++++++++--------- source/blender/makesrna/intern/rna_actuator.c | 6 ++--- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index aab4f948401..d278cf16fd4 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -3635,7 +3635,7 @@ static void draw_actuator_camera(uiLayout *layout, PointerRNA *ptr) static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr) { - uiLayout *row, *subrow, *split; + uiLayout *row, *subrow, *col, *subcol, *split; uiItemR(layout, ptr, "mode", 0, NULL, 0); switch (RNA_enum_get(ptr, "mode")) @@ -3651,15 +3651,22 @@ static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr) break; case ACT_CONST_TYPE_DIST: - uiItemR(layout, ptr, "direction", 0, NULL, 0);//move to the right - if(RNA_enum_get(ptr, "direction")!=0) - uiItemR(layout, ptr, "force_distance", 0, NULL, 0); + split = uiLayoutSplit(layout, 0.8, 0); + uiItemR(split, ptr, "direction", 0, NULL, 0); + row = uiLayoutRow(split, 1); + uiItemR(row, ptr, "local", UI_ITEM_R_TOGGLE, NULL, 0); + uiItemR(row, ptr, "normal", UI_ITEM_R_TOGGLE, NULL, 0); row = uiLayoutRow(layout, 0); - uiItemR(row, ptr, "range", 0, NULL, 0); - subrow = uiLayoutRow(row, 0); - uiLayoutSetActive(subrow, RNA_boolean_get(ptr, "force_distance")==1); - uiItemR(subrow, ptr, "distance", 0, NULL, 0); + col = uiLayoutColumn(row, 0); + uiItemL(col, "Range:", 0); + uiItemR(col, ptr, "range", 0, "", 0); + + col = uiLayoutColumn(row, 1); + uiItemR(col, ptr, "force_distance", UI_ITEM_R_TOGGLE, NULL, 0); + subcol = uiLayoutColumn(col, 0); + uiLayoutSetActive(subcol, RNA_boolean_get(ptr, "force_distance")==1); + uiItemR(subcol, ptr, "distance", 0, "", 0); uiItemR(layout, ptr, "damping", UI_ITEM_R_SLIDER , NULL, 0); @@ -3904,21 +3911,21 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) row = uiLayoutRow(layout, 0); col = uiLayoutColumn(row, 0); uiItemR(col, ptr, "servo_limit_x", UI_ITEM_R_TOGGLE, NULL, 0); - subcol = uiLayoutColumn(col, 0); + subcol = uiLayoutColumn(col, 1); uiLayoutSetActive(subcol, RNA_boolean_get(ptr, "servo_limit_x")==1); uiItemR(subcol, ptr, "force_max_x", 0, NULL, 0); uiItemR(subcol, ptr, "force_min_x", 0, NULL, 0); col = uiLayoutColumn(row, 0); uiItemR(col, ptr, "servo_limit_y", UI_ITEM_R_TOGGLE, NULL, 0); - subcol = uiLayoutColumn(col, 0); + subcol = uiLayoutColumn(col, 1); uiLayoutSetActive(subcol, RNA_boolean_get(ptr, "servo_limit_y")==1); uiItemR(subcol, ptr, "force_max_y", 0, NULL, 0); uiItemR(subcol, ptr, "force_min_y", 0, NULL, 0); col = uiLayoutColumn(row, 0); uiItemR(col, ptr, "servo_limit_z", UI_ITEM_R_TOGGLE, NULL, 0); - subcol = uiLayoutColumn(col, 0); + subcol = uiLayoutColumn(col, 1); uiLayoutSetActive(subcol, RNA_boolean_get(ptr, "servo_limit_z")==1); uiItemR(subcol, ptr, "force_max_z", 0, NULL, 0); uiItemR(subcol, ptr, "force_min_z", 0, NULL, 0); diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index f83cf4a296c..cc1cd9b1e1d 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -546,7 +546,7 @@ static void rna_def_object_actuator(BlenderRNA *brna) prop= RNA_def_property(srna, "damping", PROP_INT, PROP_NONE); RNA_def_property_ui_range(prop, 0, 1000, 1, 1); - RNA_def_property_ui_text(prop, "Damping", "Number of frames to reach the target velocity"); + RNA_def_property_ui_text(prop, "Damping Frames", "Number of frames to reach the target velocity"); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "proportional_coefficient", PROP_FLOAT, PROP_NONE); @@ -1044,7 +1044,7 @@ static void rna_def_constraint_actuator(BlenderRNA *brna) prop= RNA_def_property(srna, "range", PROP_FLOAT, PROP_NONE); RNA_def_property_float_funcs(prop, "rna_ConstraintActuator_range_get", "rna_ConstraintActuator_range_set", NULL); RNA_def_property_ui_range(prop, 0.f, 2000.f, 1, 2); - RNA_def_property_ui_text(prop, "Range", ""); + RNA_def_property_ui_text(prop, "Range", "Set the maximum length of ray"); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); @@ -1127,7 +1127,7 @@ static void rna_def_constraint_actuator(BlenderRNA *brna) RNA_def_property_ui_text(prop, "L", "Set ray along object's axis or global axis"); RNA_def_property_update(prop, NC_LOGIC, NULL); - prop= RNA_def_property(srna, "nomal", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "normal", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_CONST_NORMAL); RNA_def_property_ui_text(prop, "N", "Set object axis along (local axis) or parallel (global axis) to the normal at hit position"); RNA_def_property_update(prop, NC_LOGIC, NULL); -- cgit v1.2.3 From d8fa59ce01e3db3145a6439f76d735e4258da1c2 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Sat, 8 May 2010 04:32:48 +0000 Subject: Allow clicking in the empty area of a scrollbar (in the 'groove' outside the scroller itself) to page up/page down. --- source/blender/editors/interface/view2d_ops.c | 76 +++++++++++++++++++-------- 1 file changed, 53 insertions(+), 23 deletions(-) diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 8e760a7501c..3e66521f77d 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1145,6 +1145,8 @@ typedef struct v2dScrollerMove { float fac; /* view adjustment factor, based on size of region */ float delta; /* amount moved by mouse on axis of interest */ + float scrollbarwidth; /* width of the scrollbar itself, used for page up/down clicks */ + int lastx, lasty; /* previous mouse coordinates (in screen coordinates) for determining movement */ } v2dScrollerMove; @@ -1164,19 +1166,21 @@ struct View2DScrollers { enum { SCROLLHANDLE_MIN= -1, SCROLLHANDLE_BAR, - SCROLLHANDLE_MAX + SCROLLHANDLE_MAX, + SCROLLHANDLE_MIN_OUTSIDE, + SCROLLHANDLE_MAX_OUTSIDE } eV2DScrollerHandle_Zone; /* ------------------------ */ /* check if mouse is within scroller handle * - mouse = relevant mouse coordinate in region space - * - sc_min, sc_max = extents of scroller - * - sh_min, sh_max = positions of scroller handles + * - sc_min, sc_max = extents of scroller 'groove' (potential available space for scroller) + * - sh_min, sh_max = positions of scrollbar handles */ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_min, int sh_max) { - short in_min, in_max, in_view=1; + short in_min, in_max, in_bar, out_min, out_max, in_view=1; /* firstly, check if * - 'bubble' fills entire scroller @@ -1200,15 +1204,21 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_ /* check if mouse is in or past either handle */ in_max= ( (mouse >= (sh_max - V2D_SCROLLER_HANDLE_SIZE)) && (mouse <= (sh_max + V2D_SCROLLER_HANDLE_SIZE)) ); in_min= ( (mouse <= (sh_min + V2D_SCROLLER_HANDLE_SIZE)) && (mouse >= (sh_min - V2D_SCROLLER_HANDLE_SIZE)) ); + in_bar= ( (mouse < (sh_max - V2D_SCROLLER_HANDLE_SIZE)) && (mouse > (sh_min + V2D_SCROLLER_HANDLE_SIZE)) ); + out_min= mouse < (sh_min - V2D_SCROLLER_HANDLE_SIZE); + out_max= mouse > (sh_max + V2D_SCROLLER_HANDLE_SIZE); - /* check if overlap --> which means user clicked on bar, as bar is within handles region */ - if (in_max && in_min) + if (in_bar) return SCROLLHANDLE_BAR; else if (in_max) return SCROLLHANDLE_MAX; else if (in_min) return SCROLLHANDLE_MIN; - + else if (out_min) + return SCROLLHANDLE_MIN_OUTSIDE; + else if (out_max) + return SCROLLHANDLE_MAX_OUTSIDE; + /* unlikely to happen, though we just cover it in case */ return SCROLLHANDLE_BAR; } @@ -1248,14 +1258,14 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event, vsm->fac= (v2d->tot.xmax - v2d->tot.xmin) / mask_size; /* get 'zone' (i.e. which part of scroller is activated) */ - if (v2d->keepzoom & V2D_LOCKZOOM_X) { + vsm->zone= mouse_in_scroller_handle(x, v2d->hor.xmin, v2d->hor.xmax, scrollers->hor_min, scrollers->hor_max); + + if ((v2d->keepzoom & V2D_LOCKZOOM_X) && ELEM(vsm->zone, SCROLLHANDLE_MIN, SCROLLHANDLE_MAX)) { /* default to scroll, as handles not usable */ vsm->zone= SCROLLHANDLE_BAR; } - else { - /* check which handle we're in */ - vsm->zone= mouse_in_scroller_handle(x, v2d->hor.xmin, v2d->hor.xmax, scrollers->hor_min, scrollers->hor_max); - } + + vsm->scrollbarwidth = scrollers->hor_max - scrollers->hor_min; } else { /* vertical scroller - calculate adjustment factor first */ @@ -1263,14 +1273,14 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event, vsm->fac= (v2d->tot.ymax - v2d->tot.ymin) / mask_size; /* get 'zone' (i.e. which part of scroller is activated) */ - if (v2d->keepzoom & V2D_LOCKZOOM_Y) { + vsm->zone= mouse_in_scroller_handle(y, v2d->vert.ymin, v2d->vert.ymax, scrollers->vert_min, scrollers->vert_max); + + if ((v2d->keepzoom & V2D_LOCKZOOM_Y) && ELEM(vsm->zone, SCROLLHANDLE_MIN, SCROLLHANDLE_MAX)) { /* default to scroll, as handles not usable */ vsm->zone= SCROLLHANDLE_BAR; } - else { - /* check which handle we're in */ - vsm->zone= mouse_in_scroller_handle(y, v2d->vert.ymin, v2d->vert.ymax, scrollers->vert_min, scrollers->vert_max); - } + + vsm->scrollbarwidth = scrollers->vert_max - scrollers->vert_min; } UI_view2d_scrollers_free(scrollers); @@ -1320,8 +1330,11 @@ static void scroller_activate_apply(bContext *C, wmOperator *op) if ((vsm->scroller == 'v') && !(v2d->keepzoom & V2D_LOCKZOOM_Y)) v2d->cur.ymax += temp; break; - - default: /* SCROLLHANDLE_BAR */ + + case SCROLLHANDLE_MIN_OUTSIDE: + case SCROLLHANDLE_MAX_OUTSIDE: + case SCROLLHANDLE_BAR: + default: /* only move view on an axis if panning is allowed */ if ((vsm->scroller == 'h') && !(v2d->keepofs & V2D_LOCKOFS_X)) { v2d->cur.xmin += temp; @@ -1332,6 +1345,7 @@ static void scroller_activate_apply(bContext *C, wmOperator *op) v2d->cur.ymax += temp; } break; + } /* validate that view is in valid configuration after this operation */ @@ -1353,7 +1367,7 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, wmEvent *event) case MOUSEMOVE: { /* calculate new delta transform, then store mouse-coordinates for next-time */ - if (vsm->zone != SCROLLHANDLE_MIN) { + if (ELEM(vsm->zone, SCROLLHANDLE_BAR, SCROLLHANDLE_MAX)) { /* if using bar (i.e. 'panning') or 'max' zoom widget */ switch (vsm->scroller) { case 'h': /* horizontal scroller - so only horizontal movement ('cur' moves opposite to mouse) */ @@ -1364,7 +1378,7 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, wmEvent *event) break; } } - else { + else if (vsm->zone == SCROLLHANDLE_MIN) { /* using 'min' zoom widget */ switch (vsm->scroller) { case 'h': /* horizontal scroller - so only horizontal movement ('cur' moves with mouse) */ @@ -1386,8 +1400,24 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, wmEvent *event) case LEFTMOUSE: if (event->val==KM_RELEASE) { - scroller_activate_exit(C, op); - return OPERATOR_FINISHED; + + /* click was in empty space outside scroll bar */ + if (ELEM(vsm->zone, SCROLLHANDLE_MIN_OUTSIDE, SCROLLHANDLE_MAX_OUTSIDE)) { + if (vsm->zone == SCROLLHANDLE_MIN_OUTSIDE) + vsm->delta = -vsm->scrollbarwidth * 0.8; + else if (vsm->zone == SCROLLHANDLE_MAX_OUTSIDE) + vsm->delta = vsm->scrollbarwidth * 0.8; + + scroller_activate_apply(C, op); + scroller_activate_exit(C, op); + return OPERATOR_FINISHED; + } + + /* otherwise, end the drag action */ + if (vsm->lastx || vsm->lasty) { + scroller_activate_exit(C, op); + return OPERATOR_FINISHED; + } } break; } -- cgit v1.2.3 From 68173d1dc0e4d1b8e205bd614e1dc43aaafd4442 Mon Sep 17 00:00:00 2001 From: Damien Plisson Date: Sat, 8 May 2010 05:56:34 +0000 Subject: Fix blenderplayer linking issues when building with CMake on unix systems --- source/blenderplayer/CMakeLists.txt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/source/blenderplayer/CMakeLists.txt b/source/blenderplayer/CMakeLists.txt index 60ea3347c3e..38ccb56c410 100644 --- a/source/blenderplayer/CMakeLists.txt +++ b/source/blenderplayer/CMakeLists.txt @@ -81,10 +81,11 @@ IF(UNIX) bf_oglrasterizer bf_expressions bf_scenegraph - bf_ikplugin - bf_ITASC - bf_IK - bf_smoke + bf_ikplugin + bf_ITASC + bf_IK + bf_smoke + bf_modifiers bf_moto bf_kernel bf_nodes @@ -115,7 +116,7 @@ IF(UNIX) ) IF(WITH_QUICKTIME) - SET(BLENDER_SORTED_LIBS ${BLENDER_SORTED_LIBS} quicktime) + SET(BLENDER_SORTED_LIBS ${BLENDER_SORTED_LIBS} bf_quicktime) ENDIF(WITH_QUICKTIME) IF(WITH_CXX_GUARDEDALLOC) -- cgit v1.2.3 From fcaca6c5bde7c580fa9c7d2445ec5c98418b7cbc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 8 May 2010 07:25:26 +0000 Subject: - console drop handler for datablocks & filepaths. - added BLO_idcode_to_name_plural() for names like meshes, scenes, libraries etc from and ID type. --- source/blender/blenloader/BLO_readfile.h | 11 ++++ source/blender/blenloader/intern/readblenentry.c | 68 +++++++++++++--------- .../blender/editors/space_console/space_console.c | 63 ++++++++++++++++++++ source/blender/makesrna/intern/rna_internal.h | 2 +- source/blender/makesrna/intern/rna_main.c | 5 +- source/blender/makesrna/intern/rna_main_api.c | 2 +- 6 files changed, 118 insertions(+), 33 deletions(-) diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index df7cd25a6db..d6418f426c8 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -122,6 +122,17 @@ BLO_blendfiledata_free( char* BLO_idcode_to_name( int code); + +/** + * Convert an idcode into a name (plural). + * + * @param code The code to convert. + * @return A static string representing the name of + * the code. + */ + char* +BLO_idcode_to_name_plural( + int code); /** * Convert a name into an idcode (ie. ID_SCE) diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index 33827c801f1..6424829c12a 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -70,41 +70,44 @@ typedef struct { unsigned short code; - char *name; + char *name, *plural; int flags; #define IDTYPE_FLAGS_ISLINKABLE (1<<0) } IDType; +/* plural need to match rna_main.c's MainCollectionDef */ static IDType idtypes[]= { - { ID_AC, "Action", IDTYPE_FLAGS_ISLINKABLE}, - { ID_AR, "Armature", IDTYPE_FLAGS_ISLINKABLE}, - { ID_BR, "Brush", IDTYPE_FLAGS_ISLINKABLE}, - { ID_CA, "Camera", IDTYPE_FLAGS_ISLINKABLE}, - { ID_CU, "Curve", IDTYPE_FLAGS_ISLINKABLE}, - { ID_GD, "GPencil", IDTYPE_FLAGS_ISLINKABLE}, - { ID_GR, "Group", IDTYPE_FLAGS_ISLINKABLE}, - { ID_ID, "ID", 0}, - { ID_IM, "Image", IDTYPE_FLAGS_ISLINKABLE}, - { ID_IP, "Ipo", IDTYPE_FLAGS_ISLINKABLE}, - { ID_KE, "Key", 0}, - { ID_LA, "Lamp", IDTYPE_FLAGS_ISLINKABLE}, - { ID_LI, "Library", 0}, - { ID_LT, "Lattice", IDTYPE_FLAGS_ISLINKABLE}, - { ID_MA, "Material", IDTYPE_FLAGS_ISLINKABLE}, - { ID_MB, "Metaball", IDTYPE_FLAGS_ISLINKABLE}, - { ID_ME, "Mesh", IDTYPE_FLAGS_ISLINKABLE}, - { ID_NT, "NodeTree", IDTYPE_FLAGS_ISLINKABLE}, - { ID_OB, "Object", IDTYPE_FLAGS_ISLINKABLE}, - { ID_SCE, "Scene", IDTYPE_FLAGS_ISLINKABLE}, - { ID_SCR, "Screen", 0}, - { ID_SEQ, "Sequence", 0}, - { ID_SO, "Sound", IDTYPE_FLAGS_ISLINKABLE}, - { ID_TE, "Texture", IDTYPE_FLAGS_ISLINKABLE}, - { ID_TXT, "Text", IDTYPE_FLAGS_ISLINKABLE}, - { ID_VF, "VFont", IDTYPE_FLAGS_ISLINKABLE}, - { ID_WO, "World", IDTYPE_FLAGS_ISLINKABLE}, - { ID_WV, "Wave", 0}, + { ID_AC, "Action", "actions", IDTYPE_FLAGS_ISLINKABLE}, + { ID_AR, "Armature", "armatures", IDTYPE_FLAGS_ISLINKABLE}, + { ID_BR, "Brush", "brushes", IDTYPE_FLAGS_ISLINKABLE}, + { ID_CA, "Camera", "cameras", IDTYPE_FLAGS_ISLINKABLE}, + { ID_CU, "Curve", "curves", IDTYPE_FLAGS_ISLINKABLE}, + { ID_GD, "GPencil", "gpencil", IDTYPE_FLAGS_ISLINKABLE}, /* rename gpencil */ + { ID_GR, "Group", "groups", IDTYPE_FLAGS_ISLINKABLE}, + { ID_ID, "ID", "ids", 0}, /* plural is fake */ + { ID_IM, "Image", "images", IDTYPE_FLAGS_ISLINKABLE}, + { ID_IP, "Ipo", "ipos", IDTYPE_FLAGS_ISLINKABLE}, /* deprecated */ + { ID_KE, "Key", "keys", 0}, + { ID_LA, "Lamp", "lamps", IDTYPE_FLAGS_ISLINKABLE}, + { ID_LI, "Library", "libraries", 0}, + { ID_LT, "Lattice", "lattices", IDTYPE_FLAGS_ISLINKABLE}, + { ID_MA, "Material", "materials", IDTYPE_FLAGS_ISLINKABLE}, + { ID_MB, "Metaball", "metaballs", IDTYPE_FLAGS_ISLINKABLE}, + { ID_ME, "Mesh", "meshes", IDTYPE_FLAGS_ISLINKABLE}, + { ID_NT, "NodeTree", "node_groups", IDTYPE_FLAGS_ISLINKABLE}, + { ID_OB, "Object", "objects", IDTYPE_FLAGS_ISLINKABLE}, + { ID_PA, "ParticleSettings", "particles", 0}, + { ID_SCE, "Scene", "scenes", IDTYPE_FLAGS_ISLINKABLE}, + { ID_SCR, "Screen", "screens", 0}, + { ID_SEQ, "Sequence", "sequences", 0}, /* not actually ID data */ + { ID_SO, "Sound", "sounds", IDTYPE_FLAGS_ISLINKABLE}, + { ID_TE, "Texture", "textures", IDTYPE_FLAGS_ISLINKABLE}, + { ID_TXT, "Text", "texts", IDTYPE_FLAGS_ISLINKABLE}, + { ID_VF, "VFont", "fonts", IDTYPE_FLAGS_ISLINKABLE}, + { ID_WO, "World", "worlds", IDTYPE_FLAGS_ISLINKABLE}, + { ID_WM, "WindowManager", "window_managers", 0}, + { ID_WV, "Wave", "waves", 0}, /* deprecated */ }; static int nidtypes= sizeof(idtypes)/sizeof(idtypes[0]); @@ -156,7 +159,14 @@ int BLO_idcode_from_name(char *name) return idt?idt->code:0; } + +char *BLO_idcode_to_name_plural(int code) +{ + IDType *idt= idtype_from_code(code); + return idt?idt->plural:NULL; +} + /* Access routines used by filesel. */ BlendHandle *BLO_blendhandle_from_file(char *file) diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 1b8191696f4..8a2f4e85f96 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -29,9 +29,14 @@ #include #include +#ifdef WIN32 +#include "BLI_winstuff.h" +#endif #include "MEM_guardedalloc.h" +#include "BLO_readfile.h" + #include "BLI_blenlib.h" #include "BLI_math.h" @@ -142,14 +147,71 @@ static SpaceLink *console_duplicate(SpaceLink *sl) static void console_main_area_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; + ListBase *lb; UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); /* own keymap */ keymap= WM_keymap_find(wm->defaultconf, "Console", SPACE_CONSOLE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + + /* add drop boxes */ + lb= WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW); + + WM_event_add_dropbox_handler(&ar->handlers, lb); +} + + +/* ************* dropboxes ************* */ + +static int id_drop_poll(bContext *C, wmDrag *drag, wmEvent *event) +{ + SpaceConsole *sc= CTX_wm_space_console(C); + if(sc->type==CONSOLE_TYPE_PYTHON) + if(drag->type==WM_DRAG_ID) + return 1; + return 0; +} + +static void id_drop_copy(wmDrag *drag, wmDropBox *drop) +{ + char text[64]; + ID *id= drag->poin; + + snprintf(text, sizeof(text), "bpy.data.%s['%s']", BLO_idcode_to_name_plural(GS(id->name)), id->name+2); + + /* copy drag path to properties */ + RNA_string_set(drop->ptr, "text", text); } +static int path_drop_poll(bContext *C, wmDrag *drag, wmEvent *event) +{ + SpaceConsole *sc= CTX_wm_space_console(C); + if(sc->type==CONSOLE_TYPE_PYTHON) + if(drag->type==WM_DRAG_PATH) + return 1; + return 0; +} + +static void path_drop_copy(wmDrag *drag, wmDropBox *drop) +{ + char pathname[FILE_MAXDIR+FILE_MAXFILE+2]; + snprintf(pathname, sizeof(pathname), "\"%s\"", drag->path); + RNA_string_set(drop->ptr, "text", pathname); +} + + +/* this region dropbox definition */ +static void console_dropboxes(void) +{ + ListBase *lb= WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW); + + WM_dropbox_add(lb, "CONSOLE_OT_insert", id_drop_poll, id_drop_copy); + WM_dropbox_add(lb, "CONSOLE_OT_insert", path_drop_poll, path_drop_copy); +} + +/* ************* end drop *********** */ + static void console_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ @@ -344,6 +406,7 @@ void ED_spacetype_console(void) st->duplicate= console_duplicate; st->operatortypes= console_operatortypes; st->keymap= console_keymap; + st->dropboxes= console_dropboxes; st->listener= console_main_area_listener; /* regions: main window */ diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 433d5ff2904..005efdb9bc4 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -249,7 +249,7 @@ void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_curves(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop); -void RNA_def_main_vfonts(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_textures(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_worlds(BlenderRNA *brna, PropertyRNA *cprop); diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index 7688d92f2e1..b683f5dc4b1 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -173,7 +173,7 @@ static void rna_Main_script_begin(CollectionPropertyIterator *iter, PointerRNA * rna_iterator_listbase_begin(iter, &bmain->script, NULL); } -static void rna_Main_vfont_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +static void rna_Main_font_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { Main *bmain= (Main*)ptr->data; rna_iterator_listbase_begin(iter, &bmain->vfont, NULL); @@ -271,6 +271,7 @@ void RNA_def_main(BlenderRNA *brna) PropertyRNA *prop; CollectionDefFunc *func; + /* plural must match idtypes in readblenentry.c */ MainCollectionDef lists[]= { {"cameras", "Camera", "rna_Main_camera_begin", "Cameras", "Camera datablocks.", RNA_def_main_cameras}, {"scenes", "Scene", "rna_Main_scene_begin", "Scenes", "Scene datablocks.", RNA_def_main_scenes}, @@ -286,7 +287,7 @@ void RNA_def_main(BlenderRNA *brna) {"lattices", "Lattice", "rna_Main_latt_begin", "Lattices", "Lattice datablocks.", RNA_def_main_lattices}, {"curves", "Curve", "rna_Main_curve_begin", "Curves", "Curve datablocks.", RNA_def_main_curves} , {"metaballs", "MetaBall", "rna_Main_mball_begin", "Metaballs", "Metaball datablocks.", RNA_def_main_metaballs}, - {"vfonts", "VectorFont", "rna_Main_vfont_begin", "Vector Fonts", "Vector font datablocks.", RNA_def_main_vfonts}, + {"fonts", "VectorFont", "rna_Main_font_begin", "Vector Fonts", "Vector font datablocks.", RNA_def_main_fonts}, {"textures", "Texture", "rna_Main_tex_begin", "Textures", "Texture datablocks.", RNA_def_main_textures}, {"brushes", "Brush", "rna_Main_brush_begin", "Brushes", "Brush datablocks.", RNA_def_main_brushes}, {"worlds", "World", "rna_Main_world_begin", "Worlds", "World datablocks.", RNA_def_main_worlds}, diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index d70962568e5..186334f12a4 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -594,7 +594,7 @@ void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop) { } -void RNA_def_main_vfonts(BlenderRNA *brna, PropertyRNA *cprop) +void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop) { } -- cgit v1.2.3 From ad068e6351e5b9b5d3c5e050602941a2fd8cdde6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 8 May 2010 07:34:01 +0000 Subject: remove BLI_strnlen, use _strnlen as strnlen on windows. cant test on windows but from what I can tell this exists like _vsnprintf --- source/blender/blenlib/BLI_string.h | 1 - source/blender/blenlib/intern/BLI_dynstr.c | 5 ++++- source/blender/blenlib/intern/string.c | 6 ------ 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h index 39123a438df..c722ffb1693 100644 --- a/source/blender/blenlib/BLI_string.h +++ b/source/blender/blenlib/BLI_string.h @@ -128,7 +128,6 @@ char *BLI_strcasestr(const char *s, const char *find); int BLI_strcasecmp(const char *s1, const char *s2); int BLI_strncasecmp(const char *s1, const char *s2, int n); int BLI_natstrcmp(const char *s1, const char *s2); -size_t BLI_strnlen(const char *str, size_t maxlen); void BLI_timestr(double _time, char *str); /* time var is global */ diff --git a/source/blender/blenlib/intern/BLI_dynstr.c b/source/blender/blenlib/intern/BLI_dynstr.c index 5b61a86305b..4754d3bd8c3 100644 --- a/source/blender/blenlib/intern/BLI_dynstr.c +++ b/source/blender/blenlib/intern/BLI_dynstr.c @@ -39,6 +39,9 @@ #ifndef vsnprintf #define vsnprintf _vsnprintf #endif +#ifndef strnlen +#define strnlen _strnlen +#endif #endif /***/ @@ -83,7 +86,7 @@ void BLI_dynstr_append(DynStr *ds, const char *cstr) { void BLI_dynstr_nappend(DynStr *ds, const char *cstr, int len) { DynStrElem *dse= malloc(sizeof(*dse)); - int cstrlen= BLI_strnlen(cstr, len); + int cstrlen= strnlen(cstr, len); dse->str= malloc(cstrlen+1); memcpy(dse->str, cstr, cstrlen); diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index c344d8c0711..bc9614667a7 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -342,9 +342,3 @@ void BLI_timestr(double _time, char *str) str[11]=0; } -/* determine the length of a fixed-size string */ -size_t BLI_strnlen(const char *str, size_t maxlen) -{ - const char *end = memchr(str, '\0', maxlen); - return end ? (size_t) (end - str) : maxlen; -} -- cgit v1.2.3 From d906d8ce3a1e93b95852b13b67783480b338a28a Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sat, 8 May 2010 07:48:37 +0000 Subject: Scons compile fix for SVN 28661. * Missing 'blenloader' include. --- source/blender/editors/space_console/SConscript | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/editors/space_console/SConscript b/source/blender/editors/space_console/SConscript index ecc10a1d0c3..d50902446ba 100644 --- a/source/blender/editors/space_console/SConscript +++ b/source/blender/editors/space_console/SConscript @@ -14,6 +14,7 @@ incs = [ '../../blenlib', '../../windowmanager', '../../blenfont', + '../../blenloader', ] if not env['WITH_BF_PYTHON']: -- cgit v1.2.3 From 9c1a9d93792ae1edfa384f5672473b288d170024 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 8 May 2010 15:37:29 +0000 Subject: revert own commit 28662. strnlen is a GNU extension according to http://unixpapa.com/incnote/string.html --- source/blender/blenlib/BLI_string.h | 1 + source/blender/blenlib/intern/BLI_dynstr.c | 5 +---- source/blender/blenlib/intern/string.c | 6 ++++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h index c722ffb1693..39123a438df 100644 --- a/source/blender/blenlib/BLI_string.h +++ b/source/blender/blenlib/BLI_string.h @@ -128,6 +128,7 @@ char *BLI_strcasestr(const char *s, const char *find); int BLI_strcasecmp(const char *s1, const char *s2); int BLI_strncasecmp(const char *s1, const char *s2, int n); int BLI_natstrcmp(const char *s1, const char *s2); +size_t BLI_strnlen(const char *str, size_t maxlen); void BLI_timestr(double _time, char *str); /* time var is global */ diff --git a/source/blender/blenlib/intern/BLI_dynstr.c b/source/blender/blenlib/intern/BLI_dynstr.c index 4754d3bd8c3..5b61a86305b 100644 --- a/source/blender/blenlib/intern/BLI_dynstr.c +++ b/source/blender/blenlib/intern/BLI_dynstr.c @@ -39,9 +39,6 @@ #ifndef vsnprintf #define vsnprintf _vsnprintf #endif -#ifndef strnlen -#define strnlen _strnlen -#endif #endif /***/ @@ -86,7 +83,7 @@ void BLI_dynstr_append(DynStr *ds, const char *cstr) { void BLI_dynstr_nappend(DynStr *ds, const char *cstr, int len) { DynStrElem *dse= malloc(sizeof(*dse)); - int cstrlen= strnlen(cstr, len); + int cstrlen= BLI_strnlen(cstr, len); dse->str= malloc(cstrlen+1); memcpy(dse->str, cstr, cstrlen); diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index bc9614667a7..c344d8c0711 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -342,3 +342,9 @@ void BLI_timestr(double _time, char *str) str[11]=0; } +/* determine the length of a fixed-size string */ +size_t BLI_strnlen(const char *str, size_t maxlen) +{ + const char *end = memchr(str, '\0', maxlen); + return end ? (size_t) (end - str) : maxlen; +} -- cgit v1.2.3 From 5371c54a4cc9043fc300834c57855117f5553ad3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 8 May 2010 16:36:28 +0000 Subject: bugfix [#21085] Sequencer file selector for movies is strange elubie fixed the first part, this fixes the internal data updating while keeping the frame range. --- source/blender/blenkernel/BKE_sequencer.h | 2 +- source/blender/blenkernel/intern/sequencer.c | 24 ++++++++++++++++++---- .../editors/space_sequencer/sequencer_edit.c | 9 ++++---- source/blender/makesrna/intern/rna_sequencer.c | 14 ++++++++++--- 4 files changed, 37 insertions(+), 12 deletions(-) diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 2bf6eee5e6b..354638013ec 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -154,7 +154,7 @@ void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown, i void calc_sequence(struct Scene *scene, struct Sequence *seq); void calc_sequence_disp(struct Scene *scene, struct Sequence *seq); void new_tstripdata(struct Sequence *seq); -void reload_sequence_new_file(struct Scene *scene, struct Sequence * seq); +void reload_sequence_new_file(struct Scene *scene, struct Sequence * seq, int lock_range); void sort_seq(struct Scene *scene); void build_seqar_cb(struct ListBase *seqbase, struct Sequence ***seqar, int *totseq, int (*test_func)(struct Sequence * seq)); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 4a9624036ff..245de6213d5 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -566,9 +566,12 @@ void calc_sequence(Scene *scene, Sequence *seq) } } -void reload_sequence_new_file(Scene *scene, Sequence * seq) +/* note: caller should run calc_sequence(scene, seq) */ +void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range) { char str[FILE_MAXDIR+FILE_MAXFILE]; + int prev_startdisp, prev_enddisp; + /* note: dont rename the strip, will break animation curves */ if (!(seq->type == SEQ_MOVIE || seq->type == SEQ_IMAGE || seq->type == SEQ_SOUND || @@ -576,6 +579,14 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) return; } + if(lock_range) { + /* keep so we dont have to move the actual start and end points (only the data) */ + calc_sequence_disp(scene, seq); + prev_startdisp= seq->startdisp; + prev_enddisp= seq->enddisp; + } + + new_tstripdata(seq); if (seq->type != SEQ_SCENE && seq->type != SEQ_META && @@ -587,6 +598,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) if (seq->type == SEQ_IMAGE) { /* Hack? */ size_t olen = MEM_allocN_len(seq->strip->stripdata)/sizeof(struct StripElem); + seq->len = olen; seq->len -= seq->anim_startofs; seq->len -= seq->anim_endofs; @@ -621,6 +633,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) } seq->strip->len = seq->len; } else if (seq->type == SEQ_SCENE) { + /* 'seq->scenenr' should be replaced with something more reliable */ Scene * sce = G.main->scene.first; int nr = 1; @@ -637,9 +650,6 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) } else { sce = seq->scene; } - - BLI_strncpy(seq->name+2, sce->id.name + 2, SEQ_NAME_MAXSTR-2); - seqbase_unique_name_recursive(&scene->ed->seqbase, seq); seq->len= seq->scene->r.efra - seq->scene->r.sfra + 1; seq->len -= seq->anim_startofs; @@ -652,6 +662,12 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) free_proxy_seq(seq); + if(lock_range) { + seq_tx_set_final_left(seq, prev_startdisp); + seq_tx_set_final_right(seq, prev_enddisp); + seq_single_fix(seq); + } + calc_sequence(scene, seq); } diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 1154ed02a3e..164ca6c21b0 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -946,7 +946,7 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence * seq, int cutframe) } } - reload_sequence_new_file(scene, seq); + reload_sequence_new_file(scene, seq, FALSE); calc_sequence(scene, seq); if (!skip_dup) { @@ -985,8 +985,8 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence * seq, int cutframe) seqn->startstill = 0; } - reload_sequence_new_file(scene, seqn); - calc_sequence(scene, seqn); + reload_sequence_new_file(scene, seqn, FALSE); + calc_sequence(scene, seq); } return seqn; } @@ -1178,7 +1178,8 @@ void set_filter_seq(Scene *scene) if(seq->flag & SELECT) { if(seq->type==SEQ_MOVIE) { seq->flag |= SEQ_FILTERY; - reload_sequence_new_file(scene, seq); + reload_sequence_new_file(scene, seq, FALSE); + calc_sequence(scene, seq); } } diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 4af4727b43c..bbcc1f82826 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -137,7 +137,7 @@ static void rna_Sequence_anim_startofs_final_set(PointerRNA *ptr, int value) seq->anim_startofs = MIN2(value, seq->len + seq->anim_startofs); - reload_sequence_new_file(scene, seq); + reload_sequence_new_file(scene, seq, FALSE); rna_Sequence_frame_change_update(scene, seq); } @@ -148,7 +148,7 @@ static void rna_Sequence_anim_endofs_final_set(PointerRNA *ptr, int value) seq->anim_endofs = MIN2(value, seq->len + seq->anim_endofs); - reload_sequence_new_file(scene, seq); + reload_sequence_new_file(scene, seq, FALSE); rna_Sequence_frame_change_update(scene, seq); } @@ -431,6 +431,14 @@ static void rna_Sequence_mute_update(Main *bmain, Scene *scene, PointerRNA *ptr) rna_Sequence_update(bmain, scene, ptr); } +static void rna_Sequence_filepath_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + Sequence *seq= (Sequence*)(ptr->data); + reload_sequence_new_file(scene, seq, TRUE); + calc_sequence(scene, seq); + rna_Sequence_update(bmain, scene, ptr); +} + /* do_versions? */ static float rna_Sequence_opacity_get(PointerRNA *ptr) { return ((Sequence*)(ptr->data))->blend_opacity / 100.0f; @@ -1014,7 +1022,7 @@ static void rna_def_movie(BlenderRNA *brna) RNA_def_property_ui_text(prop, "File", ""); RNA_def_property_string_funcs(prop, "rna_Sequence_filepath_get", "rna_Sequence_filepath_length", "rna_Sequence_filepath_set"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_filepath_update"); rna_def_filter_video(srna); rna_def_proxy(srna); -- cgit v1.2.3 From 5afd3f192ae18c025c8ebe6011c7d0b2956f2d16 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 8 May 2010 17:54:29 +0000 Subject: bugfix [#22281] Edit mode face selection dots gone from textured viewport mode tweaked the logic for drawing face dots --- source/blender/editors/space_view3d/drawobject.c | 31 +++++++++++++++++------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 9cfeb04d080..70f20df507b 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -105,13 +105,6 @@ ((vd->drawtype==OB_TEXTURE && dt>OB_SOLID) || \ (vd->drawtype==OB_SOLID && vd->flag2 & V3D_SOLID_TEX)) -#define CHECK_OB_DRAWFACEDOT(sce, vd, dt) \ -( (sce->toolsettings->selectmode & SCE_SELECT_FACE) && \ - (vd->drawtype<=OB_SOLID) && \ - (G.f & G_BACKBUFSEL)==0 && \ - (((vd->drawtype==OB_SOLID) && (dt>=OB_SOLID) && (vd->flag2 & V3D_SOLID_TEX) && (vd->flag & V3D_ZBUF_SELECT)) == 0) \ - ) - static void draw_bounding_volume(Scene *scene, Object *ob); static void drawcube_size(float size); @@ -119,6 +112,26 @@ static void drawcircle_size(float size); static void draw_empty_sphere(float size); static void draw_empty_cone(float size); +static int check_ob_drawface_dot(Scene *sce, View3D *vd, char dt) +{ + if((sce->toolsettings->selectmode & SCE_SELECT_FACE) == 0) + return 0; + + if(G.f & G_BACKBUFSEL) + return 0; + + if((vd->flag & V3D_ZBUF_SELECT) == 0) + return 1; + + /* if its drawing textures with zbuf sel, then dont draw dots */ + if(dt==OB_TEXTURE && vd->drawtype==OB_TEXTURE) + return 0; + + if(vd->drawtype>=OB_SOLID && vd->flag2 & V3D_SOLID_TEX) + return 0; + + return 1; +} /* ************* only use while object drawing ************** * or after running ED_view3d_init_mats_rv3d @@ -1980,7 +1993,7 @@ static void draw_em_fancy_verts(Scene *scene, View3D *v3d, Object *obedit, EditM draw_dm_verts(cageDM, sel, eve_act); } - if( CHECK_OB_DRAWFACEDOT(scene, v3d, obedit->dt) ) { + if(check_ob_drawface_dot(scene, v3d, obedit->dt)) { glPointSize(fsize); glColor4ubv((GLubyte *)fcol); draw_dm_face_centers(cageDM, sel); @@ -6293,7 +6306,7 @@ static void bbs_mesh_solid_EM(Scene *scene, View3D *v3d, Object *ob, DerivedMesh if (facecol) { dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, (void*)(intptr_t) 1, 0); - if( CHECK_OB_DRAWFACEDOT(scene, v3d, ob->dt) ) { + if(check_ob_drawface_dot(scene, v3d, ob->dt)) { glPointSize(UI_GetThemeValuef(TH_FACEDOT_SIZE)); bglBegin(GL_POINTS); -- cgit v1.2.3 From d58a591072059f0cb0af905790045aabc5a2b614 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 8 May 2010 19:08:33 +0000 Subject: Sequencer crashes with clips that have OpenGl render enabled (rev 28658) disabling for now, opengl write rendering isnt drivial to solve. --- release/scripts/ui/space_sequencer.py | 2 ++ source/blender/blenkernel/intern/sequencer.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/release/scripts/ui/space_sequencer.py b/release/scripts/ui/space_sequencer.py index ca31e134e59..9460905bd85 100644 --- a/release/scripts/ui/space_sequencer.py +++ b/release/scripts/ui/space_sequencer.py @@ -382,11 +382,13 @@ class SEQUENCER_PT_preview(bpy.types.Panel): col.active = render.use_sequencer_gl_preview col.prop(render, "sequencer_gl_preview", text="") + ''' col = layout.column() col.prop(render, "use_sequencer_gl_render", text="Open GL Render") col = layout.column() col.active = render.use_sequencer_gl_render col.prop(render, "sequencer_gl_render", text="") + ''' class SEQUENCER_PT_effect(SequencerButtonsPanel): diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 245de6213d5..f1e60ee2cfd 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2178,7 +2178,7 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int int rendering = G.rendering; int doseq; - int doseq_gl= G.rendering ? (scene->r.seq_flag & R_SEQ_GL_REND) : (scene->r.seq_flag & R_SEQ_GL_PREV); + int doseq_gl= G.rendering ? /*(scene->r.seq_flag & R_SEQ_GL_REND)*/ 0 : (scene->r.seq_flag & R_SEQ_GL_PREV); /* prevent eternal loop */ doseq= scene->r.scemode & R_DOSEQ; -- cgit v1.2.3 From 79d5d623e05e43e0102fe734312d0cfce815f6ad Mon Sep 17 00:00:00 2001 From: Joilnen Leite Date: Sat, 8 May 2010 19:48:28 +0000 Subject: Fixing the makefiles compiling --- source/blender/editors/space_console/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/editors/space_console/Makefile b/source/blender/editors/space_console/Makefile index a7c9283985b..3f760b1ad67 100644 --- a/source/blender/editors/space_console/Makefile +++ b/source/blender/editors/space_console/Makefile @@ -43,6 +43,7 @@ CPPFLAGS += -I../../windowmanager CPPFLAGS += -I../../blenfont CPPFLAGS += -I../../blenkernel CPPFLAGS += -I../../blenlib +CPPFLAGS += -I../../blenloader CPPFLAGS += -I../../makesdna CPPFLAGS += -I../../makesrna CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include -- cgit v1.2.3 From 2909a4988b2895d067a3626b47a68aaa9b61c737 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Sat, 8 May 2010 19:52:13 +0000 Subject: Logic UI: add notifiers for sensors and controllers (so the ui updates if you change the value through script) + some layout adjusments. --- source/blender/editors/space_logic/logic_window.c | 21 ++++---- source/blender/makesrna/intern/rna_controller.c | 10 ++++ source/blender/makesrna/intern/rna_sensor.c | 61 ++++++++++++++++++++++- 3 files changed, 81 insertions(+), 11 deletions(-) diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index d278cf16fd4..3b8ed083ad0 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -3483,21 +3483,22 @@ static void draw_controller_header(uiLayout *layout, PointerRNA *ptr) static void draw_controller_expression(uiLayout *layout, PointerRNA *ptr) { - uiItemR(layout, ptr, "expression", 0, NULL, 0); + uiItemR(layout, ptr, "expression", 0, "", 0); } static void draw_controller_python(uiLayout *layout, PointerRNA *ptr) { - uiLayout *row; + uiLayout *row, *split, *subsplit; - uiItemR(layout, ptr, "mode", 0, NULL, 0); + split = uiLayoutSplit(layout, 0.3, 1); + uiItemR(split, ptr, "mode", 0, "", 0); if (RNA_enum_get(ptr, "mode") == CONT_PY_SCRIPT) { - uiItemR(layout, ptr, "text", 0, NULL, 0); + uiItemR(split, ptr, "text", 0, "", 0); } else { - row= uiLayoutRow(layout, 0); - uiItemR(row, ptr, "module", 0, NULL, 0); - uiItemR(row, ptr, "debug", 0, NULL, 0); + subsplit = uiLayoutSplit(split, 0.8, 0); + uiItemR(subsplit, ptr, "module", 0, "", 0); + uiItemR(subsplit, ptr, "debug", UI_ITEM_R_TOGGLE, NULL, 0); } } @@ -3558,7 +3559,7 @@ static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr) uiLayout *row; row= uiLayoutRow(layout, 0); - uiItemR(row, ptr, "mode", 0, NULL, 0); + uiItemR(row, ptr, "mode", 0, "", 0); uiItemR(row, ptr, "action", 0, NULL, 0); uiItemR(row, ptr, "continue_last_frame", 0, NULL, 0); @@ -3811,7 +3812,7 @@ static void draw_actuator_ipo(uiLayout *layout, PointerRNA *ptr) uiLayout *row, *subrow, *col; row= uiLayoutRow(layout, 0); - uiItemR(row, ptr, "play_type", 0, NULL, 0); + uiItemR(row, ptr, "play_type", 0, "", 0); subrow= uiLayoutRow(row, 1); uiItemR(subrow, ptr, "force", UI_ITEM_R_TOGGLE, NULL, 0); uiItemR(subrow, ptr, "add", UI_ITEM_R_TOGGLE, NULL, 0); @@ -4058,7 +4059,7 @@ static void draw_actuator_shape_action(uiLayout *layout, PointerRNA *ptr) uiLayout *row; row= uiLayoutRow(layout, 0); - uiItemR(row, ptr, "mode", 0, NULL, 0); + uiItemR(row, ptr, "mode", 0, "", 0); uiItemR(row, ptr, "action", 0, NULL, 0); uiItemR(row, ptr, "continue_last_frame", 0, NULL, 0); diff --git a/source/blender/makesrna/intern/rna_controller.c b/source/blender/makesrna/intern/rna_controller.c index 3d44730cf76..dd174c668f2 100644 --- a/source/blender/makesrna/intern/rna_controller.c +++ b/source/blender/makesrna/intern/rna_controller.c @@ -24,6 +24,7 @@ #include +#include "WM_types.h" #include "RNA_define.h" #include "rna_internal.h" @@ -102,22 +103,26 @@ void RNA_def_controller(BlenderRNA *brna) prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Name", ""); RNA_def_struct_name_property(srna, prop); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_enum_funcs(prop, NULL, "rna_Controller_type_set", NULL); RNA_def_property_enum_items(prop, controller_type_items); RNA_def_property_ui_text(prop, "Type", ""); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "expanded", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CONT_SHOW); RNA_def_property_ui_text(prop, "Expanded", "Set controller expanded in the user interface"); RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "priority", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CONT_PRIO); RNA_def_property_ui_text(prop, "Priority", "Mark controller for execution before all non-marked controllers (good for startup scripts)"); RNA_def_property_ui_icon(prop, ICON_BOOKMARKS, 1); + RNA_def_property_update(prop, NC_LOGIC, NULL); /* Expression Controller */ srna= RNA_def_struct(brna, "ExpressionController", "Controller"); @@ -128,6 +133,7 @@ void RNA_def_controller(BlenderRNA *brna) RNA_def_property_string_sdna(prop, NULL, "str"); RNA_def_property_string_maxlength(prop, 127); RNA_def_property_ui_text(prop, "Expression", ""); + RNA_def_property_update(prop, NC_LOGIC, NULL); /* Python Controller */ srna= RNA_def_struct(brna, "PythonController", "Controller" ); @@ -137,19 +143,23 @@ void RNA_def_controller(BlenderRNA *brna) prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, python_controller_modes); RNA_def_property_ui_text(prop, "Execution Method", "Python script type (textblock or module - faster)"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "text", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Text"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Text", "Text datablock with the python script"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "module", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Module", "Module name and function to run e.g. \"someModule.main\". Internal texts and external python files can be used"); RNA_def_struct_name_property(srna, prop); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "debug", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CONT_PY_DEBUG); RNA_def_property_ui_text(prop, "D", "Continuously reload the module from disk for editing external modules without restarting"); + RNA_def_property_update(prop, NC_LOGIC, NULL); /* Other Controllers */ srna= RNA_def_struct(brna, "AndController", "Controller"); diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index edae9ab36b6..3621d6bb6d0 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -195,40 +195,49 @@ static void rna_def_sensor(BlenderRNA *brna) prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Name", "Sensor name"); RNA_def_struct_name_property(srna, prop); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_enum_items(prop, sensor_type_items); RNA_def_property_enum_funcs(prop, NULL, "rna_Sensor_type_set", "rna_Sensor_type_itemf"); RNA_def_property_ui_text(prop, "Type", ""); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "expanded", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_SHOW); RNA_def_property_ui_text(prop, "Expanded", "Set sensor expanded in the user interface"); RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); - + RNA_def_property_update(prop, NC_LOGIC, NULL); + prop= RNA_def_property(srna, "invert", PROP_BOOLEAN, PROP_NONE); RNA_def_property_ui_text(prop, "Invert Output", "Invert the level(output) of this sensor"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "level", PROP_BOOLEAN, PROP_NONE); RNA_def_property_ui_text(prop, "Level", "Level detector, trigger controllers of new states(only applicable upon logic state transition)"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "pulse_true_level", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "pulse", SENS_PULSE_REPEAT); RNA_def_property_ui_text(prop, "Pulse True Level", "Activate TRUE level triggering (pulse mode)"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "pulse_false_level", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "pulse", SENS_NEG_PULSE_MODE); RNA_def_property_ui_text(prop, "Pulse False Level", "Activate FALSE level triggering (pulse mode)"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "frequency", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "freq"); RNA_def_property_ui_text(prop, "Frequency", "Delay between repeated pulses(in logic tics, 0=no delay)"); RNA_def_property_range(prop, 0, 10000); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "tap", PROP_BOOLEAN, PROP_NONE);\ RNA_def_property_boolean_sdna(prop, NULL, "tap", 1); RNA_def_property_ui_text(prop, "Tap", "Trigger controllers only for an instant, even while the sensor remains true"); + RNA_def_property_update(prop, NC_LOGIC, NULL); } static void rna_def_always_sensor(BlenderRNA *brna) @@ -250,16 +259,19 @@ static void rna_def_near_sensor(BlenderRNA *brna) prop= RNA_def_property(srna, "property", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "name"); RNA_def_property_ui_text(prop, "Property", "Only look for objects with this property"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "dist"); RNA_def_property_ui_text(prop, "Distance", "Trigger distance"); RNA_def_property_range(prop, 0.0f, 10000.0f); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "reset_distance", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "resetdist"); RNA_def_property_ui_text(prop, "Reset Distance", ""); RNA_def_property_range(prop, 0.0f, 10000.0f); + RNA_def_property_update(prop, NC_LOGIC, NULL); } static void rna_def_mouse_sensor(BlenderRNA *brna) @@ -286,6 +298,7 @@ static void rna_def_mouse_sensor(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "type"); RNA_def_property_enum_items(prop, mouse_event_items); RNA_def_property_ui_text(prop, "Mouse Event", "Specify the type of event this mouse sensor should trigger on"); + RNA_def_property_update(prop, NC_LOGIC, NULL); } static void rna_def_touch_sensor(BlenderRNA *brna) @@ -302,6 +315,7 @@ static void rna_def_touch_sensor(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "ma"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Material", "Only look for floors with this material"); + RNA_def_property_update(prop, NC_LOGIC, NULL); } static void rna_def_keyboard_sensor(BlenderRNA *brna) @@ -318,30 +332,36 @@ static void rna_def_keyboard_sensor(BlenderRNA *brna) RNA_def_property_enum_items(prop, event_type_items); RNA_def_property_enum_funcs(prop, NULL, "rna_Sensor_keyboard_key_set", NULL); RNA_def_property_ui_text(prop, "Key", ""); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "modifier_key", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "qual"); RNA_def_property_enum_items(prop, event_type_items); RNA_def_property_enum_funcs(prop, NULL, "rna_Sensor_keyboard_modifier_set", NULL); RNA_def_property_ui_text(prop, "Modifier Key", "Modifier key code"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "second_modifier_key", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "qual2"); RNA_def_property_enum_items(prop, event_type_items); RNA_def_property_enum_funcs(prop, NULL, "rna_Sensor_keyboard_modifier2_set", NULL); RNA_def_property_ui_text(prop, "Second Modifier Key", "Modifier key code"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "target", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "targetName"); RNA_def_property_ui_text(prop, "Target", "Property that indicates whether to log keystrokes as a string"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "log", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "toggleName"); RNA_def_property_ui_text(prop, "Log Toggle", "Property that receive the keystrokes in case a string is logged"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "all_keys", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "type", 1); RNA_def_property_ui_text(prop, "All Keys", "Trigger this sensor on any keystroke"); + RNA_def_property_update(prop, NC_LOGIC, NULL); } static void rna_def_property_sensor(BlenderRNA *brna) @@ -364,22 +384,27 @@ static void rna_def_property_sensor(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "type"); RNA_def_property_enum_items(prop, prop_type_items); RNA_def_property_ui_text(prop, "Evaluation Type", "Type of property evaluation"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "property", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "name"); RNA_def_property_ui_text(prop, "Property", ""); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "value", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "value"); RNA_def_property_ui_text(prop, "Value", "Check for this value in types in Equal or Not Equal types"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "min_value", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "value"); RNA_def_property_ui_text(prop, "Minimum Value", "Specify minimum value in Interval type"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "max_value", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "maxvalue"); RNA_def_property_ui_text(prop, "Maximum Value", "Specify maximum value in Interval type"); + RNA_def_property_update(prop, NC_LOGIC, NULL); } static void rna_def_armature_sensor(BlenderRNA *brna) @@ -402,18 +427,22 @@ static void rna_def_armature_sensor(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "type"); RNA_def_property_enum_items(prop, prop_type_items); RNA_def_property_ui_text(prop, "Test Type", "Type of value and test"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "channel_name", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "posechannel"); RNA_def_property_ui_text(prop, "Bone name", "Identify the bone to check value from"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "constraint_name", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "constraint"); RNA_def_property_ui_text(prop, "Constraint name", "Identify the bone constraint to check value from"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "value"); RNA_def_property_ui_text(prop, "Compare Value", "Specify value to be used in comparison"); + RNA_def_property_update(prop, NC_LOGIC, NULL); } static void rna_def_actuator_sensor(BlenderRNA *brna) @@ -429,6 +458,7 @@ static void rna_def_actuator_sensor(BlenderRNA *brna) prop= RNA_def_property(srna, "actuator", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "name"); RNA_def_property_ui_text(prop, "Actuator", "Actuator name, actuator active state modifications will be detected"); + RNA_def_property_update(prop, NC_LOGIC, NULL); } static void rna_def_delay_sensor(BlenderRNA *brna) @@ -443,14 +473,17 @@ static void rna_def_delay_sensor(BlenderRNA *brna) prop= RNA_def_property(srna, "delay", PROP_INT, PROP_NONE); RNA_def_property_ui_text(prop, "Delay", "Delay in number of logic tics before the positive trigger (default 60 per second)"); RNA_def_property_range(prop, 0, 5000); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "duration", PROP_INT, PROP_NONE); RNA_def_property_ui_text(prop, "Duration", "If >0, delay in number of logic tics before the negative trigger following the positive trigger"); RNA_def_property_range(prop, 0, 5000); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "repeat", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_DELAY_REPEAT); RNA_def_property_ui_text(prop, "Repeat", "Toggle repeat option. If selected, the sensor restarts after Delay+Dur logic tics"); + RNA_def_property_update(prop, NC_LOGIC, NULL); } static void rna_def_collision_sensor(BlenderRNA *brna) @@ -465,19 +498,23 @@ static void rna_def_collision_sensor(BlenderRNA *brna) prop= RNA_def_property(srna, "pulse", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", SENS_COLLISION_PULSE); RNA_def_property_ui_text(prop, "Pulse", "Changes to the set of colliding objects generates pulse"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "collision_type", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", SENS_COLLISION_MATERIAL); RNA_def_property_ui_text(prop, "M/P", "Toggle collision on material or property"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "property", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "name"); RNA_def_property_ui_text(prop, "Property", "Only look for Objects with this property"); + RNA_def_property_update(prop, NC_LOGIC, NULL); //XXX to make a setFunction to create a lookup with all materials in Blend File (not only this object mat.) prop= RNA_def_property(srna, "material", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "materialName"); RNA_def_property_ui_text(prop, "Material", "Only look for Objects with this material"); + RNA_def_property_update(prop, NC_LOGIC, NULL); /*//XXX either use a datablock look up to store the string name (material) // or to do a doversion and use a material pointer. @@ -509,19 +546,23 @@ static void rna_def_radar_sensor(BlenderRNA *brna) prop= RNA_def_property(srna, "property", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "name"); RNA_def_property_ui_text(prop, "Property", "Only look for Objects with this property"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, axis_items); RNA_def_property_ui_text(prop, "Axis", "Specify along which axis the radar cone is cast"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0, 179.9); RNA_def_property_ui_text(prop, "Angle", "Opening angle of the radar cone"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "range"); RNA_def_property_range(prop, 0.0, 10000.0); RNA_def_property_ui_text(prop, "Distance", "Depth of the radar cone"); + RNA_def_property_update(prop, NC_LOGIC, NULL); } static void rna_def_random_sensor(BlenderRNA *brna) @@ -536,6 +577,7 @@ static void rna_def_random_sensor(BlenderRNA *brna) prop= RNA_def_property(srna, "seed", PROP_INT, PROP_NONE); RNA_def_property_range(prop, 0, 1000); RNA_def_property_ui_text(prop, "Seed", "Initial seed of the generator. (Choose 0 for not random)"); + RNA_def_property_update(prop, NC_LOGIC, NULL); } static void rna_def_ray_sensor(BlenderRNA *brna) @@ -558,10 +600,12 @@ static void rna_def_ray_sensor(BlenderRNA *brna) prop= RNA_def_property(srna, "property", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "propname"); RNA_def_property_ui_text(prop, "Property", "Only look for Objects with this property"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "material", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "matname"); RNA_def_property_ui_text(prop, "Material", "Only look for Objects with this material"); + RNA_def_property_update(prop, NC_LOGIC, NULL); /* //XXX either use a datablock look up to store the string name (material) // or to do a doversion and use a material pointer. @@ -575,19 +619,23 @@ static void rna_def_ray_sensor(BlenderRNA *brna) prop= RNA_def_property(srna, "ray_type", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", SENS_COLLISION_MATERIAL); RNA_def_property_ui_text(prop, "M/P", "Toggle collision on material or property"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "x_ray_mode", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", SENS_RAY_XRAY); RNA_def_property_ui_text(prop, "X-Ray Mode", "Toggle X-Ray option (see through objects that don't have the property)"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "range", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.01, 10000.0); RNA_def_property_ui_text(prop, "Range", "Sense objects no farther than this distance"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "axisflag"); RNA_def_property_enum_items(prop, axis_items); RNA_def_property_ui_text(prop, "Axis", "Specify along which axis the ray is cast"); + RNA_def_property_update(prop, NC_LOGIC, NULL); } static void rna_def_message_sensor(BlenderRNA *brna) @@ -601,6 +649,7 @@ static void rna_def_message_sensor(BlenderRNA *brna) prop= RNA_def_property(srna, "subject", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Subject", "Optional subject filter: only accept messages with this subject, or empty for all"); + RNA_def_property_update(prop, NC_LOGIC, NULL); } static void rna_def_joystick_sensor(BlenderRNA *brna) @@ -642,54 +691,64 @@ static void rna_def_joystick_sensor(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "joyindex"); RNA_def_property_ui_text(prop, "Index", "Specify which joystick to use"); RNA_def_property_range(prop, 0, SENS_JOY_MAXINDEX-1); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "event_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "type"); RNA_def_property_enum_items(prop, event_type_items); RNA_def_property_ui_text(prop, "Event Type", "The type of event this joystick sensor is triggered on"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "all_events", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_JOY_ANY_EVENT); RNA_def_property_ui_text(prop, "All Events", "Triggered by all events on this joysticks current type (axis/button/hat)"); + RNA_def_property_update(prop, NC_LOGIC, NULL); /* Button */ prop= RNA_def_property(srna, "button_number", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "button"); RNA_def_property_ui_text(prop, "Button Number", "Specify which button to use"); RNA_def_property_range(prop, 0, 18); + RNA_def_property_update(prop, NC_LOGIC, NULL); /* Axis */ prop= RNA_def_property(srna, "axis_number", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "axis"); RNA_def_property_ui_text(prop, "Axis Number", "Specify which axis pair to use, 1 is usually the main direction input"); RNA_def_property_range(prop, 1, 2); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "axis_threshold", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "precision"); RNA_def_property_ui_text(prop, "Axis Threshold", "Specify the precision of the axis"); RNA_def_property_range(prop, 0, 32768); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "axis_direction", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "axisf"); RNA_def_property_enum_items(prop, axis_direction_items); RNA_def_property_ui_text(prop, "Axis Direction", "The direction of the axis"); + RNA_def_property_update(prop, NC_LOGIC, NULL); /* Single Axis */ prop= RNA_def_property(srna, "single_axis_number", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "axis_single"); RNA_def_property_ui_text(prop, "Axis Number", "Specify a single axis (verticle/horizontal/other) to detect"); RNA_def_property_range(prop, 1, 16); + RNA_def_property_update(prop, NC_LOGIC, NULL); /* Hat */ prop= RNA_def_property(srna, "hat_number", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "hat"); RNA_def_property_ui_text(prop, "Hat Number", "Specify which hat to use"); RNA_def_property_range(prop, 1, 2); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "hat_direction", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "hatf"); RNA_def_property_enum_items(prop, hat_direction_items); RNA_def_property_ui_text(prop, "Hat Direction", "Specify hat direction"); + RNA_def_property_update(prop, NC_LOGIC, NULL); } void RNA_def_sensor(BlenderRNA *brna) -- cgit v1.2.3 From 5741dbf6e48e71f4a30e496e948d04a44941adda Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 8 May 2010 20:07:29 +0000 Subject: render time wasnt being written to the metadata of images. --- source/blender/blenkernel/intern/image.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index a377bbed24c..eb478eaddf5 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1163,6 +1163,7 @@ void BKE_stamp_info(Scene *scene, struct ImBuf *ibuf) if (stamp_data.camera[0]) IMB_metadata_change_field (ibuf, "Camera", stamp_data.camera); if (stamp_data.scene[0]) IMB_metadata_change_field (ibuf, "Scene", stamp_data.scene); if (stamp_data.strip[0]) IMB_metadata_change_field (ibuf, "Strip", stamp_data.strip); + if (stamp_data.rendertime[0]) IMB_metadata_change_field (ibuf, "RenderTime", stamp_data.rendertime); } int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimtype, int quality) -- cgit v1.2.3 From 9aa39368cc2242dc2152ef21b2ed979d46d21f3a Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Sat, 8 May 2010 20:57:09 +0000 Subject: == MSVC projectfiles == - update for latest ImBuf changes --- projectfiles_vc9/blender/imbuf/BL_imbuf.vcproj | 134 ++++--------------------- 1 file changed, 19 insertions(+), 115 deletions(-) diff --git a/projectfiles_vc9/blender/imbuf/BL_imbuf.vcproj b/projectfiles_vc9/blender/imbuf/BL_imbuf.vcproj index 26bbab73154..fdee6ca9228 100644 --- a/projectfiles_vc9/blender/imbuf/BL_imbuf.vcproj +++ b/projectfiles_vc9/blender/imbuf/BL_imbuf.vcproj @@ -43,7 +43,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -844,51 +780,19 @@ > - - - - - - - - - - - - - - - - Date: Sat, 8 May 2010 21:02:22 +0000 Subject: == filebrowser == - smooth scrolling to editable button after new directory is created (for now scrolling starts as soon as the mouse moves back to the file list area, for Matt to check if immediate scrolling is possible) - fix for autocomplete directory, show first matching part if directory doesn't exist, otherwise won't work for directories starting with the same prefix like textures_walls and textures_grass for example. --- source/blender/editors/space_file/file_draw.c | 7 ++ source/blender/editors/space_file/file_intern.h | 1 + source/blender/editors/space_file/file_ops.c | 107 ++++++++++++++++++++++++ source/blender/editors/space_file/filesel.c | 6 +- source/blender/editors/space_file/space_file.c | 2 + source/blender/makesdna/DNA_space_types.h | 4 +- 6 files changed, 122 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index ac09ce6861a..03ab42b467d 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -514,6 +514,13 @@ void file_draw_list(const bContext *C, ARegion *ar) numfiles_layout = ED_fileselect_layout_numfiles(layout, ar); + /* adjust, so the next row is already drawn when scrolling */ + if (layout->flag & FILE_LAYOUT_HOR) { + numfiles_layout += layout->rows; + } else { + numfiles_layout += layout->columns; + } + for (i=offset; (i < numfiles) && (ismoothscroll_timer==NULL || sfile->smoothscroll_timer!=event->customdata) + return OPERATOR_PASS_THROUGH; + + numfiles = filelist_numfiles(sfile->files); + + /* check if we are editing a name */ + for (i=0; i < numfiles; ++i) + { + struct direntry *file = filelist_file(sfile->files, i); + if (file->flags & EDITING) { + edit_idx=i; + break; + } + } + + /* if we are not editing, we are done */ + if (0==edit_idx) { + WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer); + sfile->smoothscroll_timer=NULL; + return OPERATOR_PASS_THROUGH; + } + + /* we need the correct area for scrolling */ + if (!ar || ar->regiontype != RGN_TYPE_WINDOW) { + WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer); + sfile->smoothscroll_timer=NULL; + return OPERATOR_PASS_THROUGH; + } + + offset = ED_fileselect_layout_offset(sfile->layout, 0, ar->v2d.cur.xmin, -ar->v2d.cur.ymax); + if (offset<0) offset=0; + + /* scroll offset is the first file in the row/column we are editing in */ + if (sfile->scroll_offset == 0) { + if (sfile->layout->flag & FILE_LAYOUT_HOR) { + sfile->scroll_offset = (edit_idx/sfile->layout->rows)*sfile->layout->rows; + if (sfile->scroll_offset <= offset) sfile->scroll_offset -= sfile->layout->rows; + } else { + sfile->scroll_offset = (edit_idx/sfile->layout->columns)*sfile->layout->columns; + if (sfile->scroll_offset <= offset) sfile->scroll_offset -= sfile->layout->columns; + } + } + + numfiles_layout = ED_fileselect_layout_numfiles(sfile->layout, ar); + + /* check if we have reached our final scroll position */ + if ( (sfile->scroll_offset >= offset) && (sfile->scroll_offset < offset + numfiles_layout) ) { + WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer); + sfile->smoothscroll_timer=NULL; + return OPERATOR_FINISHED; + } + + /* scroll one step in the desired direction */ + if (sfile->scroll_offset < offset) { + if (sfile->layout->flag & FILE_LAYOUT_HOR) { + WM_operator_name_call(C, "VIEW2D_OT_scroll_left", 0, NULL); + } else { + WM_operator_name_call(C, "VIEW2D_OT_scroll_up", 0, NULL); + } + + } else { + if (sfile->layout->flag & FILE_LAYOUT_HOR) { + WM_operator_name_call(C, "VIEW2D_OT_scroll_right", 0, NULL); + } else { + WM_operator_name_call(C, "VIEW2D_OT_scroll_down", 0, NULL); + } + } + + ED_region_tag_redraw(CTX_wm_region(C)); + + return OPERATOR_FINISHED; +} + + +void FILE_OT_smoothscroll(wmOperatorType *ot) +{ + + /* identifiers */ + ot->name= "Smooth Scroll"; + ot->idname= "FILE_OT_smoothscroll"; + ot->description="Smooth scroll to make editable file visible."; + + /* api callbacks */ + ot->invoke= file_smoothscroll_invoke; + + ot->poll= ED_operator_file_active; +} + + /* create a new, non-existing folder name, returns 1 if successful, 0 if name couldn't be created. The actual name is returned in 'name', 'folder' contains the complete path, including the new folder name. */ @@ -794,6 +895,12 @@ int file_directory_new_exec(bContext *C, wmOperator *op) /* now remember file to jump into editing */ BLI_strncpy(sfile->params->renamefile, name, FILE_MAXFILE); + + /* set timer to smoothly view newly generated file */ + sfile->smoothscroll_timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER1, 1.0/1000.0); /* max 30 frs/sec */ + sfile->scroll_offset=0; + + /* reload dir to make sure we're seeing what's in the directory */ ED_fileselect_clear(C, sfile); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 916f8dfcd62..f971e18043c 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -213,11 +213,11 @@ int ED_fileselect_layout_numfiles(FileLayout* layout, struct ARegion *ar) if (layout->flag & FILE_LAYOUT_HOR) { int width = ar->v2d.cur.xmax - ar->v2d.cur.xmin - 2*layout->tile_border_x; - numfiles = width/layout->tile_w + 1; + numfiles = (float)width/(float)layout->tile_w+0.5; return numfiles*layout->rows; } else { int height = ar->v2d.cur.ymax - ar->v2d.cur.ymin - 2*layout->tile_border_y; - numfiles = height/layout->tile_h + 1; + numfiles = (float)height/(float)layout->tile_h+0.5; return numfiles*layout->columns; } } @@ -482,7 +482,7 @@ void autocomplete_directory(struct bContext *C, char *str, void *arg_v) if (BLI_exists(str)) { BLI_add_slash(str); } else { - BLI_make_exist(str); + BLI_strncpy(sfile->params->dir, str, sizeof(sfile->params->dir)); } } } diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index efdd8cb0db1..550871f9419 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -364,6 +364,7 @@ void file_operatortypes(void) WM_operatortype_append(FILE_OT_directory_new); WM_operatortype_append(FILE_OT_delete); WM_operatortype_append(FILE_OT_rename); + WM_operatortype_append(FILE_OT_smoothscroll); } /* NOTE: do not add .blend file reading on this level */ @@ -408,6 +409,7 @@ void file_keymap(struct wmKeyConfig *keyconf) RNA_int_set(kmi->ptr, "increment", -10); kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_CTRL, 0); RNA_int_set(kmi->ptr, "increment",-100); + WM_keymap_verify_item(keymap, "FILE_OT_smoothscroll", TIMER1, KM_ANY, KM_ANY, 0); /* keys for button area (top) */ keymap= WM_keymap_find(keyconf, "File Browser Buttons", SPACE_FILE, 0); diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 70419b6a662..e59cad09d6c 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -187,7 +187,7 @@ typedef struct SpaceFile { SpaceLink *next, *prev; ListBase regionbase; /* storage of regions for inactive spaces */ int spacetype; - int pad; + int scroll_offset; struct FileSelectParams *params; /* config and input for file select */ @@ -203,7 +203,7 @@ typedef struct SpaceFile { */ struct wmOperator *op; - struct wmTimer *loadimage_timer; + struct wmTimer *smoothscroll_timer; struct FileLayout *layout; -- cgit v1.2.3 From 94cd746566eac365605813f0b7b9a5ed93eec271 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Sat, 8 May 2010 22:11:00 +0000 Subject: Logic UI - lookup for properties (matt need your help to finish it) I based this code on drawnode, so I hope this is the right way of doing this. Working Sensors: - keyboard - property Working Actuators: - property (partly) - ipo - action - shape action - message - random Need help with: - actuator sensor - property actuator (for the second object) - touch/ray/collision sensors + constraint actuator (for the material lookup, not the property one) maybe a doversion + changing the type to material work better here (as we have in touch sensor) + added notifier for the game property. --- source/blender/editors/space_logic/logic_window.c | 88 +++++++++++++++++------ source/blender/makesrna/intern/rna_actuator.c | 17 +++-- source/blender/makesrna/intern/rna_property.c | 11 +++ source/blender/makesrna/intern/rna_sensor.c | 2 +- 4 files changed, 90 insertions(+), 28 deletions(-) diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 3b8ed083ad0..e554d869a4a 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -3208,6 +3208,14 @@ static void draw_sensor_internal_header(uiLayout *layout, PointerRNA *ptr) static void draw_sensor_actuator(uiLayout *layout, PointerRNA *ptr) { + /* -- couldnt make it work for actuators + Object *ob = (Object *)ptr->id.data; + PointerRNA settings_ptr; + + RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); + uiItemPointerR(layout, ptr, "actuator", &settings_ptr, "actuators", "", 0); + */ + uiItemR(layout, ptr, "actuator", 0, NULL, 0); } @@ -3296,6 +3304,8 @@ static void draw_sensor_joystick(uiLayout *layout, PointerRNA *ptr) static void draw_sensor_keyboard(uiLayout *layout, PointerRNA *ptr) { + Object *ob = (Object *)ptr->id.data; + PointerRNA settings_ptr; uiLayout *row, *col; row = uiLayoutRow(layout, 0); @@ -3315,9 +3325,13 @@ static void draw_sensor_keyboard(uiLayout *layout, PointerRNA *ptr) row = uiLayoutRow(col, 0); uiItemL(row, "Second Modifier:", 0); uiItemR(row, ptr, "second_modifier_key", UI_ITEM_R_EVENT, "", 0); - - uiItemR(layout, ptr, "target", 0, NULL, 0); - uiItemR(layout, ptr, "log", 0, NULL, 0); + + RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); + uiItemPointerR(layout, ptr, "target", &settings_ptr, "properties", NULL, 0); + uiItemPointerR(layout, ptr, "log", &settings_ptr, "properties", NULL, 0); + +// uiItemR(layout, ptr, "target", 0, NULL, 0); +// uiItemR(layout, ptr, "log", 0, NULL, 0); } static void draw_sensor_message(uiLayout *layout, PointerRNA *ptr) @@ -3343,9 +3357,14 @@ static void draw_sensor_near(uiLayout *layout, PointerRNA *ptr) static void draw_sensor_property(uiLayout *layout, PointerRNA *ptr) { + Object *ob = (Object *)ptr->id.data; + PointerRNA settings_ptr; + uiLayout *row; uiItemR(layout, ptr, "evaluation_type", 0, NULL, 0); - uiItemR(layout, ptr, "property", 0, NULL, 0); + + RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); + uiItemPointerR(layout, ptr, "property", &settings_ptr, "properties", NULL, 0); switch (RNA_enum_get(ptr, "evaluation_type")) { case SENS_PROP_INTERVAL: @@ -3556,8 +3575,12 @@ static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr) static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr) { + Object *ob = (Object *)ptr->id.data; + PointerRNA settings_ptr; uiLayout *row; + RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); + row= uiLayoutRow(layout, 0); uiItemR(row, ptr, "mode", 0, "", 0); uiItemR(row, ptr, "action", 0, NULL, 0); @@ -3565,7 +3588,7 @@ static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr) row= uiLayoutRow(layout, 0); if((RNA_enum_get(ptr, "mode") == ACT_ACTION_FROM_PROP)) - uiItemR(row, ptr, "property", 0, NULL, 0); + uiItemPointerR(row, ptr, "property", &settings_ptr, "properties", NULL, 0); else { uiItemR(row, ptr, "frame_start", 0, NULL, 0); @@ -3577,7 +3600,7 @@ static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr) uiItemR(row, ptr, "priority", 0, NULL, 0); row= uiLayoutRow(layout, 0); - uiItemR(row, ptr, "frame_property", 0, NULL, 0); + uiItemPointerR(layout, ptr, "frame_property", &settings_ptr, "properties", NULL, 0); #ifdef __NLA_ACTION_BY_MOTION_ACTUATOR uiItemR(row, "stride_length", 0, NULL, 0); @@ -3809,8 +3832,13 @@ static void draw_actuator_game(uiLayout *layout, PointerRNA *ptr) static void draw_actuator_ipo(uiLayout *layout, PointerRNA *ptr) { + Object *ob; + PointerRNA settings_ptr; uiLayout *row, *subrow, *col; + ob = (Object *)ptr->id.data; + RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); + row= uiLayoutRow(layout, 0); uiItemR(row, ptr, "play_type", 0, "", 0); subrow= uiLayoutRow(row, 1); @@ -3823,7 +3851,7 @@ static void draw_actuator_ipo(uiLayout *layout, PointerRNA *ptr) row= uiLayoutRow(layout, 0); if((RNA_enum_get(ptr, "play_type") == ACT_IPO_FROM_PROP)) - uiItemR(row, ptr, "property", 0, NULL, 0); + uiItemPointerR(row, ptr, "property", &settings_ptr, "properties", NULL, 0); else { uiItemR(row, ptr, "frame_start", 0, NULL, 0); @@ -3832,31 +3860,37 @@ static void draw_actuator_ipo(uiLayout *layout, PointerRNA *ptr) uiItemR(row, ptr, "child", 0, NULL, 0); row= uiLayoutRow(layout, 0); - uiItemR(row, ptr, "frame_property", 0, NULL, 0); + uiItemPointerR(row, ptr, "frame_property", &settings_ptr, "properties", NULL, 0); } static void draw_actuator_message(uiLayout *layout, PointerRNA *ptr) { + Object *ob; + PointerRNA settings_ptr; uiLayout *row; + ob = (Object *)ptr->id.data; + RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); + uiItemR(layout, ptr, "to_property", 0, NULL, 0); uiItemR(layout, ptr, "subject", 0, NULL, 0); - row= uiLayoutRow(layout, 0); + row= uiLayoutRow(layout, 1); uiItemR(row, ptr, "body_type", 0, NULL, 0); if(RNA_enum_get(ptr, "body_type") == ACT_MESG_MESG) - uiItemR(row, ptr, "body_message", 0, NULL, 0); + uiItemR(row, ptr, "body_message", 0, "", 0); else // mode == ACT_MESG_PROP - uiItemR(row, ptr, "body_property", 0, NULL, 0); + uiItemPointerR(row, ptr, "body_property", &settings_ptr, "properties", "", 0); } static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) { - uiLayout *split, *row, *col, *subcol; - Object *ob = (Object *)ptr->id.data; + Object *ob; PointerRNA settings_ptr; - + uiLayout *split, *row, *col, *subcol; + + ob = (Object *)ptr->id.data; RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); uiItemR(layout, ptr, "mode", 0, NULL, 0); @@ -3957,10 +3991,14 @@ static void draw_actuator_parent(uiLayout *layout, PointerRNA *ptr) static void draw_actuator_property(uiLayout *layout, PointerRNA *ptr) { + Object *ob = (Object *)ptr->id.data; + PointerRNA settings_ptr; uiLayout *row; uiItemR(layout, ptr, "mode", 0, NULL, 0); - uiItemR(layout, ptr, "prop_name", 0, NULL, 0); + + RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); + uiItemPointerR(layout, ptr, "property", &settings_ptr, "properties", NULL, 0); switch(RNA_enum_get(ptr, "mode")) { @@ -3975,26 +4013,32 @@ static void draw_actuator_property(uiLayout *layout, PointerRNA *ptr) case ACT_PROP_COPY: row = uiLayoutRow(layout, 0); uiItemR(row, ptr, "object", 0, NULL, 0); - uiItemR(row, ptr, "object_prop_name", 0, NULL, 0); + uiItemR(row, ptr, "object_property", 0, NULL, 0); } } static void draw_actuator_random(uiLayout *layout, PointerRNA *ptr) { + Object *ob; + PointerRNA settings_ptr; uiLayout *row; + + ob = (Object *)ptr->id.data; + RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); + row = uiLayoutRow(layout, 0); uiItemR(row, ptr, "seed", 0, NULL, 0); uiItemR(row, ptr, "distribution", 0, NULL, 0); row = uiLayoutRow(layout, 0); - uiItemR(row, ptr, "property", 0, NULL, 0); + uiItemPointerR(row, ptr, "property", &settings_ptr, "properties", NULL, 0); row = uiLayoutRow(layout, 0); switch (RNA_enum_get(ptr, "distribution")){ case ACT_RANDOM_BOOL_CONST: - uiItemR(row, ptr, "always_true", 0, NULL, 0); + uiItemR(row, ptr, "always_true", UI_ITEM_R_TOGGLE, NULL, 0); break; case ACT_RANDOM_BOOL_UNIFORM: @@ -4056,8 +4100,12 @@ static void draw_actuator_scene(uiLayout *layout, PointerRNA *ptr) static void draw_actuator_shape_action(uiLayout *layout, PointerRNA *ptr) { + Object *ob = (Object *)ptr->id.data; + PointerRNA settings_ptr; uiLayout *row; + RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); + row= uiLayoutRow(layout, 0); uiItemR(row, ptr, "mode", 0, "", 0); uiItemR(row, ptr, "action", 0, NULL, 0); @@ -4065,7 +4113,7 @@ static void draw_actuator_shape_action(uiLayout *layout, PointerRNA *ptr) row= uiLayoutRow(layout, 0); if((RNA_enum_get(ptr, "mode") == ACT_ACTION_FROM_PROP)) - uiItemR(row, ptr, "property", 0, NULL, 0); + uiItemPointerR(row, ptr, "property", &settings_ptr, "properties", NULL, 0); else { uiItemR(row, ptr, "frame_start", 0, NULL, 0); @@ -4077,7 +4125,7 @@ static void draw_actuator_shape_action(uiLayout *layout, PointerRNA *ptr) uiItemR(row, ptr, "priority", 0, NULL, 0); row= uiLayoutRow(layout, 0); - uiItemR(row, ptr, "frame_property", 0, NULL, 0); + uiItemPointerR(row, ptr, "frame_property", &settings_ptr, "properties", NULL, 0); #ifdef __NLA_ACTION_BY_MOTION_ACTUATOR uiItemR(row, "stride_length", 0, NULL, 0); diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index cc1cd9b1e1d..43b09c84a12 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -383,8 +383,6 @@ EnumPropertyItem *rna_Actuator_type_itemf(bContext *C, PointerRNA *ptr, int *fre if (ob->type==OB_ARMATURE) { RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_ACTION); RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_ARMATURE); - } else { - RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_SHAPEACTION); } } @@ -400,6 +398,13 @@ EnumPropertyItem *rna_Actuator_type_itemf(bContext *C, PointerRNA *ptr, int *fre RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_PROPERTY); RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_RANDOM); RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_SCENE); + + if (ob != NULL) { + if (ob->type==OB_MESH){ + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_SHAPEACTION); + } + } + RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_SOUND); RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_STATE); RNA_enum_items_add_value(&item, &totitem, actuator_type_items, ACT_VISIBILITY); @@ -936,8 +941,7 @@ static void rna_def_property_actuator(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Mode", ""); RNA_def_property_update(prop, NC_LOGIC, NULL); - //XXX add magic property lookup - prop= RNA_def_property(srna, "prop_name", PROP_STRING, PROP_NONE); + prop= RNA_def_property(srna, "property", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "name"); RNA_def_property_ui_text(prop, "Property", "The name of the property"); RNA_def_property_update(prop, NC_LOGIC, NULL); @@ -955,7 +959,7 @@ static void rna_def_property_actuator(BlenderRNA *brna) RNA_def_property_update(prop, NC_LOGIC, NULL); //XXX add even magic'er property lookup (need to look for the property list of the target object) - prop= RNA_def_property(srna, "object_prop_name", PROP_STRING, PROP_NONE); + prop= RNA_def_property(srna, "object_property", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "value"); RNA_def_property_ui_text(prop, "Property Name", "Copy this property"); RNA_def_property_update(prop, NC_LOGIC, NULL); @@ -1340,7 +1344,6 @@ static void rna_def_random_actuator(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Seed", "Initial seed of the random generator. Use Python for more freedom (choose 0 for not random)"); RNA_def_property_update(prop, NC_LOGIC, NULL); - //XXX add magic property lookup prop= RNA_def_property(srna, "property", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "propname"); RNA_def_property_ui_text(prop, "Property", "Assign the random value to this property"); @@ -1464,7 +1467,7 @@ static void rna_def_message_actuator(BlenderRNA *brna) prop= RNA_def_property(srna, "body_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "bodyType"); RNA_def_property_enum_items(prop, prop_body_type_items); - RNA_def_property_ui_text(prop, "Body Type", "Toggle message type: either Text or a PropertyName"); + RNA_def_property_ui_text(prop, "Body", "Toggle message type: either Text or a PropertyName"); /* ACT_MESG_MESG */ prop= RNA_def_property(srna, "body_message", PROP_STRING, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_property.c b/source/blender/makesrna/intern/rna_property.c index c65aa4ac725..7bcb58ea28d 100644 --- a/source/blender/makesrna/intern/rna_property.c +++ b/source/blender/makesrna/intern/rna_property.c @@ -30,6 +30,8 @@ #include "DNA_property_types.h" +#include "WM_types.h" + #ifdef RNA_RUNTIME #include "BKE_property.h" @@ -111,24 +113,29 @@ void RNA_def_gameproperty(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Name", "Available as GameObject attributes in the game engine's python API"); RNA_def_struct_name_property(srna, prop); RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GameProperty_name_set"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, gameproperty_type_items); RNA_def_property_ui_text(prop, "Type", ""); RNA_def_property_enum_funcs(prop, NULL, "rna_GameProperty_type_set", NULL); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "debug", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PROP_DEBUG); RNA_def_property_ui_text(prop, "Debug", "Print debug information for this property"); + RNA_def_property_update(prop, NC_LOGIC, NULL); /* GameBooleanProperty */ srna= RNA_def_struct(brna, "GameBooleanProperty", "GameProperty"); RNA_def_struct_ui_text(srna , "Game Boolean Property", "Game engine user defined Boolean property"); RNA_def_struct_sdna(srna, "bProperty"); + RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "value", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "data", 1); RNA_def_property_ui_text(prop, "Value", "Property value"); + RNA_def_property_update(prop, NC_LOGIC, NULL); /* GameIntProperty */ srna= RNA_def_struct(brna, "GameIntProperty", "GameProperty"); @@ -139,6 +146,7 @@ void RNA_def_gameproperty(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "data"); RNA_def_property_ui_text(prop, "Value", "Property value"); RNA_def_property_range(prop, -10000, 10000); + RNA_def_property_update(prop, NC_LOGIC, NULL); /* GameFloatProperty */ srna= RNA_def_struct(brna, "GameFloatProperty", "GameProperty"); @@ -150,6 +158,7 @@ void RNA_def_gameproperty(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Value", "Property value"); RNA_def_property_range(prop, -10000, 10000); RNA_def_property_float_funcs(prop, "rna_GameFloatProperty_value_get", "rna_GameFloatProperty_value_set", NULL); + RNA_def_property_update(prop, NC_LOGIC, NULL); /* GameTimerProperty */ srna= RNA_def_struct(brna, "GameTimerProperty", "GameProperty"); @@ -161,6 +170,7 @@ void RNA_def_gameproperty(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Value", "Property value"); RNA_def_property_range(prop, -10000, 10000); RNA_def_property_float_funcs(prop, "rna_GameFloatProperty_value_get", "rna_GameFloatProperty_value_set", NULL); + RNA_def_property_update(prop, NC_LOGIC, NULL); /* GameStringProperty */ srna= RNA_def_struct(brna, "GameStringProperty", "GameProperty"); @@ -171,6 +181,7 @@ void RNA_def_gameproperty(BlenderRNA *brna) RNA_def_property_string_sdna(prop, NULL, "poin"); RNA_def_property_string_maxlength(prop, MAX_PROPSTRING); RNA_def_property_ui_text(prop, "Value", "Property value"); + RNA_def_property_update(prop, NC_LOGIC, NULL); } #endif diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index 3621d6bb6d0..45a660a0895 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -314,7 +314,7 @@ static void rna_def_touch_sensor(BlenderRNA *brna) RNA_def_property_struct_type(prop, "Material"); RNA_def_property_pointer_sdna(prop, NULL, "ma"); RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Material", "Only look for floors with this material"); + RNA_def_property_ui_text(prop, "Material", "Only look for objects with this material"); RNA_def_property_update(prop, NC_LOGIC, NULL); } -- cgit v1.2.3 From 5548e86795bc1b7f97112c418e611023765c5af6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 8 May 2010 23:34:54 +0000 Subject: function to remove property eg: bpy.types.Scene.IntProperty(attr="myprop") # adds bpy.types.Scene.RemoveProperty(attr="myprop") # removes --- source/blender/makesrna/RNA_define.h | 1 + source/blender/makesrna/intern/rna_define.c | 34 +++++++++++++++++++++++++ source/blender/python/intern/bpy_props.c | 39 +++++++++++++++++++++++++++++ source/blender/python/intern/bpy_props.h | 2 ++ source/blender/python/intern/bpy_rna.c | 2 ++ 5 files changed, 78 insertions(+) diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h index 99bd79d5d90..88543e4add2 100644 --- a/source/blender/makesrna/RNA_define.h +++ b/source/blender/makesrna/RNA_define.h @@ -193,6 +193,7 @@ void RNA_def_func_duplicate_pointers(FunctionRNA *func); void RNA_def_func_free_pointers(FunctionRNA *func); void RNA_def_property_duplicate_pointers(PropertyRNA *prop); void RNA_def_property_free_pointers(PropertyRNA *prop); +int RNA_def_property_free_identifier(StructOrFunctionRNA *cont_, const char *identifier); #ifdef __cplusplus } diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index d0a8763baa7..01684482954 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -2722,5 +2722,39 @@ void RNA_def_property_free_pointers(PropertyRNA *prop) } } } + +void RNA_def_property_free(StructOrFunctionRNA *cont_, PropertyRNA *prop) +{ + ContainerRNA *cont= cont_; + + RNA_def_property_free_pointers(prop); + + if(prop->flag & PROP_RUNTIME) { + if(cont->prophash) + BLI_ghash_remove(cont->prophash, (void*)prop->identifier, NULL, NULL); + + rna_freelinkN(&cont->properties, prop); + } +} + +/* note: only intended for removing dynamic props */ +int RNA_def_property_free_identifier(StructOrFunctionRNA *cont_, const char *identifier) +{ + ContainerRNA *cont= cont_; + PropertyRNA *prop; + + for(prop= cont->properties.first; prop; prop= prop->next) { + if(strcmp(prop->identifier, identifier)==0) { + if(prop->flag & PROP_RUNTIME) { + RNA_def_property_free(cont_, prop); + return 1; + } + else { + return 0; + } + } + } + return 0; +} #endif diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index 85935c05cb1..37fd83e3b9b 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -860,6 +860,42 @@ PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw) return NULL; } +static char BPy_RemoveProperty_doc[] = +".. function:: RemoveProperty(attr)\n" +"\n" +" Removes a dynamically defined property.\n" +"\n" +" :arg attr: Property name.\n" +" :type attr: string"; +PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw) +{ + StructRNA *srna; + + srna= srna_from_self(self, "RemoveProperty(...):"); + if(srna==NULL && PyErr_Occurred()) { + return NULL; /* self's type was compatible but error getting the srna */ + } + else if(srna==NULL) { + PyErr_SetString(PyExc_TypeError, "RemoveProperty(): struct rna not available for this type."); + return NULL; + } + else { + static const char *kwlist[] = {"attr", NULL}; + + char *id=NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kw, "s:RemoveProperty", (char **)kwlist, &id)) + return NULL; + + if(RNA_def_property_free_identifier(srna, id) == 0) { + PyErr_Format(PyExc_TypeError, "RemoveProperty(): '%s' not a defined dynamic property.", id); + return NULL; + } + + Py_RETURN_NONE; + } +} + static struct PyMethodDef props_methods[] = { {"BoolProperty", (PyCFunction)BPy_BoolProperty, METH_VARARGS|METH_KEYWORDS, BPy_BoolProperty_doc}, {"BoolVectorProperty", (PyCFunction)BPy_BoolVectorProperty, METH_VARARGS|METH_KEYWORDS, BPy_BoolVectorProperty_doc}, @@ -871,6 +907,9 @@ static struct PyMethodDef props_methods[] = { {"EnumProperty", (PyCFunction)BPy_EnumProperty, METH_VARARGS|METH_KEYWORDS, BPy_EnumProperty_doc}, {"PointerProperty", (PyCFunction)BPy_PointerProperty, METH_VARARGS|METH_KEYWORDS, BPy_PointerProperty_doc}, {"CollectionProperty", (PyCFunction)BPy_CollectionProperty, METH_VARARGS|METH_KEYWORDS, BPy_CollectionProperty_doc}, + + /* only useful as a bpy_struct method */ + /* {"RemoveProperty", (PyCFunction)BPy_RemoveProperty, METH_VARARGS|METH_KEYWORDS, BPy_RemoveProperty_doc}, */ {NULL, NULL, 0, NULL} }; diff --git a/source/blender/python/intern/bpy_props.h b/source/blender/python/intern/bpy_props.h index 5fb62ac56d3..9382fc8115f 100644 --- a/source/blender/python/intern/bpy_props.h +++ b/source/blender/python/intern/bpy_props.h @@ -41,6 +41,8 @@ PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw); PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw); PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw); +PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw); + #define PYRNA_STACK_ARRAY 32 #endif diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 88f8990eae5..9063e5f9509 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -3794,6 +3794,8 @@ static struct PyMethodDef pyrna_struct_subtype_methods[] = { {"EnumProperty", (PyCFunction)BPy_EnumProperty, METH_VARARGS|METH_KEYWORDS, ""}, {"PointerProperty", (PyCFunction)BPy_PointerProperty, METH_VARARGS|METH_KEYWORDS, ""}, {"CollectionProperty", (PyCFunction)BPy_CollectionProperty, METH_VARARGS|METH_KEYWORDS, ""}, + + {"RemoveProperty", (PyCFunction)BPy_RemoveProperty, METH_VARARGS|METH_KEYWORDS, ""}, // {"__get_rna", (PyCFunction)BPy_GetStructRNA, METH_NOARGS, ""}, {NULL, NULL, 0, NULL} -- cgit v1.2.3 From d73af20b7acd50d9aaddcbce180fda1fb80df483 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 9 May 2010 00:06:35 +0000 Subject: py/rna: defining new properties now replaces the old onces and raises an error if they collide with dynamic props. --- source/blender/makesrna/intern/rna_define.c | 2 +- source/blender/python/intern/bpy_props.c | 72 +++++++++++++---------------- 2 files changed, 32 insertions(+), 42 deletions(-) diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 01684482954..fbcc3109af4 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -2750,7 +2750,7 @@ int RNA_def_property_free_identifier(StructOrFunctionRNA *cont_, const char *ide return 1; } else { - return 0; + return -1; } } } diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index 37fd83e3b9b..223b23a3dbd 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -132,10 +132,9 @@ PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssiO!s:BoolProperty", (char **)kwlist, &id, &name, &description, &def, &PySet_Type, &pyopts, &pysubtype)) return NULL; - if(bpy_struct_id_used(srna, id)) { - // PyErr_Format(PyExc_TypeError, "BoolProperty(): '%s' already defined.", id); - // return NULL; - Py_RETURN_NONE; + if(RNA_def_property_free_identifier(srna, id) == -1) { + PyErr_Format(PyExc_TypeError, "BoolProperty(): '%s' is defined as a non-dynamic type.", id); + return NULL; } if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "BoolProperty(options={...}):")) @@ -200,10 +199,9 @@ PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject *kw) if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssOO!si:BoolVectorProperty", (char **)kwlist, &id, &name, &description, &pydef, &PySet_Type, &pyopts, &pysubtype, &size)) return NULL; - if(bpy_struct_id_used(srna, id)) { - // PyErr_Format(PyExc_TypeError, "BoolVectorProperty(): '%s' already defined.", id); - // return NULL; - Py_RETURN_NONE; + if(RNA_def_property_free_identifier(srna, id) == -1) { + PyErr_Format(PyExc_TypeError, "BoolVectorProperty(): '%s' is defined as a non-dynamic type.", id); + return NULL; } if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "BoolVectorProperty(options={...}):")) @@ -275,10 +273,9 @@ PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw) if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssiiiiiiO!s:IntProperty", (char **)kwlist, &id, &name, &description, &def, &min, &max, &soft_min, &soft_max, &step, &PySet_Type, &pyopts, &pysubtype)) return NULL; - if(bpy_struct_id_used(srna, id)) { - // PyErr_Format(PyExc_TypeError, "IntProperty(): '%s' already defined.", id); - // return NULL; - Py_RETURN_NONE; + if(RNA_def_property_free_identifier(srna, id) == -1) { + PyErr_Format(PyExc_TypeError, "IntProperty(): '%s' is defined as a non-dynamic type.", id); + return NULL; } if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "IntProperty(options={...}):")) @@ -344,10 +341,9 @@ PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject *kw) if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssOiiiiO!si:IntVectorProperty", (char **)kwlist, &id, &name, &description, &pydef, &min, &max, &soft_min, &soft_max, &PySet_Type, &pyopts, &pysubtype, &size)) return NULL; - if(bpy_struct_id_used(srna, id)) { - // PyErr_Format(PyExc_TypeError, "IntVectorProperty(): '%s' already defined.", id); - // return NULL; - Py_RETURN_NONE; + if(RNA_def_property_free_identifier(srna, id) == -1) { + PyErr_Format(PyExc_TypeError, "IntVectorProperty(): '%s' is defined as a non-dynamic type.", id); + return NULL; } if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "IntVectorProperty(options={...}):")) @@ -426,10 +422,9 @@ PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssffffffiO!ss:FloatProperty", (char **)kwlist, &id, &name, &description, &def, &min, &max, &soft_min, &soft_max, &step, &precision, &PySet_Type, &pyopts, &pysubtype, &pyunit)) return NULL; - if(bpy_struct_id_used(srna, id)) { - // PyErr_Format(PyExc_TypeError, "FloatProperty(): '%s' already defined.", id); - // return NULL; - Py_RETURN_NONE; + if(RNA_def_property_free_identifier(srna, id) == -1) { + PyErr_Format(PyExc_TypeError, "FloatProperty(): '%s' is defined as a non-dynamic type.", id); + return NULL; } if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "FloatProperty(options={...}):")) @@ -500,10 +495,9 @@ PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObject *kw) if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssOfffffiO!si:FloatVectorProperty", (char **)kwlist, &id, &name, &description, &pydef, &min, &max, &soft_min, &soft_max, &step, &precision, &PySet_Type, &pyopts, &pysubtype, &size)) return NULL; - if(bpy_struct_id_used(srna, id)) { - // PyErr_Format(PyExc_TypeError, "FloatVectorProperty(): '%s' already defined.", id); - // return NULL; - Py_RETURN_NONE; + if(RNA_def_property_free_identifier(srna, id) == -1) { + PyErr_Format(PyExc_TypeError, "FloatVectorProperty(): '%s' is defined as a non-dynamic type.", id); + return NULL; } if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "FloatVectorProperty(options={...}):")) @@ -576,10 +570,9 @@ PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw) if (!PyArg_ParseTupleAndKeywords(args, kw, "s|sssiO!s:StringProperty", (char **)kwlist, &id, &name, &description, &def, &maxlen, &PySet_Type, &pyopts, &pysubtype)) return NULL; - if(bpy_struct_id_used(srna, id)) { - // PyErr_Format(PyExc_TypeError, "StringProperty(): '%s' already defined.", id); - // return NULL; - Py_RETURN_NONE; + if(RNA_def_property_free_identifier(srna, id) == -1) { + PyErr_Format(PyExc_TypeError, "StringProperty(): '%s' is defined as a non-dynamic type.", id); + return NULL; } if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "StringProperty(options={...}):")) @@ -688,10 +681,9 @@ PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) if (!PyArg_ParseTupleAndKeywords(args, kw, "sO|sssO!:EnumProperty", (char **)kwlist, &id, &items, &name, &description, &def, &PySet_Type, &pyopts)) return NULL; - if(bpy_struct_id_used(srna, id)) { - // PyErr_Format(PyExc_TypeError, "EnumProperty(): '%s' already defined.", id); - // return NULL; - Py_RETURN_NONE; + if(RNA_def_property_free_identifier(srna, id) == -1) { + PyErr_Format(PyExc_TypeError, "EnumProperty(): '%s' is defined as a non-dynamic type.", id); + return NULL; } if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "EnumProperty(options={...}):")) @@ -772,10 +764,9 @@ PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw) if (!PyArg_ParseTupleAndKeywords(args, kw, "sO|ssO!:PointerProperty", (char **)kwlist, &id, &type, &name, &description, &PySet_Type, &pyopts)) return NULL; - if(bpy_struct_id_used(srna, id)) { - // PyErr_Format(PyExc_TypeError, "PointerProperty(): '%s' already defined.", id); - // return NULL; - Py_RETURN_NONE; + if(RNA_def_property_free_identifier(srna, id) == -1) { + PyErr_Format(PyExc_TypeError, "PointerProperty(): '%s' is defined as a non-dynamic type.", id); + return NULL; } if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "PointerProperty(options={...}):")) @@ -833,10 +824,9 @@ PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw) if (!PyArg_ParseTupleAndKeywords(args, kw, "sO|ssO!:CollectionProperty", (char **)kwlist, &id, &type, &name, &description, &PySet_Type, &pyopts)) return NULL; - if(bpy_struct_id_used(srna, id)) { - // PyErr_Format(PyExc_TypeError, "CollectionProperty(): '%s' already defined.", id); - // return NULL; - Py_RETURN_NONE; + if(RNA_def_property_free_identifier(srna, id) == -1) { + PyErr_Format(PyExc_TypeError, "CollectionProperty(): '%s' is defined as a non-dynamic type.", id); + return NULL; } if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "CollectionProperty(options={...}):")) @@ -887,7 +877,7 @@ PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw) if (!PyArg_ParseTupleAndKeywords(args, kw, "s:RemoveProperty", (char **)kwlist, &id)) return NULL; - if(RNA_def_property_free_identifier(srna, id) == 0) { + if(RNA_def_property_free_identifier(srna, id) != 1) { PyErr_Format(PyExc_TypeError, "RemoveProperty(): '%s' not a defined dynamic property.", id); return NULL; } -- cgit v1.2.3 From d92751fb3329c4a40e69846eb36a29a98de3dea0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 9 May 2010 00:37:12 +0000 Subject: missing arg from docstring --- source/blender/python/intern/bpy_rna.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 9063e5f9509..bf063ee8f7e 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -1864,7 +1864,7 @@ static int pyrna_struct_keyframe_parse(PointerRNA *ptr, PyObject *args, char *er } static char pyrna_struct_keyframe_insert_doc[] = -".. method:: keyframe_insert(path, index=-1, frame=bpy.context.scene.frame_current)\n" +".. method:: keyframe_insert(path, index=-1, frame=bpy.context.scene.frame_current, group=\"\")\n" "\n" " Insert a keyframe on the property given, adding fcurves and animation data when necessary.\n" "\n" @@ -1898,7 +1898,7 @@ static PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *arg } static char pyrna_struct_keyframe_delete_doc[] = -".. method:: keyframe_delete(path, index=-1, frame=bpy.context.scene.frame_current)\n" +".. method:: keyframe_delete(path, index=-1, frame=bpy.context.scene.frame_current, group=\"\")\n" "\n" " Remove a keyframe from this properties fcurve.\n" "\n" -- cgit v1.2.3 From c7a6bf6fc27de1bb5251e203233beb533ad3302b Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sun, 9 May 2010 08:33:18 +0000 Subject: 2.5 Constraint UI: * Slight alignment change in header, to match modifiers box a bit better. Basically the "name" filed expands with the size of the properties panel now, which looks better imho. * Code cleanup: Removed some old drawing functions, and the Python Constraint UI Code, which was not functional anyway. --- .../editors/interface/interface_templates.c | 176 +-------------------- source/blender/makesrna/intern/rna_constraint.c | 2 +- 2 files changed, 8 insertions(+), 170 deletions(-) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index a5eec8f3b7f..aef24acc7a7 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -940,77 +940,6 @@ static void constraint_active_func(bContext *C, void *ob_v, void *con_v) ED_object_constraint_set_active(ob_v, con_v); } - -/* some commonly used macros in the constraints drawing code */ -#define is_armature_target(target) (target && target->type==OB_ARMATURE) -#define is_armature_owner(ob) ((ob->type == OB_ARMATURE) && (ob->mode & OB_MODE_POSE)) -#define is_geom_target(target) (target && (ELEM(target->type, OB_MESH, OB_LATTICE)) ) - -/* Helper function for draw constraint - draws constraint space stuff - * This function should not be called if no menus are required - * owner/target: -1 = don't draw menu; 0= not posemode, 1 = posemode - */ -static void draw_constraint_spaceselect (uiBlock *block, bConstraint *con, short xco, short yco, short owner, short target) -{ - short tarx, ownx, iconx; - short bwidth; - short iconwidth = 20; - - /* calculate sizes and placement of menus */ - if (owner == -1) { - bwidth = 125; - tarx = 120; - ownx = 0; - } - else if (target == -1) { - bwidth = 125; - tarx = 0; - ownx = 120; - } - else { - bwidth = 100; - tarx = 85; - iconx = tarx + bwidth + 5; - ownx = tarx + bwidth + iconwidth + 10; - } - - - uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Convert:", xco, yco, 80,18, NULL, 0.0, 0.0, 0.0, 0.0, ""); - - /* Target-Space */ - if (target == 1) { - uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Target Space %t|World Space %x0|Pose Space %x2|Local with Parent %x3|Local Space %x1", - tarx, yco, bwidth, 18, &con->tarspace, 0, 0, 0, 0, "Choose space that target is evaluated in"); - } - else if (target == 0) { - uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Target Space %t|World Space %x0|Local (Without Parent) Space %x1", - tarx, yco, bwidth, 18, &con->tarspace, 0, 0, 0, 0, "Choose space that target is evaluated in"); - } - - if ((target != -1) && (owner != -1)) - uiDefIconBut(block, LABEL, 0, ICON_ARROW_LEFTRIGHT, - iconx, yco, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, ""); - - /* Owner-Space */ - if (owner == 1) { - uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Owner Space %t|World Space %x0|Pose Space %x2|Local with Parent %x3|Local Space %x1", - ownx, yco, bwidth, 18, &con->ownspace, 0, 0, 0, 0, "Choose space that owner is evaluated in"); - } - else if (owner == 0) { - uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Owner Space %t|World Space %x0|Local (Without Parent) Space %x1", - ownx, yco, bwidth, 18, &con->ownspace, 0, 0, 0, 0, "Choose space that owner is evaluated in"); - } -} - -static void test_obpoin_but(bContext *C, char *name, ID **idpp) -{ - ID *id= BLI_findstring(&CTX_data_main(C)->object, name, offsetof(ID, name) + 2); - *idpp= id; /* can be NULL */ - - if(id) - id_lib_extern(id); /* checks lib data, sets correct flag for saving then */ -} - /* draw panel showing settings for a constraint */ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) { @@ -1018,7 +947,6 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) bConstraintTypeInfo *cti; uiBlock *block; uiLayout *result= NULL, *col, *box, *row, *subrow; - uiBut *but; PointerRNA ptr; char typestr[32]; short width = 265; @@ -1059,7 +987,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) block= uiLayoutGetBlock(box); subrow= uiLayoutRow(row, 0); - uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_LEFT); + //uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_LEFT); /* Draw constraint header */ uiBlockSetEmboss(block, UI_EMBOSSN); @@ -1085,7 +1013,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) uiItemL(subrow, con->name, 0); subrow= uiLayoutRow(row, 0); - uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_RIGHT); + //uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_RIGHT); /* proxy-protected constraints cannot be edited, so hide up/down + close buttons */ if (proxy_protected) { @@ -1143,109 +1071,19 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) /* Set but-locks for protected settings (magic numbers are used here!) */ if (proxy_protected) uiBlockSetButLock(block, 1, "Cannot edit Proxy-Protected Constraint"); - + + /* Draw constraint data */ + if ((con->flag & CONSTRAINT_EXPAND) == 0) { (yco) -= 21; } else { box= uiLayoutBox(col); block= uiLayoutAbsoluteBlock(box); - - switch (con->type) { -#ifndef DISABLE_PYTHON - case CONSTRAINT_TYPE_PYTHON: - { - bPythonConstraint *data = con->data; - bConstraintTarget *ct; - // uiBut *but2; - int tarnum, theight; - // static int pyconindex=0; - // char *menustr; - - theight = (data->tarnum)? (data->tarnum * 38) : (38); - - uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Script:", xco+60, yco-24, 55, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); - - /* do the scripts menu */ - /* XXX menustr = buildmenu_pyconstraints(data->text, &pyconindex); - but2 = uiDefButI(block, MENU, B_CONSTRAINT_TEST, menustr, - xco+120, yco-24, 150, 20, &pyconindex, - 0, 0, 0, 0, "Set the Script Constraint to use"); - uiButSetFunc(but2, validate_pyconstraint_cb, data, &pyconindex); - MEM_freeN(menustr); */ - - /* draw target(s) */ - if (data->flag & PYCON_USETARGETS) { - /* Draw target parameters */ - for (ct=data->targets.first, tarnum=1; ct; ct=ct->next, tarnum++) { - char tarstr[32]; - short yoffset= ((tarnum-1) * 38); - - /* target label */ - sprintf(tarstr, "Target %d:", tarnum); - uiDefBut(block, LABEL, B_CONSTRAINT_TEST, tarstr, xco+45, yco-(48+yoffset), 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); - - /* target space-selector - per target */ - if (is_armature_target(ct->tar)) { - uiDefButS(block, MENU, B_CONSTRAINT_TEST, "Target Space %t|World Space %x0|Pose Space %x3|Local with Parent %x4|Local Space %x1", - xco+10, yco-(66+yoffset), 100, 18, &ct->space, 0, 0, 0, 0, "Choose space that target is evaluated in"); - } - else { - uiDefButS(block, MENU, B_CONSTRAINT_TEST, "Target Space %t|World Space %x0|Local (Without Parent) Space %x1", - xco+10, yco-(66+yoffset), 100, 18, &ct->space, 0, 0, 0, 0, "Choose space that target is evaluated in"); - } - - uiBlockBeginAlign(block); - /* target object */ - uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-(48+yoffset), 150, 18, &ct->tar, "Target Object"); - - /* subtarget */ - if (is_armature_target(ct->tar)) { - but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+120, yco-(66+yoffset),150,18, &ct->subtarget, 0, 24, 0, 0, "Subtarget Bone"); - //uiButSetCompleteFunc(but, autocomplete_bone, (void *)ct->tar); - } - else if (is_geom_target(ct->tar)) { - but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", xco+120, yco-(66+yoffset),150,18, &ct->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points"); - //uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)ct->tar); - } - else { - strcpy(ct->subtarget, ""); - } - uiBlockEndAlign(block); - } - } - else { - /* Draw indication that no target needed */ - uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+60, yco-48, 55, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); - uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Not Applicable", xco+120, yco-48, 150, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); - } - - /* settings */ - uiBlockBeginAlign(block); - but=uiDefBut(block, BUT, B_CONSTRAINT_TEST, "Options", xco, yco-(52+theight), (width/2),18, NULL, 0, 24, 0, 0, "Change some of the constraint's settings."); - // XXX uiButSetFunc(but, BPY_pyconstraint_settings, data, NULL); - - but=uiDefBut(block, BUT, B_CONSTRAINT_TEST, "Refresh", xco+((width/2)+10), yco-(52+theight), (width/2),18, NULL, 0, 24, 0, 0, "Force constraint to refresh it's settings"); - uiBlockEndAlign(block); - - /* constraint space settings */ - draw_constraint_spaceselect(block, con, xco, yco-(73+theight), is_armature_owner(ob), -1); - } - break; -#endif - - case CONSTRAINT_TYPE_NULL: - { - uiItemL(box, "", 0); - } - break; - default: - result= box; - break; + result= box; } - } - + /* clear any locks set up for proxies/lib-linking */ uiBlockClearButLock(block); diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index c61ebf5adfc..b4ae49ae2f4 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -1855,7 +1855,7 @@ void RNA_def_constraint(BlenderRNA *brna) /* strings */ prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Constraint_name_set"); - RNA_def_property_ui_text(prop, "Name", ""); + RNA_def_property_ui_text(prop, "Name", "Constraint name"); RNA_def_struct_name_property(srna, prop); /* enums */ -- cgit v1.2.3 From d4ce8a7717dd0bdd57d2325f89efff7d17f3a994 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sun, 9 May 2010 09:43:49 +0000 Subject: Renaming IPO > F-Curve in the Logic Editor (Layout Engine version) --- source/blender/makesrna/intern/rna_actuator.c | 32 +++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 43b09c84a12..cb99f4dbbe7 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -41,7 +41,7 @@ EnumPropertyItem actuator_type_items[] ={ {ACT_EDIT_OBJECT, "EDIT_OBJECT", 0, "Edit Object", ""}, {ACT_2DFILTER, "FILTER_2D", 0, "2D Filter", ""}, {ACT_GAME, "GAME", 0, "Game", ""}, - {ACT_IPO, "IPO", 0, "IPO", ""}, + {ACT_IPO, "F-Curve", 0, "F-Curve", ""}, {ACT_MESSAGE, "MESSAGE", 0, "Message", ""}, {ACT_OBJECT, "OBJECT", 0, "Motion", ""}, {ACT_PARENT, "PARENT", 0, "Parent", ""}, @@ -76,7 +76,7 @@ static StructRNA* rna_Actuator_refine(struct PointerRNA *ptr) case ACT_OBJECT: return &RNA_ObjectActuator; case ACT_IPO: - return &RNA_IpoActuator; + return &RNA_FcurveActuator; case ACT_CAMERA: return &RNA_CameraActuator; case ACT_SOUND: @@ -290,7 +290,7 @@ static void rna_ConstraintActuator_spring_set(struct PointerRNA *ptr, float valu *fp = value; } -static void rna_IpoActuator_add_set(struct PointerRNA *ptr, int value) +static void rna_FcurveActuator_add_set(struct PointerRNA *ptr, int value) { bActuator *act = (bActuator *)ptr->data; bIpoActuator *ia = act->data; @@ -302,7 +302,7 @@ static void rna_IpoActuator_add_set(struct PointerRNA *ptr, int value) ia->flag &= ~ACT_IPOADD; } -static void rna_IpoActuator_force_set(struct PointerRNA *ptr, int value) +static void rna_FcurveActuator_force_set(struct PointerRNA *ptr, int value) { bActuator *act = (bActuator *)ptr->data; bIpoActuator *ia = act->data; @@ -705,7 +705,7 @@ static void rna_def_object_actuator(BlenderRNA *brna) RNA_def_property_update(prop, NC_LOGIC, NULL); } -static void rna_def_ipo_actuator(BlenderRNA *brna) +static void rna_def_fcurve_actuator(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; @@ -720,14 +720,14 @@ static void rna_def_ipo_actuator(BlenderRNA *brna) {ACT_IPO_FROM_PROP, "PROP", 0, "Property", ""}, {0, NULL, 0, NULL, NULL}}; - srna= RNA_def_struct(brna, "IpoActuator", "Actuator"); - RNA_def_struct_ui_text(srna, "IPO Actuator", "Actuator to animate the object"); + srna= RNA_def_struct(brna, "FcurveActuator", "Actuator"); + RNA_def_struct_ui_text(srna, "F-Curve Actuator", "Actuator to animate the object"); RNA_def_struct_sdna_from(srna, "bIpoActuator", "data"); prop= RNA_def_property(srna, "play_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "type"); RNA_def_property_enum_items(prop, prop_type_items); - RNA_def_property_ui_text(prop, "IPO Type", "Specify the way you want to play the animation"); + RNA_def_property_ui_text(prop, "F-Curve Type", "Specify the way you want to play the animation"); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "frame_start", PROP_INT, PROP_NONE); @@ -744,7 +744,7 @@ static void rna_def_ipo_actuator(BlenderRNA *brna) prop= RNA_def_property(srna, "property", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "name"); - RNA_def_property_ui_text(prop, "Property", "Use this property to define the Ipo position"); + RNA_def_property_ui_text(prop, "Property", "Use this property to define the F-Curve position"); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "frame_property", PROP_STRING, PROP_NONE); @@ -754,24 +754,24 @@ static void rna_def_ipo_actuator(BlenderRNA *brna) /* booleans */ prop= RNA_def_property(srna, "add", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOADD); - RNA_def_property_boolean_funcs(prop, NULL, "rna_IpoActuator_add_set"); - RNA_def_property_ui_text(prop, "Add", "Ipo is added to the current loc/rot/scale in global or local coordinate according to Local flag"); + RNA_def_property_boolean_funcs(prop, NULL, "rna_FcurveActuator_add_set"); + RNA_def_property_ui_text(prop, "Add", "F-Curve is added to the current loc/rot/scale in global or local coordinate according to Local flag"); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "force", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOFORCE); - RNA_def_property_boolean_funcs(prop, NULL, "rna_IpoActuator_force_set"); - RNA_def_property_ui_text(prop, "Force", "Apply IPO as a global or local force depending on the local option (dynamic objects only)"); + RNA_def_property_boolean_funcs(prop, NULL, "rna_FcurveActuator_force_set"); + RNA_def_property_ui_text(prop, "Force", "Apply F-Curve as a global or local force depending on the local option (dynamic objects only)"); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "local", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOLOCAL); - RNA_def_property_ui_text(prop, "L", "Let the IPO act in local coordinates, used in Force and Add mode"); + RNA_def_property_ui_text(prop, "L", "Let the F-Curve act in local coordinates, used in Force and Add mode"); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "child", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOCHILD); - RNA_def_property_ui_text(prop, "Child", "Update IPO on all children Objects as well"); + RNA_def_property_ui_text(prop, "Child", "Update F-Curve on all children Objects as well"); RNA_def_property_update(prop, NC_LOGIC, NULL); } @@ -1814,7 +1814,7 @@ void RNA_def_actuator(BlenderRNA *brna) rna_def_action_actuator(brna); rna_def_object_actuator(brna); - rna_def_ipo_actuator(brna); + rna_def_fcurve_actuator(brna); rna_def_camera_actuator(brna); rna_def_sound_actuator(brna); rna_def_property_actuator(brna); -- cgit v1.2.3 From 80f6671dfe64ece1e692c8032e1d1169621bceff Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sun, 9 May 2010 09:49:55 +0000 Subject: Some more IPO > F-Curve renaming in RNA. --- source/blender/makesrna/intern/rna_object.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 9972fa01a34..c34769dbeec 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1885,12 +1885,12 @@ static void rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "time_offset", PROP_FLOAT, PROP_NONE|PROP_UNIT_TIME); RNA_def_property_float_sdna(prop, NULL, "sf"); RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); - RNA_def_property_ui_text(prop, "Time Offset", "Animation offset in frames for IPO's and dupligroup instances"); + RNA_def_property_ui_text(prop, "Time Offset", "Animation offset in frames for F-Curve and dupligroup instances"); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update"); prop= RNA_def_property(srna, "time_offset_edit", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "ipoflag", OB_OFFS_OB); - RNA_def_property_ui_text(prop, "Time Offset Edit", "Use time offset when inserting keys and display time offset for IPO and action views"); + RNA_def_property_ui_text(prop, "Time Offset Edit", "Use time offset when inserting keys and display time offset for F-Curve and action views"); prop= RNA_def_property(srna, "time_offset_parent", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "ipoflag", OB_OFFS_PARENT); -- cgit v1.2.3