Nodes: new interactive operator to slide nodes #121981

Open
Jacques Lucke wants to merge 24 commits from JacquesLucke/blender:slide-nodes into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
180 changed files with 6730 additions and 6980 deletions
Showing only changes of commit 4d64f626ac - Show all commits

View File

@ -46,7 +46,7 @@ def main():
# It's unlikely this directory exists.
# Keep it so users can bundle their own add-ons with app-templates which share modules.
# Also keep this for consistency with the other `addons` directories.
# Check this exists because the bundled scritps should not be manipulated at run-time.
# Check this exists because the bundled scripts should not be manipulated at run-time.
dirpath = join(dirname(dirname(dirname(__file__))), "addons_core", "modules")
if exists(dirpath):
sys.path.append(dirpath)

View File

@ -3222,6 +3222,10 @@ class WM_MT_splash_quick_setup(Menu):
def draw(self, context):
layout = self.layout
wm = context.window_manager
prefs = context.preferences
layout.operator_context = 'EXEC_DEFAULT'
old_version = bpy.types.PREFERENCES_OT_copy_prev.previous_version()
@ -3257,7 +3261,6 @@ class WM_MT_splash_quick_setup(Menu):
# Languages.
if bpy.app.build_options.international:
prefs = context.preferences
col.prop(prefs.view, "language")
# Themes.
@ -3270,7 +3273,6 @@ class WM_MT_splash_quick_setup(Menu):
col.separator()
# Shortcuts.
wm = context.window_manager
kc = wm.keyconfigs.active
kc_prefs = kc.preferences
@ -3280,15 +3282,13 @@ class WM_MT_splash_quick_setup(Menu):
text = "Blender"
sub.menu("USERPREF_MT_keyconfigs", text=text)
has_select_mouse = hasattr(kc_prefs, "select_mouse")
if has_select_mouse:
if hasattr(kc_prefs, "select_mouse"):
col.row().prop(kc_prefs, "select_mouse", text="Mouse Select", expand=True)
has_spacebar_action = hasattr(kc_prefs, "spacebar_action")
if has_spacebar_action:
if hasattr(kc_prefs, "spacebar_action"):
col.row().prop(kc_prefs, "spacebar_action", text="Spacebar Action")
# Themes.
# Save Preferences.
sub = col.column()
sub.separator(factor=2)

View File

@ -688,7 +688,7 @@ void BKE_armature_deform_coords_with_editmesh(const Object *ob_arm,
int deformflag,
float (*vert_coords_prev)[3],
const char *defgrp_name,
BMEditMesh *em_target);
const BMEditMesh *em_target);
/** \} */

View File

@ -75,8 +75,8 @@ void BKE_brush_gpencil_sculpt_presets(Main *bmain, ToolSettings *ts, bool reset)
void BKE_brush_gpencil_weight_presets(Main *bmain, ToolSettings *ts, bool reset);
void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, short type);
void BKE_brush_jitter_pos(const Scene *scene,
Brush *brush,
void BKE_brush_jitter_pos(const Scene &scene,
const Brush &brush,
const float pos[2],
float jitterpos[2]);
void BKE_brush_randomize_texture_coords(UnifiedPaintSettings *ups, bool mask);

View File

@ -1,31 +0,0 @@
/* SPDX-FileCopyrightText: 2006 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup bke
* \section aboutcdderivedmesh CDDerivedMesh interface
* CDDerivedMesh (CD = Custom Data) is a DerivedMesh backend which stores
* mesh elements (vertices, edges and faces) as layers of custom element data.
*
* \note This is deprecated & should eventually be removed.
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
struct DerivedMesh;
struct Mesh;
/* creates a CDDerivedMesh from the given Mesh, this will reference the
* original data in Mesh, but it is safe to apply vertex coordinates or
* calculate normals as those functions will automatically create new
* data to not overwrite the original. */
struct DerivedMesh *CDDM_from_mesh(struct Mesh *mesh);
#ifdef __cplusplus
}
#endif

View File

@ -423,7 +423,7 @@ void BKE_curve_deform_coords_with_editmesh(const Object *ob_curve,
int defgrp_index,
short flag,
short defaxis,
BMEditMesh *em_target);
const BMEditMesh *em_target);
/**
* \param orco: Input vec and orco = local coord in curve space

View File

@ -40,6 +40,7 @@ struct Scene;
* #Mesh.runtime.edit_mesh stores a pointer to this structure.
*/
struct BMEditMesh {
/* Always owned by an original mesh in edit mode. */
BMesh *bm;
/**

View File

@ -8,6 +8,9 @@
* \ingroup bke
*/
#include "BLI_math_vector_types.hh"
#include "BLI_span.hh"
#include "DNA_customdata_types.h"
struct BMEditMesh;
@ -23,9 +26,9 @@ void BKE_editmesh_loop_tangent_calc(BMEditMesh *em,
bool calc_active_tangent,
const char (*tangent_names)[MAX_CUSTOMDATA_LAYER_NAME],
int tangent_names_len,
const float (*face_normals)[3],
const float (*corner_normals)[3],
const float (*vert_orco)[3],
blender::Span<blender::float3> face_normals,
blender::Span<blender::float3> corner_normals,
blender::Span<blender::float3> vert_orco,
CustomData *dm_loopdata_out,
uint dm_loopdata_out_len,
short *tangent_mask_curr_p);

View File

@ -106,6 +106,6 @@ void BKE_lattice_deform_coords_with_editmesh(const Object *ob_lattice,
short flag,
const char *defgrp_name,
float fac,
BMEditMesh *em_target);
const BMEditMesh *em_target);
/** \} */

