Changeset View
Standalone View
source/blender/editors/space_view3d/view3d_edit.c
| Show All 28 Lines | |||||
| #include <string.h> | #include <string.h> | ||||
| #include "DNA_armature_types.h" | #include "DNA_armature_types.h" | ||||
| #include "DNA_camera_types.h" | #include "DNA_camera_types.h" | ||||
| #include "DNA_curve_types.h" | #include "DNA_curve_types.h" | ||||
| #include "DNA_gpencil_types.h" | #include "DNA_gpencil_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_world_types.h" | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_dial_2d.h" | #include "BLI_dial_2d.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| ▲ Show 20 Lines • Show All 4,824 Lines • ▼ Show 20 Lines | void VIEW3D_OT_background_image_remove(wmOperatorType *ot) | ||||
| /* properties */ | /* properties */ | ||||
| RNA_def_int( | RNA_def_int( | ||||
| ot->srna, "index", 0, 0, INT_MAX, "Index", "Background image index to remove", 0, INT_MAX); | ot->srna, "index", 0, 0, INT_MAX, "Index", "Background image index to remove", 0, INT_MAX); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Drop World Operator | |||||
| * \{ */ | |||||
| static int drop_world_exec(bContext *C, wmOperator *op) | |||||
| { | |||||
| Main *bmain = CTX_data_main(C); | |||||
| Scene *scene = CTX_data_scene(C); | |||||
| char name[MAX_ID_NAME - 2]; | |||||
| RNA_string_get(op->ptr, "name", name); | |||||
| World *world = (World *)BKE_libblock_find_name(bmain, ID_WO, name); | |||||
| if (world == NULL) { | |||||
| return OPERATOR_CANCELLED; | |||||
| } | |||||
| id_us_plus(&world->id); | |||||
| scene->world = world; | |||||
deadpin: I'm unsure if this naked assignment is correct. | |||||
Done Inline ActionsSeems ok, RNA doesn't have additional logic for world. jbakker: Seems ok, RNA doesn't have additional logic for world. | |||||
| DEG_id_tag_update(&scene->id, 0); | |||||
| DEG_relations_tag_update(bmain); | |||||
| WM_event_add_notifier(C, NC_SCENE | ND_WORLD, scene); | |||||
Not Done Inline ActionsThink this is the only notifier that's needed, I wouldn't send the other ones. But make this take the scene, not the world. Severin: Think this is the only notifier that's needed, I wouldn't send the other ones. But make this… | |||||
Not Done Inline ActionsThe NC_SPACE | ND_SPACE_VIEW3D notification is still needed if you drop a World while in Eevee rendered or material preview mode. Without it you have to move the viewport in order to see the change. deadpin: The `NC_SPACE | ND_SPACE_VIEW3D` notification is still needed if you drop a World while in… | |||||
Not Done Inline ActionsIn that case it's better to make sure the 3D View updates correctly for NC_SCENE | ND_WORLD. This if block probably needs correction: https://developer.blender.org/diffusion/B/browse/master/source/blender/editors/space_view3d/space_view3d.c$1559-1561 The design idea behind notifiers is that a notifier is sent indicating what changed, and editors can respond with a redraw if they care about this change. By sending a specific space notifier it's basically the wrong way around: the data change explicitly says which editor should redraw. So space notifiers should only be sent if the actual space data changed. Severin: In that case it's better to make sure the 3D View updates correctly for `NC_SCENE | ND_WORLD`. | |||||
| return OPERATOR_FINISHED; | |||||
| } | |||||
| static bool drop_world_poll(bContext *C) | |||||
| { | |||||
| return ED_operator_scene_editable(C); | |||||
| } | |||||
| void VIEW3D_OT_drop_world(wmOperatorType *ot) | |||||
| { | |||||
| /* identifiers */ | |||||
Done Inline ActionsWould be more specific on the name and consistent with the other drop operations. Same for name + description. Note that you're not changing the world of the 3d view, but of the scene. jbakker: Would be more specific on the name and consistent with the other drop operations. | |||||
| ot->name = "Drop World"; | |||||
| ot->description = "Drop a world into the scene"; | |||||
| ot->idname = "VIEW3D_OT_drop_world"; | |||||
| /* api callbacks */ | |||||
| ot->exec = drop_world_exec; | |||||
| ot->poll = drop_world_poll; | |||||
| /* flags */ | |||||
| ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL; | |||||
| /* properties */ | |||||
Not Done Inline ActionsUse OPTYPE_UNDO | OPTYPE_INTERNAL here. Severin: Use `OPTYPE_UNDO | OPTYPE_INTERNAL` here. | |||||
| RNA_def_string(ot->srna, "name", "World", MAX_ID_NAME - 2, "Name", "World to assign"); | |||||
| } | |||||
| /** \} */ | |||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name View Clipping Planes Operator | /** \name View Clipping Planes Operator | ||||
| * | * | ||||
| * Draw border or toggle off. | * Draw border or toggle off. | ||||
| * \{ */ | * \{ */ | ||||
| static void calc_local_clipping(float clip_local[6][4], | static void calc_local_clipping(float clip_local[6][4], | ||||
| const BoundBox *clipbb, | const BoundBox *clipbb, | ||||
| const float mat[4][4]) | const float mat[4][4]) | ||||
| ▲ Show 20 Lines • Show All 493 Lines • Show Last 20 Lines | |||||
I'm unsure if this naked assignment is correct.