Files
test/source/blender/editors/object/object_intern.hh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

375 lines
14 KiB
C++
Raw Normal View History

/* SPDX-FileCopyrightText: 2008 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
2011-02-27 20:29:51 +00:00
/** \file
* \ingroup edobj
2011-02-27 20:29:51 +00:00
*/
#pragma once
#include "BLI_vector.hh"
#include "RNA_types.hh"
struct bContext;
struct ModifierData;
struct Object;
struct StructRNA;
struct wmOperator;
struct wmOperatorType;
namespace blender::ed::object {
/* add hook menu */
enum eObject_Hook_Add_Mode {
OBJECT_ADDHOOK_NEWOB = 1,
OBJECT_ADDHOOK_SELOB,
OBJECT_ADDHOOK_SELOB_BONE,
};
/* internal exports only */
/* object_transform.cc */
void OBJECT_OT_location_clear(wmOperatorType *ot);
void OBJECT_OT_rotation_clear(wmOperatorType *ot);
void OBJECT_OT_scale_clear(wmOperatorType *ot);
void OBJECT_OT_origin_clear(wmOperatorType *ot);
void OBJECT_OT_visual_transform_apply(wmOperatorType *ot);
void OBJECT_OT_transform_apply(wmOperatorType *ot);
void OBJECT_OT_parent_inverse_apply(wmOperatorType *ot);
void OBJECT_OT_transform_axis_target(wmOperatorType *ot);
void OBJECT_OT_origin_set(wmOperatorType *ot);
/* `object_relations.cc` */
void OBJECT_OT_parent_set(wmOperatorType *ot);
void OBJECT_OT_parent_no_inverse_set(wmOperatorType *ot);
void OBJECT_OT_parent_clear(wmOperatorType *ot);
void OBJECT_OT_vertex_parent_set(wmOperatorType *ot);
void OBJECT_OT_track_set(wmOperatorType *ot);
void OBJECT_OT_track_clear(wmOperatorType *ot);
void OBJECT_OT_make_local(wmOperatorType *ot);
void OBJECT_OT_make_single_user(wmOperatorType *ot);
void OBJECT_OT_make_links_scene(wmOperatorType *ot);
void OBJECT_OT_make_links_data(wmOperatorType *ot);
void OBJECT_OT_make_override_library(wmOperatorType *ot);
void OBJECT_OT_reset_override_library(wmOperatorType *ot);
void OBJECT_OT_clear_override_library(wmOperatorType *ot);
/**
* Used for drop-box.
* Assigns to object under cursor, only first material slot.
*/
void OBJECT_OT_drop_named_material(wmOperatorType *ot);
/**
* Used for drop-box.
* Assigns to object under cursor, creates a new geometry nodes modifier.
*/
void OBJECT_OT_drop_geometry_nodes(wmOperatorType *ot);
/**
* \note Only for empty-image objects, this operator is needed
*/
void OBJECT_OT_unlink_data(wmOperatorType *ot);
/* object_edit.cc */
void OBJECT_OT_hide_view_set(wmOperatorType *ot);
void OBJECT_OT_hide_view_clear(wmOperatorType *ot);
void OBJECT_OT_hide_collection(wmOperatorType *ot);
void OBJECT_OT_mode_set(wmOperatorType *ot);
void OBJECT_OT_mode_set_with_submode(wmOperatorType *ot);
void OBJECT_OT_editmode_toggle(wmOperatorType *ot);
void OBJECT_OT_posemode_toggle(wmOperatorType *ot);
void OBJECT_OT_shade_smooth(wmOperatorType *ot);
void OBJECT_OT_shade_smooth_by_angle(wmOperatorType *ot);
void OBJECT_OT_shade_auto_smooth(wmOperatorType *ot);
void OBJECT_OT_shade_flat(wmOperatorType *ot);
void OBJECT_OT_paths_calculate(wmOperatorType *ot);
void OBJECT_OT_paths_update(wmOperatorType *ot);
void OBJECT_OT_paths_clear(wmOperatorType *ot);
void OBJECT_OT_paths_update_visible(wmOperatorType *ot);
void OBJECT_OT_forcefield_toggle(wmOperatorType *ot);
void OBJECT_OT_move_to_collection(wmOperatorType *ot);
void OBJECT_OT_link_to_collection(wmOperatorType *ot);
void OBJECT_OT_transfer_mode(wmOperatorType *ot);
/* `object_select.cc` */
void OBJECT_OT_select_all(wmOperatorType *ot);
void OBJECT_OT_select_random(wmOperatorType *ot);
void OBJECT_OT_select_by_type(wmOperatorType *ot);
void OBJECT_OT_select_linked(wmOperatorType *ot);
void OBJECT_OT_select_grouped(wmOperatorType *ot);
void OBJECT_OT_select_mirror(wmOperatorType *ot);
void OBJECT_OT_select_more(wmOperatorType *ot);
void OBJECT_OT_select_less(wmOperatorType *ot);
void OBJECT_OT_select_same_collection(wmOperatorType *ot);
/* object_add.cc */
void OBJECT_OT_add(wmOperatorType *ot);
void OBJECT_OT_add_named(wmOperatorType *ot);
void OBJECT_OT_transform_to_mouse(wmOperatorType *ot);
void OBJECT_OT_metaball_add(wmOperatorType *ot);
void OBJECT_OT_text_add(wmOperatorType *ot);
void OBJECT_OT_armature_add(wmOperatorType *ot);
void OBJECT_OT_empty_add(wmOperatorType *ot);
void OBJECT_OT_lightprobe_add(wmOperatorType *ot);
void OBJECT_OT_empty_image_add(wmOperatorType *ot);
void OBJECT_OT_grease_pencil_add(wmOperatorType *ot);
void OBJECT_OT_light_add(wmOperatorType *ot);
void OBJECT_OT_effector_add(wmOperatorType *ot);
void OBJECT_OT_camera_add(wmOperatorType *ot);
void OBJECT_OT_speaker_add(wmOperatorType *ot);
void OBJECT_OT_curves_random_add(wmOperatorType *ot);
void OBJECT_OT_curves_empty_hair_add(wmOperatorType *ot);
void OBJECT_OT_pointcloud_add(wmOperatorType *ot);
/**
* Only used as menu.
*/
void OBJECT_OT_collection_instance_add(wmOperatorType *ot);
void OBJECT_OT_collection_external_asset_drop(wmOperatorType *ot);
void OBJECT_OT_data_instance_add(wmOperatorType *ot);
void OBJECT_OT_duplicates_make_real(wmOperatorType *ot);
void OBJECT_OT_duplicate(wmOperatorType *ot);
void OBJECT_OT_delete(wmOperatorType *ot);
void OBJECT_OT_join(wmOperatorType *ot);
void OBJECT_OT_join_shapes(wmOperatorType *ot);
void OBJECT_OT_convert(wmOperatorType *ot);
/* `object_volume.cc` */
void OBJECT_OT_volume_add(wmOperatorType *ot);
/**
* Called by other space types too.
*/
void OBJECT_OT_volume_import(wmOperatorType *ot);
/* `object_hook.cc` */
void OBJECT_OT_hook_add_selob(wmOperatorType *ot);
void OBJECT_OT_hook_add_newob(wmOperatorType *ot);
void OBJECT_OT_hook_remove(wmOperatorType *ot);
void OBJECT_OT_hook_select(wmOperatorType *ot);
void OBJECT_OT_hook_assign(wmOperatorType *ot);
void OBJECT_OT_hook_reset(wmOperatorType *ot);
void OBJECT_OT_hook_recenter(wmOperatorType *ot);
/* `object_collection.cc` */
void COLLECTION_OT_create(wmOperatorType *ot);
void COLLECTION_OT_objects_remove_all(wmOperatorType *ot);
void COLLECTION_OT_objects_remove(wmOperatorType *ot);
void COLLECTION_OT_objects_add_active(wmOperatorType *ot);
void COLLECTION_OT_objects_remove_active(wmOperatorType *ot);
/* object_light_linking_ops.cc */
void OBJECT_OT_light_linking_receiver_collection_new(wmOperatorType *ot);
void OBJECT_OT_light_linking_receivers_select(wmOperatorType *ot);
void OBJECT_OT_light_linking_receivers_link(wmOperatorType *ot);
void OBJECT_OT_light_linking_blocker_collection_new(wmOperatorType *ot);
void OBJECT_OT_light_linking_blockers_select(wmOperatorType *ot);
void OBJECT_OT_light_linking_blockers_link(wmOperatorType *ot);
void OBJECT_OT_light_linking_unlink_from_collection(wmOperatorType *ot);
/* `object_modifier.cc` */
bool edit_modifier_poll_generic(bContext *C,
StructRNA *rna_type,
int obtype_flag,
bool is_editmode_allowed,
bool is_liboverride_allowed);
void edit_modifier_properties(wmOperatorType *ot);
bool edit_modifier_invoke_properties(bContext *C, wmOperator *op);
ModifierData *edit_modifier_property_get(wmOperator *op, Object *ob, int type);
void OBJECT_OT_modifier_add(wmOperatorType *ot);
void OBJECT_OT_modifier_remove(wmOperatorType *ot);
void OBJECT_OT_modifiers_clear(wmOperatorType *ot);
void OBJECT_OT_modifier_move_up(wmOperatorType *ot);
void OBJECT_OT_modifier_move_down(wmOperatorType *ot);
void OBJECT_OT_modifier_move_to_index(wmOperatorType *ot);
void OBJECT_OT_modifier_apply(wmOperatorType *ot);
void OBJECT_OT_modifier_apply_as_shapekey(wmOperatorType *ot);
void OBJECT_OT_modifier_convert(wmOperatorType *ot);
void OBJECT_OT_modifier_copy(wmOperatorType *ot);
void OBJECT_OT_modifier_copy_to_selected(wmOperatorType *ot);
void OBJECT_OT_modifiers_copy_to_selected(wmOperatorType *ot);
void OBJECT_OT_modifier_set_active(wmOperatorType *ot);
void OBJECT_OT_multires_subdivide(wmOperatorType *ot);
void OBJECT_OT_multires_reshape(wmOperatorType *ot);
void OBJECT_OT_multires_higher_levels_delete(wmOperatorType *ot);
void OBJECT_OT_multires_base_apply(wmOperatorType *ot);
void OBJECT_OT_multires_unsubdivide(wmOperatorType *ot);
void OBJECT_OT_multires_rebuild_subdiv(wmOperatorType *ot);
void OBJECT_OT_multires_external_save(wmOperatorType *ot);
void OBJECT_OT_multires_external_pack(wmOperatorType *ot);
void OBJECT_OT_correctivesmooth_bind(wmOperatorType *ot);
void OBJECT_OT_meshdeform_bind(wmOperatorType *ot);
void OBJECT_OT_explode_refresh(wmOperatorType *ot);
void OBJECT_OT_ocean_bake(wmOperatorType *ot);
void OBJECT_OT_skin_root_mark(wmOperatorType *ot);
void OBJECT_OT_skin_loose_mark_clear(wmOperatorType *ot);
void OBJECT_OT_skin_radii_equalize(wmOperatorType *ot);
void OBJECT_OT_skin_armature_create(wmOperatorType *ot);
void OBJECT_OT_laplaciandeform_bind(wmOperatorType *ot);
void OBJECT_OT_surfacedeform_bind(wmOperatorType *ot);
void OBJECT_OT_geometry_nodes_input_attribute_toggle(wmOperatorType *ot);
void OBJECT_OT_geometry_node_tree_copy_assign(wmOperatorType *ot);
void OBJECT_OT_grease_pencil_dash_modifier_segment_add(wmOperatorType *ot);
void OBJECT_OT_grease_pencil_dash_modifier_segment_remove(wmOperatorType *ot);
void OBJECT_OT_grease_pencil_dash_modifier_segment_move(wmOperatorType *ot);
void OBJECT_OT_grease_pencil_time_modifier_segment_add(wmOperatorType *ot);
void OBJECT_OT_grease_pencil_time_modifier_segment_remove(wmOperatorType *ot);
void OBJECT_OT_grease_pencil_time_modifier_segment_move(wmOperatorType *ot);
/* `object_shader_fx.cc` */
void OBJECT_OT_shaderfx_add(wmOperatorType *ot);
void OBJECT_OT_shaderfx_copy(wmOperatorType *ot);
void OBJECT_OT_shaderfx_remove(wmOperatorType *ot);
void OBJECT_OT_shaderfx_move_up(wmOperatorType *ot);
void OBJECT_OT_shaderfx_move_down(wmOperatorType *ot);
void OBJECT_OT_shaderfx_move_to_index(wmOperatorType *ot);
/* `object_constraint.cc` */
void OBJECT_OT_constraint_add(wmOperatorType *ot);
void OBJECT_OT_constraint_add_with_targets(wmOperatorType *ot);
void POSE_OT_constraint_add(wmOperatorType *ot);
void POSE_OT_constraint_add_with_targets(wmOperatorType *ot);
void OBJECT_OT_constraints_copy(wmOperatorType *ot);
void POSE_OT_constraints_copy(wmOperatorType *ot);
void OBJECT_OT_constraints_clear(wmOperatorType *ot);
void POSE_OT_constraints_clear(wmOperatorType *ot);
void POSE_OT_ik_add(wmOperatorType *ot);
void POSE_OT_ik_clear(wmOperatorType *ot);
void CONSTRAINT_OT_delete(wmOperatorType *ot);
void CONSTRAINT_OT_apply(wmOperatorType *ot);
void CONSTRAINT_OT_copy(wmOperatorType *ot);
void CONSTRAINT_OT_copy_to_selected(wmOperatorType *ot);
void CONSTRAINT_OT_move_up(wmOperatorType *ot);
void CONSTRAINT_OT_move_to_index(wmOperatorType *ot);
void CONSTRAINT_OT_move_down(wmOperatorType *ot);
void CONSTRAINT_OT_stretchto_reset(wmOperatorType *ot);
void CONSTRAINT_OT_limitdistance_reset(wmOperatorType *ot);
void CONSTRAINT_OT_childof_set_inverse(wmOperatorType *ot);
void CONSTRAINT_OT_childof_clear_inverse(wmOperatorType *ot);
void CONSTRAINT_OT_objectsolver_set_inverse(wmOperatorType *ot);
void CONSTRAINT_OT_objectsolver_clear_inverse(wmOperatorType *ot);
void CONSTRAINT_OT_followpath_path_animate(wmOperatorType *ot);
2022-08-14 14:32:54 -04:00
/* object_vgroup.cc */
void OBJECT_OT_vertex_group_add(wmOperatorType *ot);
void OBJECT_OT_vertex_group_remove(wmOperatorType *ot);
void OBJECT_OT_vertex_group_assign(wmOperatorType *ot);
void OBJECT_OT_vertex_group_assign_new(wmOperatorType *ot);
void OBJECT_OT_vertex_group_remove_from(wmOperatorType *ot);
void OBJECT_OT_vertex_group_select(wmOperatorType *ot);
void OBJECT_OT_vertex_group_deselect(wmOperatorType *ot);
void OBJECT_OT_vertex_group_copy_to_selected(wmOperatorType *ot);
void OBJECT_OT_vertex_group_copy(wmOperatorType *ot);
void OBJECT_OT_vertex_group_normalize(wmOperatorType *ot);
void OBJECT_OT_vertex_group_normalize_all(wmOperatorType *ot);
void OBJECT_OT_vertex_group_levels(wmOperatorType *ot);
void OBJECT_OT_vertex_group_lock(wmOperatorType *ot);
void OBJECT_OT_vertex_group_invert(wmOperatorType *ot);
void OBJECT_OT_vertex_group_smooth(wmOperatorType *ot);
void OBJECT_OT_vertex_group_clean(wmOperatorType *ot);
void OBJECT_OT_vertex_group_quantize(wmOperatorType *ot);
void OBJECT_OT_vertex_group_limit_total(wmOperatorType *ot);
void OBJECT_OT_vertex_group_mirror(wmOperatorType *ot);
void OBJECT_OT_vertex_group_set_active(wmOperatorType *ot);
void OBJECT_OT_vertex_group_sort(wmOperatorType *ot);
void OBJECT_OT_vertex_group_move(wmOperatorType *ot);
void OBJECT_OT_vertex_weight_paste(wmOperatorType *ot);
void OBJECT_OT_vertex_weight_delete(wmOperatorType *ot);
void OBJECT_OT_vertex_weight_set_active(wmOperatorType *ot);
void OBJECT_OT_vertex_weight_normalize_active_vertex(wmOperatorType *ot);
void OBJECT_OT_vertex_weight_copy(wmOperatorType *ot);
/* `object_warp.cc` */
void TRANSFORM_OT_vertex_warp(wmOperatorType *ot);
/* `object_shapekey.cc` */
void OBJECT_OT_shape_key_add(wmOperatorType *ot);
void OBJECT_OT_shape_key_remove(wmOperatorType *ot);
void OBJECT_OT_shape_key_clear(wmOperatorType *ot);
void OBJECT_OT_shape_key_retime(wmOperatorType *ot);
void OBJECT_OT_shape_key_mirror(wmOperatorType *ot);
void OBJECT_OT_shape_key_move(wmOperatorType *ot);
void OBJECT_OT_shape_key_lock(wmOperatorType *ot);
/* `object_collection.cc` */
void OBJECT_OT_collection_add(wmOperatorType *ot);
void OBJECT_OT_collection_link(wmOperatorType *ot);
void OBJECT_OT_collection_remove(wmOperatorType *ot);
void OBJECT_OT_collection_unlink(wmOperatorType *ot);
void OBJECT_OT_collection_objects_select(wmOperatorType *ot);
Sorry, three commits in one, became difficult to untangle.. Editors Modules * render/ module added in editors, moved the preview render code there and also shading related operators. * physics/ module made more consistent with other modules. renaming files, making a single physics_ops.c for operators and keymaps. Also move all particle related operators here now. * space_buttons/ now should have only operators relevant to the buttons specificially. Updates & Notifiers * Material/Texture/World/Lamp can now be passed to DAG_id_flush_update, which will go back to a callback in editors. Eventually these should be in the depsgraph itself, but for now this gives a unified call for doing updates. * GLSL materials are now refreshed on changes. There's still various cases missing, * Preview icons now hook into this system, solving various update cases that were missed before. * Also fixes issue in my last commit, where some preview would not render, problem is avoided in the new system. Icon Rendering * On systems with support for non-power of two textures, an OpenGL texture is now used instead of glDrawPixels. This avoids problems with icons get clipped on region borders. On my Linux desktop, this gives an 1.1x speedup, and on my Mac laptop a 2.3x speedup overall in redrawing the full window, with the default setup. The glDrawPixels implementation on Mac seems to have a lot of overhread. * Preview icons are now drawn using proper premul alpha, and never faded so you can see them clearly. * Also tried to fix issue with texture node preview rendering, globals can't be used with threads reliably.
2009-09-29 19:12:12 +00:00
/* `object_bake.cc` */
void OBJECT_OT_bake_image(wmOperatorType *ot);
Bake API - bpy.ops.object.bake() New operator that can calls a bake function to the current render engine when available. This commit provides no feature for the users, but allows external engines to be accessed by the operator and be integrated with the baking api. The API itself is simple. Blender sends a populated array of BakePixels to the renderer, and gets back an array of floats with the result. The Blender Internal (and multires) system is still running independent, but we eventually will pipe it through the API as well. Cycles baking will come next as a separated commit Python Operator: ---------------- The operator can be called with some arguments, or a user interface can be created for it. In that case the arguments can be ommited and the interface can expose the settings from bpy.context.scene.render.bake bpy.ops.object.bake(type='COMBINED', filepath="", width=512, height=512, margin=16, use_selected_to_active=False, cage_extrusion=0, cage="", normal_space='TANGENT', normal_r='POS_X', normal_g='POS_Y', normal_b='POS_Z', save_mode='INTERNAL', use_clear=False, use_split_materials=False, use_automatic_name=False) Note: external save mode is currently disabled. Supported Features: ------------------ * Margin - Baked result is extended this many pixels beyond the border of each UV "island," to soften seams in the texture. * Selected to Active - bake shading on the surface of selected object to the active object. The rays are cast from the lowpoly object inwards towards the highpoly object. If the highpoly object is not entirely involved by the lowpoly object, you can tweak the rays start point with Cage Extrusion. For even more control of the cage you can use a Cage object. * Cage Extrusion - distance to use for the inward ray cast when using selected to active * Custom Cage - object to use as cage (instead of the lowpoly object). * Normal swizzle - change the axis that gets mapped to RGB * Normal space - save as tangent or object normal spaces Supported Passes: ----------------- Any pass that is supported by Blender renderlayer system. Though it's up to the external engine to provide a valid enum with its supported passes. Normal passes get a special treatment since we post-process them to converted and "swizzled" Development Notes for External Engines: --------------------------------------- (read them in bake_api.c) * For a complete implementation example look at the Cycles Bake commit (next). Review: D421 Reviewed by: Campbell Barton, Brecht van Lommel, Sergey Sharybin, Thomas Dinge Normal map pipeline "consulting" by Andy Davies (metalliandy) Original design by Brecht van Lommel. The entire commit history can be found on the branch: bake-cycles
2014-01-02 19:05:07 -02:00
void OBJECT_OT_bake(wmOperatorType *ot);
Geometry Nodes: add simulation support This adds support for building simulations with geometry nodes. A new `Simulation Input` and `Simulation Output` node allow maintaining a simulation state across multiple frames. Together these two nodes form a `simulation zone` which contains all the nodes that update the simulation state from one frame to the next. A new simulation zone can be added via the menu (`Simulation > Simulation Zone`) or with the node add search. The simulation state contains a geometry by default. However, it is possible to add multiple geometry sockets as well as other socket types. Currently, field inputs are evaluated and stored for the preceding geometry socket in the order that the sockets are shown. Simulation state items can be added by linking one of the empty sockets to something else. In the sidebar, there is a new panel that allows adding, removing and reordering these sockets. The simulation nodes behave as follows: * On the first frame, the inputs of the `Simulation Input` node are evaluated to initialize the simulation state. In later frames these sockets are not evaluated anymore. The `Delta Time` at the first frame is zero, but the simulation zone is still evaluated. * On every next frame, the `Simulation Input` node outputs the simulation state of the previous frame. Nodes in the simulation zone can edit that data in arbitrary ways, also taking into account the `Delta Time`. The new simulation state has to be passed to the `Simulation Output` node where it is cached and forwarded. * On a frame that is already cached or baked, the nodes in the simulation zone are not evaluated, because the `Simulation Output` node can return the previously cached data directly. It is not allowed to connect sockets from inside the simulation zone to the outside without going through the `Simulation Output` node. This is a necessary restriction to make caching and sub-frame interpolation work. Links can go into the simulation zone without problems though. Anonymous attributes are not propagated by the simulation nodes unless they are explicitly stored in the simulation state. This is unfortunate, but currently there is no practical and reliable alternative. The core problem is detecting which anonymous attributes will be required for the simulation and afterwards. While we can detect this for the current evaluation, we can't look into the future in time to see what data will be necessary. We intend to make it easier to explicitly pass data through a simulation in the future, even if the simulation is in a nested node group. There is a new `Simulation Nodes` panel in the physics tab in the properties editor. It allows baking all simulation zones on the selected objects. The baking options are intentially kept at a minimum for this MVP. More features for simulation baking as well as baking in general can be expected to be added separately. All baked data is stored on disk in a folder next to the .blend file. #106937 describes how baking is implemented in more detail. Volumes can not be baked yet and materials are lost during baking for now. Packing the baked data into the .blend file is not yet supported. The timeline indicates which frames are currently cached, baked or cached but invalidated by user-changes. Simulation input and output nodes are internally linked together by their `bNode.identifier` which stays the same even if the node name changes. They are generally added and removed together. However, there are still cases where "dangling" simulation nodes can be created currently. Those generally don't cause harm, but would be nice to avoid this in more cases in the future. Co-authored-by: Hans Goudey <h.goudey@me.com> Co-authored-by: Lukas Tönne <lukas@blender.org> Pull Request: https://projects.blender.org/blender/blender/pulls/104924
2023-05-03 13:18:51 +02:00
/* object_bake_simulation.cc */
namespace bake_simulation {
void OBJECT_OT_simulation_nodes_cache_calculate_to_frame(wmOperatorType *ot);
Geometry Nodes: add simulation support This adds support for building simulations with geometry nodes. A new `Simulation Input` and `Simulation Output` node allow maintaining a simulation state across multiple frames. Together these two nodes form a `simulation zone` which contains all the nodes that update the simulation state from one frame to the next. A new simulation zone can be added via the menu (`Simulation > Simulation Zone`) or with the node add search. The simulation state contains a geometry by default. However, it is possible to add multiple geometry sockets as well as other socket types. Currently, field inputs are evaluated and stored for the preceding geometry socket in the order that the sockets are shown. Simulation state items can be added by linking one of the empty sockets to something else. In the sidebar, there is a new panel that allows adding, removing and reordering these sockets. The simulation nodes behave as follows: * On the first frame, the inputs of the `Simulation Input` node are evaluated to initialize the simulation state. In later frames these sockets are not evaluated anymore. The `Delta Time` at the first frame is zero, but the simulation zone is still evaluated. * On every next frame, the `Simulation Input` node outputs the simulation state of the previous frame. Nodes in the simulation zone can edit that data in arbitrary ways, also taking into account the `Delta Time`. The new simulation state has to be passed to the `Simulation Output` node where it is cached and forwarded. * On a frame that is already cached or baked, the nodes in the simulation zone are not evaluated, because the `Simulation Output` node can return the previously cached data directly. It is not allowed to connect sockets from inside the simulation zone to the outside without going through the `Simulation Output` node. This is a necessary restriction to make caching and sub-frame interpolation work. Links can go into the simulation zone without problems though. Anonymous attributes are not propagated by the simulation nodes unless they are explicitly stored in the simulation state. This is unfortunate, but currently there is no practical and reliable alternative. The core problem is detecting which anonymous attributes will be required for the simulation and afterwards. While we can detect this for the current evaluation, we can't look into the future in time to see what data will be necessary. We intend to make it easier to explicitly pass data through a simulation in the future, even if the simulation is in a nested node group. There is a new `Simulation Nodes` panel in the physics tab in the properties editor. It allows baking all simulation zones on the selected objects. The baking options are intentially kept at a minimum for this MVP. More features for simulation baking as well as baking in general can be expected to be added separately. All baked data is stored on disk in a folder next to the .blend file. #106937 describes how baking is implemented in more detail. Volumes can not be baked yet and materials are lost during baking for now. Packing the baked data into the .blend file is not yet supported. The timeline indicates which frames are currently cached, baked or cached but invalidated by user-changes. Simulation input and output nodes are internally linked together by their `bNode.identifier` which stays the same even if the node name changes. They are generally added and removed together. However, there are still cases where "dangling" simulation nodes can be created currently. Those generally don't cause harm, but would be nice to avoid this in more cases in the future. Co-authored-by: Hans Goudey <h.goudey@me.com> Co-authored-by: Lukas Tönne <lukas@blender.org> Pull Request: https://projects.blender.org/blender/blender/pulls/104924
2023-05-03 13:18:51 +02:00
void OBJECT_OT_simulation_nodes_cache_bake(wmOperatorType *ot);
void OBJECT_OT_simulation_nodes_cache_delete(wmOperatorType *ot);
Geometry Nodes: new Bake node This adds a new `Bake` node which allows saving and loading intermediate geometries. Typical use cases we want address with this currently are: * Bake some data for use with a render engine. * Bake parts of the node tree explicitly for better performance. For now, the format that is written to disk is not considered to be an import/export format. It's not guaranteed that data written with one Blender version can be read by another Blender version. For that it's better to use proper interchange formats. Better support for those will be added eventually as well. We also plan an `Import Bake` node that allows reading the blender-specific baked data independent of the Bake node and at different frames. The baking works very similar to the baking in the simulation zone (UI and implementation wise). Major differences are: * The Bake node has a `Bake Still` and `Bake Animation` mode. * The Bake node doesn't do automatic caching. Implementation details: * Refactored how we create the Python operators for moving socket items so that it also makes sense for non-zones. * The `ModifierCache` stores an independent map of `SimulationNodeCache` and `BakeNodeCache`, but both share a common data structure for the actually baked data. * For baking, the `Bake` node is added as a side-effect-node in the modifier. This will make sure that the node is baked even if it's currently not connected to the output. * Had to add a new `DEG_id_tag_update_for_side_effect_request` function that is used during baking. It's necessary because I want to evaluate the object again even though none of its inputs changed. The reevaluation is necessary to create the baked data. Using `DEG_id_tag_update` technically works as well, but has the problem that it also uses the `DEG_UPDATE_SOURCE_USER_EDIT` flag which (rightly) invalidates simulation caches which shouldn't happen here. * Slightly refactored the timeline drawing so that it can also show the baked ranges of Bake nodes. It does not show anything for baked nodes with a in Still mode though. * The bake operator is refactored to bake a list of `NodeBakeRequest` which makes the code easier to follow compared to the previous nested `ObjectBakeData > ModifierBakeData > NodeBakeData` data structure. * The bake operators are disabled when the .blend file is not yet saved. This is technically only necessary when the bake path depends on the .blend file path but seems ok to force the user anyway (otherwise the bake path may be lost as well if it's set explicitly). * The same operators are used to bake and delete single bakes in `Bake` nodes and `Simulation Zones`. On top of that, there are separate operators of baking and deleting all simulation bakes (those ignore bake nodes). * The `Bake` node remembers which inputs have been fields and thus may be baked as attributes. For that it uses an `Is Attribute` flag on the socket item. This is needed because the baked data may still contain attribute data, even if the inputs to the bake node are disconnected. * Similar to simulation zones, the behavior of `Bake` nodes is passed into the geometry nodes evaluation from the outside (from the modifier only currently). This is done by providing the new `GeoNodesBakeParams` in `GeoNodesCallData` when executing geometry nodes. Next Steps (mostly because they also involve simulations): * Visualize nodes that have not been evaluated in the last evaluation. * Fix issue with seemingly loosing baked data after undo. * Improve error handling when baked data is not found. * Show bake node in link drag search. * Higher level tools for managing bakes. Pull Request: https://projects.blender.org/blender/blender/pulls/115466
2023-12-18 13:01:06 +01:00
void OBJECT_OT_geometry_node_bake_single(wmOperatorType *ot);
void OBJECT_OT_geometry_node_bake_delete_single(wmOperatorType *ot);
void OBJECT_OT_geometry_node_bake_pack_single(wmOperatorType *ot);
void OBJECT_OT_geometry_node_bake_unpack_single(wmOperatorType *ot);
Geometry Nodes: add simulation support This adds support for building simulations with geometry nodes. A new `Simulation Input` and `Simulation Output` node allow maintaining a simulation state across multiple frames. Together these two nodes form a `simulation zone` which contains all the nodes that update the simulation state from one frame to the next. A new simulation zone can be added via the menu (`Simulation > Simulation Zone`) or with the node add search. The simulation state contains a geometry by default. However, it is possible to add multiple geometry sockets as well as other socket types. Currently, field inputs are evaluated and stored for the preceding geometry socket in the order that the sockets are shown. Simulation state items can be added by linking one of the empty sockets to something else. In the sidebar, there is a new panel that allows adding, removing and reordering these sockets. The simulation nodes behave as follows: * On the first frame, the inputs of the `Simulation Input` node are evaluated to initialize the simulation state. In later frames these sockets are not evaluated anymore. The `Delta Time` at the first frame is zero, but the simulation zone is still evaluated. * On every next frame, the `Simulation Input` node outputs the simulation state of the previous frame. Nodes in the simulation zone can edit that data in arbitrary ways, also taking into account the `Delta Time`. The new simulation state has to be passed to the `Simulation Output` node where it is cached and forwarded. * On a frame that is already cached or baked, the nodes in the simulation zone are not evaluated, because the `Simulation Output` node can return the previously cached data directly. It is not allowed to connect sockets from inside the simulation zone to the outside without going through the `Simulation Output` node. This is a necessary restriction to make caching and sub-frame interpolation work. Links can go into the simulation zone without problems though. Anonymous attributes are not propagated by the simulation nodes unless they are explicitly stored in the simulation state. This is unfortunate, but currently there is no practical and reliable alternative. The core problem is detecting which anonymous attributes will be required for the simulation and afterwards. While we can detect this for the current evaluation, we can't look into the future in time to see what data will be necessary. We intend to make it easier to explicitly pass data through a simulation in the future, even if the simulation is in a nested node group. There is a new `Simulation Nodes` panel in the physics tab in the properties editor. It allows baking all simulation zones on the selected objects. The baking options are intentially kept at a minimum for this MVP. More features for simulation baking as well as baking in general can be expected to be added separately. All baked data is stored on disk in a folder next to the .blend file. #106937 describes how baking is implemented in more detail. Volumes can not be baked yet and materials are lost during baking for now. Packing the baked data into the .blend file is not yet supported. The timeline indicates which frames are currently cached, baked or cached but invalidated by user-changes. Simulation input and output nodes are internally linked together by their `bNode.identifier` which stays the same even if the node name changes. They are generally added and removed together. However, there are still cases where "dangling" simulation nodes can be created currently. Those generally don't cause harm, but would be nice to avoid this in more cases in the future. Co-authored-by: Hans Goudey <h.goudey@me.com> Co-authored-by: Lukas Tönne <lukas@blender.org> Pull Request: https://projects.blender.org/blender/blender/pulls/104924
2023-05-03 13:18:51 +02:00
} // namespace bake_simulation
/* `object_random.cc` */
void TRANSFORM_OT_vertex_random(wmOperatorType *ot);
/* object_remesh.cc */
void OBJECT_OT_voxel_remesh(wmOperatorType *ot);
void OBJECT_OT_voxel_size_edit(wmOperatorType *ot);
void OBJECT_OT_quadriflow_remesh(wmOperatorType *ot);
/* object_transfer_data.c */
/**
* Transfer mesh data from active to selected objects.
*/
void OBJECT_OT_data_transfer(wmOperatorType *ot);
void OBJECT_OT_datalayout_transfer(wmOperatorType *ot);
void object_modifier_add_asset_register();
void collection_exporter_register();
Vector<PointerRNA> modifier_get_edit_objects(const bContext &C, const wmOperator &op);
void modifier_register_use_selected_objects_prop(wmOperatorType *ot);
} // namespace blender::ed::object