View File

@ -7,6 +7,7 @@
* \ingroup bke
*/
#include "BLI_array.hh"
#include "BLI_compiler_attrs.h"
#include "BLI_compiler_compat.h"
#include "BLI_utildefines.h"
@ -124,10 +125,9 @@ Mesh *BKE_mesh_new_nomain_from_template_ex(const Mesh *me_src,
CustomData_MeshMasks mask);
/**
* Performs copy for use during evaluation,
* optional referencing original arrays to reduce memory.
* Performs copy for use during evaluation.
*/
Mesh *BKE_mesh_copy_for_eval(const Mesh *source);
Mesh *BKE_mesh_copy_for_eval(const Mesh &source);
/**
* These functions construct a new Mesh,
@ -138,7 +138,10 @@ Mesh *BKE_mesh_new_nomain_from_curve_displist(const Object *ob, const ListBase *
bool BKE_mesh_attribute_required(const char *name);
float (*BKE_mesh_orco_verts_get(const Object *ob))[3];
blender::Array<blender::float3> BKE_mesh_orco_verts_get(const Object *ob);
void BKE_mesh_orco_verts_transform(Mesh *mesh,
blender::MutableSpan<blender::float3> orco,
bool invert);
void BKE_mesh_orco_verts_transform(Mesh *mesh, float (*orco)[3], int totvert, bool invert);
/**

View File

@ -14,6 +14,8 @@
#include "BKE_mesh.h"
#include "BKE_mesh_types.hh"
struct ModifierData;
namespace blender::bke {
enum class AttrDomain : int8_t;
@ -359,4 +361,9 @@ void mesh_ensure_default_color_attribute_on_add(Mesh &mesh,
AttrDomain domain,
eCustomDataType data_type);
void mesh_data_update(Depsgraph &depsgraph,
const Scene &scene,
Object &ob,
const CustomData_MeshMasks &dataMask);
} // namespace blender::bke

View File

@ -175,6 +175,12 @@ void DM_release(DerivedMesh *dm);
*/
void DM_set_only_copy(DerivedMesh *dm, const CustomData_MeshMasks *mask);
/* creates a CDDerivedMesh from the given Mesh, this will reference the
* original data in Mesh, but it is safe to apply vertex coordinates or
* calculate normals as those functions will automatically create new
* data to not overwrite the original. */
DerivedMesh *CDDM_from_mesh(Mesh *mesh);
/* -------------------------------------------------------------------- */
/** \name Custom Data Layer Access Functions
*
@ -209,27 +215,3 @@ void DM_interp_vert_data(const DerivedMesh *source,
float *weights,
int count,
int dest_index);
void mesh_get_mapped_verts_coords(Mesh *mesh_eval, blender::MutableSpan<blender::float3> r_cos);
/**
* Same as above but won't use render settings.
*/
Mesh *editbmesh_get_eval_cage(Depsgraph *depsgraph,
const Scene *scene,
Object *obedit,
BMEditMesh *em,
const CustomData_MeshMasks *dataMask);
Mesh *editbmesh_get_eval_cage_from_orig(Depsgraph *depsgraph,
const Scene *scene,
Object *obedit,
const CustomData_MeshMasks *dataMask);
bool editbmesh_modifier_is_enabled(const Scene *scene,
const Object *ob,
ModifierData *md,
bool has_prev_mesh);
void makeDerivedMesh(Depsgraph *depsgraph,
const Scene *scene,
Object *ob,
const CustomData_MeshMasks *dataMask);

View File

@ -9,9 +9,11 @@
* This file contains access functions for the Mesh.runtime struct.
*/
struct BMEditMesh;
struct CustomData_MeshMasks;
struct Depsgraph;
struct KeyBlock;
struct ModifierData;
struct Mesh;
struct Object;
struct Scene;
@ -41,10 +43,24 @@ void BKE_mesh_runtime_clear_geometry(Mesh *mesh);
*/
void BKE_mesh_runtime_clear_cache(Mesh *mesh);
/* NOTE: the functions below are defined in DerivedMesh.cc, and are intended to be moved
* to a more suitable location when that file is removed.
* They should also be renamed to use conventions from BKE, not old DerivedMesh.cc.
* For now keep the names similar to avoid confusion. */
namespace blender::bke {
void mesh_get_mapped_verts_coords(Mesh *mesh_eval, MutableSpan<float3> r_cos);
Mesh *editbmesh_get_eval_cage(Depsgraph *depsgraph,
const Scene *scene,
Object *obedit,
BMEditMesh *em,
const CustomData_MeshMasks *dataMask);
Mesh *editbmesh_get_eval_cage_from_orig(Depsgraph *depsgraph,
const Scene *scene,
Object *obedit,
const CustomData_MeshMasks *dataMask);
bool editbmesh_modifier_is_enabled(const Scene *scene,
const Object *ob,
ModifierData *md,
bool has_prev_mesh);
Mesh *mesh_get_eval_deform(Depsgraph *depsgraph,
const Scene *scene,
@ -65,7 +81,9 @@ Mesh *mesh_create_eval_no_deform_render(Depsgraph *depsgraph,
Object *ob,
const CustomData_MeshMasks *dataMask);
void BKE_mesh_runtime_eval_to_meshkey(Mesh *me_deformed, Mesh *mesh, KeyBlock *kb);
void mesh_eval_to_meshkey(const Mesh *me_deformed, Mesh *mesh, KeyBlock *kb);
} // namespace blender::bke
#ifndef NDEBUG
bool BKE_mesh_runtime_is_valid(Mesh *mesh_eval);

View File

@ -9,6 +9,7 @@
#include "DNA_customdata_types.h"
#include "BLI_math_vector_types.hh"
#include "BLI_offset_indices.hh"
#include "BLI_sys_types.h"
@ -45,7 +46,7 @@ void BKE_mesh_calc_loop_tangent_single(Mesh *mesh,
/**
* See: #BKE_editmesh_loop_tangent_calc (matching logic).
*/
void BKE_mesh_calc_loop_tangent_ex(const float (*vert_positions)[3],
void BKE_mesh_calc_loop_tangent_ex(blender::Span<blender::float3> vert_positions,
blender::OffsetIndices<int> faces,
const int *corner_verts,
const blender::int3 *corner_tris,
@ -57,10 +58,10 @@ void BKE_mesh_calc_loop_tangent_ex(const float (*vert_positions)[3],
bool calc_active_tangent,
const char (*tangent_names)[MAX_CUSTOMDATA_LAYER_NAME],
int tangent_names_len,
const float (*vert_normals)[3],
const float (*face_normals)[3],
const float (*corner_normals)[3],
const float (*vert_orco)[3],
blender::Span<blender::float3> vert_normals,
blender::Span<blender::float3> face_normals,
blender::Span<blender::float3> corner_normals,
blender::Span<blender::float3> vert_orco,
/* result */
CustomData *loopdata_out,
uint loopdata_out_len,

View File

@ -223,14 +223,14 @@ struct ModifierTypeInfo {
*/
void (*deform_verts_EM)(ModifierData *md,
const ModifierEvalContext *ctx,
BMEditMesh *em,
const BMEditMesh *em,
Mesh *mesh,
blender::MutableSpan<blender::float3> positions);
/* Set deform matrix per vertex for crazy-space correction */
void (*deform_matrices_EM)(ModifierData *md,
const ModifierEvalContext *ctx,
BMEditMesh *em,
const BMEditMesh *em,
Mesh *mesh,
blender::MutableSpan<blender::float3> positions,
blender::MutableSpan<blender::float3x3> matrices);
@ -578,7 +578,7 @@ void BKE_modifier_deform_verts(ModifierData *md,
void BKE_modifier_deform_vertsEM(ModifierData *md,
const ModifierEvalContext *ctx,
BMEditMesh *em,
const BMEditMesh *em,
Mesh *mesh,
blender::MutableSpan<blender::float3> positions);

View File

@ -604,7 +604,10 @@ const char *nodeStaticSocketLabel(int type, int subtype);
} \
((void)0)
bNodeSocket *nodeFindSocket(const bNode *node, eNodeSocketInOut in_out, const char *identifier);
bNodeSocket *nodeFindSocket(bNode *node, eNodeSocketInOut in_out, StringRef identifier);
const bNodeSocket *nodeFindSocket(const bNode *node,
eNodeSocketInOut in_out,
StringRef identifier);
bNodeSocket *nodeAddSocket(bNodeTree *ntree,
bNode *node,
eNodeSocketInOut in_out,
@ -1636,8 +1639,6 @@ void node_preview_init_tree(bNodeTree *ntree, int xsize, int ysize);
void node_preview_remove_unused(bNodeTree *ntree);
void node_preview_clear(bNodePreview *preview);
void node_preview_merge_tree(bNodeTree *to_ntree, bNodeTree *from_ntree, bool remove_old);
/* -------------------------------------------------------------------- */

View File

@ -244,12 +244,14 @@ void BKE_paint_face_set_overlay_color_get(int face_set, int seed, uchar r_color[
/* Stroke related. */
bool paint_calculate_rake_rotation(UnifiedPaintSettings *ups,
Brush *brush,
bool paint_calculate_rake_rotation(UnifiedPaintSettings &ups,
const Brush &brush,
const float mouse_pos[2],
PaintMode paint_mode,
bool stroke_has_started);
void paint_update_brush_rake_rotation(UnifiedPaintSettings *ups, Brush *brush, float rotation);
void paint_update_brush_rake_rotation(UnifiedPaintSettings &ups,
const Brush &brush,
float rotation);
void BKE_paint_stroke_get_average(const Scene *scene, const Object *ob, float stroke[3]);
@ -746,19 +748,6 @@ void BKE_sculpt_sync_face_visibility_to_grids(Mesh *mesh, SubdivCCG *subdiv_ccg)
*/
bool BKE_sculptsession_use_pbvh_draw(const Object *ob, const RegionView3D *rv3d);
/* paint_vertex.cc */
/**
* Fills the object's active color attribute layer with the fill color.
*
* \param only_selected: Limit the fill to selected faces or vertices.
*
* \return #true if successful.
*/
bool BKE_object_attributes_active_color_fill(Object *ob,
const float fill_color[4],
bool only_selected);
/** C accessor for #Object::sculpt::pbvh. */
PBVH *BKE_object_sculpt_pbvh_get(Object *object);
bool BKE_object_sculpt_use_dyntopo(const Object *object);

View File

@ -557,11 +557,10 @@ void BKE_pbvh_update_active_vcol(PBVH &pbvh, Mesh *mesh);
void BKE_pbvh_vertex_color_set(PBVH &pbvh,
blender::GroupedSpan<int> vert_to_face_map,
PBVHVertRef vertex,
const float color[4]);
void BKE_pbvh_vertex_color_get(const PBVH &pbvh,
blender::GroupedSpan<int> vert_to_face_map,
PBVHVertRef vertex,
float r_color[4]);
const blender::float4 &color);
blender::float4 BKE_pbvh_vertex_color_get(const PBVH &pbvh,
blender::GroupedSpan<int> vert_to_face_map,
PBVHVertRef vertex);
void BKE_pbvh_ensure_node_loops(PBVH &pbvh);
int BKE_pbvh_debug_draw_gen_get(PBVHNode &node);

View File

@ -4,18 +4,43 @@
#pragma once
#include <array>
#include <memory>
#include <optional>
#include "BLI_sys_types.h"
#include "DNA_ID_enums.h"
struct BlendWriter;
struct BlendDataReader;
struct BlendWriter;
struct GPUTexture;
struct ID;
struct ImBuf;
struct PreviewImage;
enum ThumbSource : int8_t;
namespace blender::bke {
struct PreviewDeferredLoadingData;
struct PreviewImageRuntime {
/** Used by previews outside of ID context. */
int icon_id = 0;
int16_t tag = 0;
std::array<GPUTexture *, NUM_ICON_SIZES> gputexture = {};
/** Used to store data to defer the loading of the preview. If empty, loading is not deferred. */
std::unique_ptr<PreviewDeferredLoadingData> deferred_loading_data;
PreviewImageRuntime();
PreviewImageRuntime(const PreviewImageRuntime &other);
~PreviewImageRuntime();
};
} // namespace blender::bke
void BKE_preview_images_init();
void BKE_preview_images_free();
@ -29,9 +54,6 @@ void BKE_previewimg_freefunc(void *link);
*/
void BKE_previewimg_free(PreviewImage **prv);
/** Must be called after reading a preview image from file. */
void BKE_previewimg_runtime_data_clear(PreviewImage *prv);
/**
* Clear the preview image or icon, but does not free it.
*/

View File

@ -16,8 +16,6 @@
#include "BLI_offset_indices.hh"
#include "BLI_sys_types.h"
#include "BKE_DerivedMesh.hh"
struct CCGElem;
struct CCGKey;
struct Mesh;

View File

@ -8,7 +8,7 @@
*/
/* struct DerivedMesh is used directly */
#include "BKE_DerivedMesh.hh"
#include "BKE_mesh_legacy_derived_mesh.hh"
/* Thread sync primitives used directly. */
#include "BLI_ordered_edge.hh"
@ -94,13 +94,6 @@ struct CCGDerivedMesh {
CCGFace *face;
} *faceMap;
int *reverseFaceMap;
PBVH *pbvh;
MeshElemMap *pmap;
int *pmap_mem;
CCGElem **gridData;
int *gridOffset;
CCGFace **gridFaces;

View File

@ -47,7 +47,6 @@ set(SRC
intern/CCGSubSurf.cc
intern/CCGSubSurf_legacy.cc
intern/CCGSubSurf_util.cc
intern/DerivedMesh.cc
intern/action.cc
intern/action_bones.cc
intern/action_mirror.cc
@ -89,7 +88,6 @@ set(SRC
intern/cachefile.cc
intern/callbacks.cc
intern/camera.cc
intern/cdderivedmesh.cc
intern/cloth.cc
intern/collection.cc
intern/collision.cc
@ -201,12 +199,14 @@ set(SRC
intern/mesh_calc_edges.cc
intern/mesh_compare.cc
intern/mesh_convert.cc
intern/mesh_data_update.cc
intern/mesh_debug.cc
intern/mesh_evaluate.cc
intern/mesh_fair.cc
intern/mesh_flip_faces.cc
intern/mesh_iterators.cc
intern/mesh_legacy_convert.cc
intern/mesh_legacy_derived_mesh.cc
intern/mesh_mapping.cc
intern/mesh_merge_customdata.cc
intern/mesh_mirror.cc
@ -321,7 +321,6 @@ set(SRC
intern/world.cc
intern/writemovie.cc
BKE_DerivedMesh.hh
BKE_action.h
BKE_action.hh
BKE_addon.h
@ -359,7 +358,6 @@ set(SRC
BKE_callbacks.hh
BKE_camera.h
BKE_ccg.h
BKE_cdderivedmesh.h
BKE_cloth.hh
BKE_collection.hh
BKE_collision.h
@ -447,6 +445,7 @@ set(SRC
BKE_mesh_fair.hh
BKE_mesh_iterators.hh
BKE_mesh_legacy_convert.hh
BKE_mesh_legacy_derived_mesh.hh
BKE_mesh_mapping.hh
BKE_mesh_mirror.hh
BKE_mesh_remap.hh

View File

@ -489,7 +489,7 @@ static void armature_deform_coords_impl(const Object *ob_arm,
const char *defgrp_name,
blender::Span<MDeformVert> dverts,
const Mesh *me_target,
BMEditMesh *em_target,
const BMEditMesh *em_target,
bGPDstroke *gps_target)
{
const bArmature *arm = static_cast<const bArmature *>(ob_arm->data);
@ -710,7 +710,7 @@ void BKE_armature_deform_coords_with_editmesh(const Object *ob_arm,
int deformflag,
float (*vert_coords_prev)[3],
const char *defgrp_name,
BMEditMesh *em_target)
const BMEditMesh *em_target)
{
armature_deform_coords_impl(ob_arm,
ob_target,

View File

@ -1154,7 +1154,7 @@ static void blendfile_append_define_actions(BlendfileLinkAppendContext *lapp_con
LinkNode *itemlink;
/* In case of non-recursive appending, gather a set of all 'original' libraries (i.e. libraries
* containing data that was explicitely selected by the user). */
* containing data that was explicitly selected by the user). */
blender::Set<Library *> direct_libraries;
if (!do_recursive) {
for (itemlink = lapp_context->items.list; itemlink; itemlink = itemlink->next) {
@ -1251,7 +1251,7 @@ static void blendfile_append_define_actions(BlendfileLinkAppendContext *lapp_con
* either there were some changes in the library data, or the previously appended local
* dependencies was modified in current file and therefore cannot be re-used anymore), then the
* user ID should not be considered as usable either. */
/* TODO: This process is currently fairly raw and inneficient. This is likely not a
/* TODO: This process is currently fairly raw and inefficient. This is likely not a
* (significant) issue currently anyway. But would be good to refactor this whole code to use
* modern CPP containers (list of items could be an `std::deque` e.g., to be iterable in both
* directions). Being able to loop backward here (i.e. typically process the dependencies

View File

@ -2531,7 +2531,10 @@ void BKE_brush_scale_size(int *r_brush_size,
(*r_brush_size) = int(float(*r_brush_size) * scale);
}
void BKE_brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2], float jitterpos[2])
void BKE_brush_jitter_pos(const Scene &scene,
const Brush &brush,
const float pos[2],
float jitterpos[2])
{
float rand_pos[2];
float spread;
@ -2542,13 +2545,13 @@ void BKE_brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2],
rand_pos[1] = BLI_rng_get_float(brush_rng) - 0.5f;
} while (len_squared_v2(rand_pos) > square_f(0.5f));
if (brush->flag & BRUSH_ABSOLUTE_JITTER) {
diameter = 2 * brush->jitter_absolute;
if (brush.flag & BRUSH_ABSOLUTE_JITTER) {
diameter = 2 * brush.jitter_absolute;
spread = 1.0;
}
else {
diameter = 2 * BKE_brush_size_get(scene, brush);
spread = brush->jitter;
diameter = 2 * BKE_brush_size_get(&scene, &brush);
spread = brush.jitter;
}
/* find random position within a circle of diameter 1 */
jitterpos[0] = pos[0] + 2 * rand_pos[0] * diameter * spread;

View File

@ -1,196 +0,0 @@
/* SPDX-FileCopyrightText: 2006 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup bke
* Implementation of #CDDerivedMesh.
* BKE_cdderivedmesh.h contains the function prototypes for this file.
*/
#include <climits>
#include <cmath>
#include <cstring>
#include "BLI_utildefines.h"
#include "BKE_DerivedMesh.hh"
#include "BKE_cdderivedmesh.h"
#include "BKE_editmesh.hh"
#include "BKE_mesh_mapping.hh"
#include "BKE_pbvh.hh"
#include "DNA_curve_types.h" /* for Curve */
#include "DNA_mesh_types.h"
#include "MEM_guardedalloc.h"
struct CDDerivedMesh {
DerivedMesh dm;
/* these point to data in the DerivedMesh custom data layers,
* they are only here for efficiency and convenience */
float (*vert_positions)[3];
blender::int2 *medge;
MFace *mface;
int *corner_verts;
int *corner_edges;
/* Cached */
PBVH *pbvh;
bool pbvh_draw;
/* Mesh connectivity */
MeshElemMap *pmap;
int *pmap_mem;
};
/**************** DerivedMesh interface functions ****************/
static int cdDM_getNumVerts(DerivedMesh *dm)
{
return dm->numVertData;
}
static int cdDM_getNumEdges(DerivedMesh *dm)
{
return dm->numEdgeData;
}
static int cdDM_getNumLoops(DerivedMesh *dm)
{
return dm->numLoopData;
}
static int cdDM_getNumPolys(DerivedMesh *dm)
{
return dm->numPolyData;
}
static void cdDM_copyVertArray(DerivedMesh *dm, float (*r_positions)[3])
{
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
memcpy(r_positions, cddm->vert_positions, sizeof(float[3]) * dm->numVertData);
}
static void cdDM_copyEdgeArray(DerivedMesh *dm, blender::int2 *r_edge)
{
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
memcpy(r_edge, cddm->medge, sizeof(*r_edge) * dm->numEdgeData);
}
static void cdDM_copyCornerVertArray(DerivedMesh *dm, int *r_corner_verts)
{
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
memcpy(r_corner_verts, cddm->corner_verts, sizeof(*r_corner_verts) * dm->numLoopData);
}
static void cdDM_copyCornerEdgeArray(DerivedMesh *dm, int *r_corner_edges)
{
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
memcpy(r_corner_edges, cddm->corner_edges, sizeof(*r_corner_edges) * dm->numLoopData);
}
static void cdDM_copyPolyArray(DerivedMesh *dm, int *r_face_offsets)
{
memcpy(r_face_offsets, dm->face_offsets, sizeof(int) * (dm->numPolyData + 1));
}
static void cdDM_free_internal(CDDerivedMesh *cddm)
{
if (cddm->pmap) {
MEM_freeN(cddm->pmap);
}
if (cddm->pmap_mem) {
MEM_freeN(cddm->pmap_mem);
}
}
static void cdDM_release(DerivedMesh *dm)
{
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
DM_release(dm);
cdDM_free_internal(cddm);
MEM_freeN(cddm);
}
/**************** CDDM interface functions ****************/
static CDDerivedMesh *cdDM_create(const char *desc)
{
CDDerivedMesh *cddm = MEM_cnew<CDDerivedMesh>(desc);
DerivedMesh *dm = &cddm->dm;
dm->getNumVerts = cdDM_getNumVerts;
dm->getNumEdges = cdDM_getNumEdges;
dm->getNumLoops = cdDM_getNumLoops;
dm->getNumPolys = cdDM_getNumPolys;
dm->copyVertArray = cdDM_copyVertArray;
dm->copyEdgeArray = cdDM_copyEdgeArray;
dm->copyCornerVertArray = cdDM_copyCornerVertArray;
dm->copyCornerEdgeArray = cdDM_copyCornerEdgeArray;
dm->copyPolyArray = cdDM_copyPolyArray;
dm->getVertDataArray = DM_get_vert_data_layer;
dm->getEdgeDataArray = DM_get_edge_data_layer;
dm->release = cdDM_release;
return cddm;
}
static DerivedMesh *cdDM_from_mesh_ex(Mesh *mesh, const CustomData_MeshMasks *mask)
{
CDDerivedMesh *cddm = cdDM_create(__func__);
DerivedMesh *dm = &cddm->dm;
CustomData_MeshMasks cddata_masks = *mask;
cddata_masks.lmask &= ~CD_MASK_MDISPS;
/* this does a referenced copy, with an exception for fluidsim */
DM_init(dm,
DM_TYPE_CDDM,
mesh->verts_num,
mesh->edges_num,
0 /* `mesh->totface` */,
mesh->corners_num,
mesh->faces_num);
CustomData_merge(&mesh->vert_data, &dm->vertData, cddata_masks.vmask, mesh->verts_num);
CustomData_merge(&mesh->edge_data, &dm->edgeData, cddata_masks.emask, mesh->edges_num);
CustomData_merge(&mesh->fdata_legacy,
&dm->faceData,
cddata_masks.fmask | CD_MASK_ORIGINDEX,
0 /* `mesh->totface` */);
CustomData_merge(&mesh->corner_data, &dm->loopData, cddata_masks.lmask, mesh->corners_num);
CustomData_merge(&mesh->face_data, &dm->polyData, cddata_masks.pmask, mesh->faces_num);
cddm->vert_positions = static_cast<float(*)[3]>(CustomData_get_layer_named_for_write(
&dm->vertData, CD_PROP_FLOAT3, "position", mesh->verts_num));
cddm->medge = static_cast<blender::int2 *>(CustomData_get_layer_named_for_write(
&dm->edgeData, CD_PROP_INT32_2D, ".edge_verts", mesh->edges_num));
cddm->corner_verts = static_cast<int *>(CustomData_get_layer_named_for_write(
&dm->loopData, CD_PROP_INT32, ".corner_vert", mesh->corners_num));
cddm->corner_edges = static_cast<int *>(CustomData_get_layer_named_for_write(
&dm->loopData, CD_PROP_INT32, ".corner_edge", mesh->corners_num));
dm->face_offsets = static_cast<int *>(MEM_dupallocN(mesh->face_offset_indices));
#if 0
cddm->mface = CustomData_get_layer(&dm->faceData, CD_MFACE);
#else
cddm->mface = nullptr;
#endif
/* commented since even when CD_ORIGINDEX was first added this line fails
* on the default cube, (after editmode toggle too) - campbell */
#if 0
BLI_assert(CustomData_has_layer(&cddm->dm.faceData, CD_ORIGINDEX));
#endif
return dm;
}
DerivedMesh *CDDM_from_mesh(Mesh *mesh)
{
return cdDM_from_mesh_ex(mesh, &CD_MASK_MESH);
}

View File

@ -1162,7 +1162,7 @@ static void cloth_update_verts(Object *ob, ClothModifierData *clmd, Mesh *mesh)
static Mesh *cloth_make_rest_mesh(ClothModifierData *clmd, Mesh *mesh)
{
using namespace blender;
Mesh *new_mesh = BKE_mesh_copy_for_eval(mesh);
Mesh *new_mesh = BKE_mesh_copy_for_eval(*mesh);
ClothVertex *verts = clmd->clothObject->verts;
MutableSpan<float3> positions = mesh->vert_positions_for_write();

View File

@ -17,7 +17,6 @@
#include "BLI_math_rotation.h"
#include "BLI_utildefines.h"
#include "BKE_DerivedMesh.hh"
#include "BKE_crazyspace.hh"
#include "BKE_curves.hh"
#include "BKE_editmesh.hh"
@ -25,6 +24,7 @@
#include "BKE_grease_pencil.hh"
#include "BKE_lib_id.hh"
#include "BKE_mesh.hh"
#include "BKE_mesh_runtime.hh"
#include "BKE_mesh_wrapper.hh"
#include "BKE_modifier.hh"
#include "BKE_multires.hh"
@ -97,17 +97,17 @@ blender::Array<blender::float3> BKE_crazyspace_get_mapped_editverts(Depsgraph *d
if (modifiers_disable_subsurf_temporary(obedit_eval, cageIndex)) {
/* Need to make new cage.
* TODO: Avoid losing original evaluated geometry. */
makeDerivedMesh(depsgraph, scene_eval, obedit_eval, &CD_MASK_BAREMESH);
blender::bke::mesh_data_update(*depsgraph, *scene_eval, *obedit_eval, CD_MASK_BAREMESH);
}
/* Now get the cage. */
BMEditMesh *em_eval = BKE_editmesh_from_object(obedit_eval);
Mesh *mesh_eval_cage = editbmesh_get_eval_cage(
Mesh *mesh_eval_cage = blender::bke::editbmesh_get_eval_cage(
depsgraph, scene_eval, obedit_eval, em_eval, &CD_MASK_BAREMESH);
const int nverts = em_eval->bm->totvert;
blender::Array<blender::float3> vertexcos(nverts);
mesh_get_mapped_verts_coords(mesh_eval_cage, vertexcos);
blender::bke::mesh_get_mapped_verts_coords(mesh_eval_cage, vertexcos);
/* Set back the flag, and ensure new cage needs to be built. */
if (modifiers_disable_subsurf_temporary(obedit_eval, cageIndex)) {
@ -260,7 +260,7 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(
for (i = 0; md && i <= cageIndex; i++, md = md->next) {
const ModifierTypeInfo *mti = BKE_modifier_get_info(static_cast<ModifierType>(md->type));
if (!editbmesh_modifier_is_enabled(scene, ob, md, mesh != nullptr)) {
if (!blender::bke::editbmesh_modifier_is_enabled(scene, ob, md, mesh != nullptr)) {
continue;
}
@ -288,7 +288,7 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(
}
for (; md && i <= cageIndex; md = md->next, i++) {
if (editbmesh_modifier_is_enabled(scene, ob, md, mesh != nullptr) &&
if (blender::bke::editbmesh_modifier_is_enabled(scene, ob, md, mesh != nullptr) &&
BKE_modifier_is_correctable_deformed(md))
{
modifiers_left_num++;
@ -372,7 +372,7 @@ int BKE_sculpt_get_first_deform_matrices(Depsgraph *depsgraph,
if (deformmats.is_empty()) {
/* NOTE: Evaluated object is re-set to its original un-deformed state. */
Mesh *mesh = static_cast<Mesh *>(object_eval.data);
mesh_eval = BKE_mesh_copy_for_eval(mesh);
mesh_eval = BKE_mesh_copy_for_eval(*mesh);
deformcos = mesh->vert_positions();
deformmats.reinitialize(mesh->verts_num);
deformmats.fill(blender::float3x3::identity());
@ -456,7 +456,7 @@ void BKE_crazyspace_build_sculpt(Depsgraph *depsgraph,
}
if (mesh_eval == nullptr) {
mesh_eval = BKE_mesh_copy_for_eval(mesh);
mesh_eval = BKE_mesh_copy_for_eval(*mesh);
}
mti->deform_verts(md, &mectx, mesh_eval, deformedVerts);

View File

@ -204,7 +204,7 @@ static void curve_deform_coords_impl(const Object *ob_curve,
const int defgrp_index,
const short flag,
const short defaxis,
BMEditMesh *em_target)
const BMEditMesh *em_target)
{
Curve *cu;
int a;
@ -391,7 +391,7 @@ void BKE_curve_deform_coords_with_editmesh(const Object *ob_curve,
const int defgrp_index,
const short flag,
const short defaxis,
BMEditMesh *em_target)
const BMEditMesh *em_target)
{
curve_deform_coords_impl(ob_curve,
ob_target,

View File

@ -1916,7 +1916,7 @@ static void dynamic_paint_apply_surface_wave_cb(void *__restrict userdata,
*/
static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *ob, Mesh *mesh)
{
Mesh *result = BKE_mesh_copy_for_eval(mesh);
Mesh *result = BKE_mesh_copy_for_eval(*mesh);
if (pmd->canvas && !(pmd->canvas->flags & MOD_DPAINT_BAKING) &&
pmd->type == MOD_DYNAMICPAINT_TYPE_CANVAS)
@ -2069,7 +2069,7 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
if (runtime_data->brush_mesh != nullptr) {
BKE_id_free(nullptr, runtime_data->brush_mesh);
}
runtime_data->brush_mesh = BKE_mesh_copy_for_eval(result);
runtime_data->brush_mesh = BKE_mesh_copy_for_eval(*result);
}
return result;
@ -2090,7 +2090,7 @@ static void canvas_copyMesh(DynamicPaintCanvasSettings *canvas, Mesh *mesh)
BKE_id_free(nullptr, runtime->canvas_mesh);
}
runtime->canvas_mesh = BKE_mesh_copy_for_eval(mesh);
runtime->canvas_mesh = BKE_mesh_copy_for_eval(*mesh);
}
/*
@ -3827,7 +3827,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(Depsgraph *depsgraph,
SUBFRAME_RECURSION,
BKE_scene_ctime_get(scene),
eModifierType_DynamicPaint);
mesh_p = BKE_mesh_copy_for_eval(dynamicPaint_brush_mesh_get(brush));
mesh_p = BKE_mesh_copy_for_eval(*dynamicPaint_brush_mesh_get(brush));
numOfVerts_p = mesh_p->verts_num;
float(*positions_p)[3] = reinterpret_cast<float(*)[3]>(
@ -4319,7 +4319,7 @@ static bool dynamicPaint_paintMesh(Depsgraph *depsgraph,
Bounds3D mesh_bb = {{0}};
DynamicPaintVolumeGrid *grid = bData->grid;
mesh = BKE_mesh_copy_for_eval(brush_mesh);
mesh = BKE_mesh_copy_for_eval(*brush_mesh);
blender::MutableSpan<blender::float3> positions = mesh->vert_positions_for_write();
const blender::Span<blender::float3> vert_normals = mesh->vert_normals();
const blender::Span<int> corner_verts = mesh->corner_verts();

View File

@ -16,11 +16,11 @@
#<