Cleanup: Reduce use and scope of templates in vertex paint #2

Closed
Hans Goudey wants to merge 10 commits from paint-vertex-fewer-templates into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
63 changed files with 298 additions and 255 deletions
Showing only changes of commit 9f4674287e - Show all commits

View File

@ -27,7 +27,7 @@ ccl_device void spot_light_uv(const float3 ray,
ccl_private float *u,
ccl_private float *v)
{
/* Ensures that the spot light projects the full image regarless of the spot angle. */
/* Ensures that the spot light projects the full image regardless of the spot angle. */
const float factor = half_cot_half_spot_angle / ray.z;
/* NOTE: Return barycentric coordinates in the same notation as Embree and OptiX. */

View File

@ -151,10 +151,10 @@ ccl_device_inline void sample_uniform_cone_concentric(const float3 N,
* hemisphere doesn't change the radius. For the latter, r_cone(rand) =
* sin_from_cos(mix(cos_angle, 1, rand)).
*
* So, to remap, we just invert r_disk (-> rand(r_disk) = r_disk^2) and insert it into r_cone:
* r_cone(r_disk) = r_cone(rand(r_disk)) = sin_from_cos(mix(cos_angle, 1, r_disk^2)). In
* practise, we need to replace `rand` with `1 - rand` to preserve the stratification, but
* since it's uniform, that's fine. */
* So, to remap, we just invert r_disk `(-> rand(r_disk) = r_disk^2)` and insert it into
* r_cone: `r_cone(r_disk) = r_cone(rand(r_disk)) = sin_from_cos(mix(cos_angle, 1, r_disk^2))`.
* In practice, we need to replace `rand` with `1 - rand` to preserve the stratification,
* but since it's uniform, that's fine. */
float2 xy = concentric_sample_disk(rand);
const float r2 = len_squared(xy);

View File

@ -6097,8 +6097,8 @@ static GHOST_TSuccess getCursorPositionClientRelative_impl(
y = wl_fixed_to_int(win->wl_fixed_to_window(xy_wrap[1]));
}
else {
x = win->wl_fixed_to_window(seat_state_pointer->xy[0]);
y = win->wl_fixed_to_window(seat_state_pointer->xy[1]);
x = wl_fixed_to_int(win->wl_fixed_to_window(seat_state_pointer->xy[0]));
y = wl_fixed_to_int(win->wl_fixed_to_window(seat_state_pointer->xy[1]));
}
return GHOST_kSuccess;

View File

@ -40,8 +40,9 @@ struct bAction *BKE_action_add(struct Main *bmain, const char name[]);
/* Action API ----------------- */
/* types of transforms applied to the given item
* - these are the return flags for action_get_item_transforms()
/**
* Types of transforms applied to the given item:
* - these are the return flags for #BKE_action_get_item_transform_flags()
*/
typedef enum eAction_TransformFlags {
/* location */
@ -69,24 +70,29 @@ typedef enum eAction_TransformFlags {
* - if 'curves' is provided, a list of links to these curves are also returned
* whose nodes WILL NEED FREEING.
*/
short action_get_item_transforms(struct bAction *act,
struct Object *ob,
struct bPoseChannel *pchan,
ListBase *curves);
eAction_TransformFlags BKE_action_get_item_transform_flags(struct bAction *act,
struct Object *ob,
struct bPoseChannel *pchan,
ListBase *curves);
/**
* Calculate the extents of given action.
*/
void calc_action_range(const struct bAction *act, float *start, float *end, short incl_modifiers);
void BKE_action_frame_range_calc(const struct bAction *act,
bool include_modifiers,
float *r_start,
float *r_end);
/* Retrieve the intended playback frame range, using the manually set range if available,
* or falling back to scanning F-Curves for their first & last frames otherwise. */
void BKE_action_get_frame_range(const struct bAction *act, float *r_start, float *r_end);
/**
* Retrieve the intended playback frame range, using the manually set range if available,
* or falling back to scanning F-Curves for their first & last frames otherwise.
*/
void BKE_action_frame_range_get(const struct bAction *act, float *r_start, float *r_end);
/**
* Check if the given action has any keyframes.
*/
bool action_has_motion(const struct bAction *act);
bool BKE_action_has_motion(const struct bAction *act);
/**
* Is the action configured as cyclic.

View File

@ -818,7 +818,9 @@ void node_type_storage(struct bNodeType *ntype,
/** \} */
/* ************** COMMON NODES *************** */
/* -------------------------------------------------------------------- */
/** \name Common Node Types
* \{ */
#define NODE_UNDEFINED -2 /* node type is not registered */
#define NODE_CUSTOM -1 /* for dynamically registered custom types */
@ -845,7 +847,7 @@ void node_type_storage(struct bNodeType *ntype,
*
* - nodetree:
* The actual bNodeTree data block.
* Check nodetree->idname or nodetree->typeinfo to use only specific types.
* Check `nodetree->idname` or `nodetree->typeinfo` to use only specific types.
*
* - id:
* The owner of the bNodeTree data block.

View File

@ -108,7 +108,7 @@ static void action_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src,
for (fcurve_src = action_src->curves.first; fcurve_src; fcurve_src = fcurve_src->next) {
/* Duplicate F-Curve. */
/* XXX TODO: pass subdata flag?
/* XXX TODO: pass sub-data flag?
* But surprisingly does not seem to be doing any ID reference-counting. */
fcurve_dst = BKE_fcurve_copy(fcurve_src);
@ -1334,7 +1334,7 @@ void BKE_pose_remove_group_index(bPose *pose, const int index)
/* ************** F-Curve Utilities for Actions ****************** */
bool action_has_motion(const bAction *act)
bool BKE_action_has_motion(const bAction *act)
{
FCurve *fcu;
@ -1392,7 +1392,10 @@ bool BKE_action_has_single_frame(const bAction *act)
return found_key;
}
void calc_action_range(const bAction *act, float *start, float *end, short incl_modifiers)
void BKE_action_frame_range_calc(const bAction *act,
bool include_modifiers,
float *r_start,
float *r_end)
{
FCurve *fcu;
float min = 999999999.0f, max = -999999999.0f;
@ -1419,10 +1422,10 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_
foundvert = 1;
}
/* if incl_modifiers is enabled, need to consider modifiers too
/* if include_modifiers is enabled, need to consider modifiers too
* - only really care about the last modifier
*/
if ((incl_modifiers) && (fcu->modifiers.last)) {
if ((include_modifiers) && (fcu->modifiers.last)) {
FModifier *fcm = fcu->modifiers.last;
/* only use the maximum sensible limits of the modifiers if they are more extreme */
@ -1470,23 +1473,23 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_
max += 1.0f;
}
*start = max_ff(min, MINAFRAMEF);
*end = min_ff(max, MAXFRAMEF);
*r_start = max_ff(min, MINAFRAMEF);
*r_end = min_ff(max, MAXFRAMEF);
}
else {
*start = 0.0f;
*end = 1.0f;
*r_start = 0.0f;
*r_end = 1.0f;
}
}
void BKE_action_get_frame_range(const bAction *act, float *r_start, float *r_end)
void BKE_action_frame_range_get(const bAction *act, float *r_start, float *r_end)
{
if (act && (act->flag & ACT_FRAME_RANGE)) {
*r_start = act->frame_start;
*r_end = act->frame_end;
}
else {
calc_action_range(act, r_start, r_end, false);
BKE_action_frame_range_calc(act, r_start, r_end, false);
}
/* Ensure that action is at least 1 frame long (for NLA strips to have a valid length). */
@ -1500,7 +1503,10 @@ bool BKE_action_is_cyclic(const bAction *act)
return act && (act->flag & ACT_FRAME_RANGE) && (act->flag & ACT_CYCLIC);
}
short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan, ListBase *curves)
eAction_TransformFlags BKE_action_get_item_transform_flags(bAction *act,
Object *ob,
bPoseChannel *pchan,
ListBase *curves)
{
PointerRNA ptr;
FCurve *fcu;

View File

@ -1352,7 +1352,7 @@ void BKE_animdata_fix_paths_rename_all_ex(Main *bmain,
} \
(void)0
/* another version of this macro for nodetrees */
/* Another version of this macro for node-trees. */
#define RENAMEFIX_ANIM_NODETREE_IDS(first, NtId_Type) \
for (id = first; id; id = id->next) { \
AnimData *adt = BKE_animdata_from_id(id); \

View File

@ -3237,7 +3237,8 @@ static void animsys_create_action_track_strip(const AnimData *adt,
/* Action range is calculated taking F-Modifiers into account
* (which making new strips doesn't do due to the troublesome nature of that). */
calc_action_range(r_action_strip->act, &r_action_strip->actstart, &r_action_strip->actend, 1);
BKE_action_frame_range_calc(
r_action_strip->act, true, &r_action_strip->actstart, &r_action_strip->actend);
r_action_strip->start = r_action_strip->actstart;
r_action_strip->end = IS_EQF(r_action_strip->actstart, r_action_strip->actend) ?
(r_action_strip->actstart + 1.0f) :
@ -4002,11 +4003,11 @@ void BKE_animsys_evaluate_all_animation(Main *main, Depsgraph *depsgraph, float
} \
(void)0
/* another macro for the "embedded" nodetree cases
* - this is like EVAL_ANIM_IDS, but this handles the case "embedded nodetrees"
* (i.e. scene/material/texture->nodetree) which we need a special exception
* for, otherwise they'd get skipped
* - 'ntp' stands for "node tree parent" = data-block where node tree stuff resides
/* Another macro for the "embedded" node-tree cases
* - This is like #EVAL_ANIM_IDS, but this handles the case "embedded node-trees"
* (i.e. `scene/material/texture->nodetree`) which we need a special exception
* for, otherwise they'd get skipped.
* - `ntp` stands for "node tree parent" = data-block where node tree stuff resides.
*/
#define EVAL_ANIM_NODETREE_IDS(first, NtId_Type, aflag) \
for (id = first; id; id = id->next) { \

View File

@ -1029,31 +1029,31 @@ void BKE_curveprofile_evaluate_length_portion(const CurveProfile *profile,
/* Find the last point along the path with a lower length portion than the input. */
int i = 0;
float length_travelled = 0.0f;
while (length_travelled < requested_length) {
float length_traveled = 0.0f;
while (length_traveled < requested_length) {
/* Check if we reached the last point before the final one. */
if (i == BKE_curveprofile_table_size(profile) - 2) {
break;
}
float new_length = curveprofile_distance_to_next_table_point(profile, i);
if (length_travelled + new_length >= requested_length) {
if (length_traveled + new_length >= requested_length) {
break;
}
length_travelled += new_length;
length_traveled += new_length;
i++;
}
/* Now travel the remaining distance of length portion down the path to the next point and
* find the location where we stop. */
float distance_to_next_point = curveprofile_distance_to_next_table_point(profile, i);
float lerp_factor = (requested_length - length_travelled) / distance_to_next_point;
float lerp_factor = (requested_length - length_traveled) / distance_to_next_point;
#ifdef DEBUG_CURVEPROFILE_EVALUATE
printf("CURVEPROFILE EVALUATE\n");
printf(" length portion input: %f\n", double(length_portion));
printf(" requested path length: %f\n", double(requested_length));
printf(" distance to next point: %f\n", double(distance_to_next_point));
printf(" length travelled: %f\n", double(length_travelled));
printf(" length traveled: %f\n", double(length_traveled));
printf(" lerp-factor: %f\n", double(lerp_factor));
printf(" ith point (%f, %f)\n", double(profile->path[i].x), double(profile->path[i].y));
printf(" next point(%f, %f)\n", double(profile->path[i + 1].x), double(profile->path[i + 1].y));

View File

@ -60,8 +60,8 @@ CurvesGeometry::CurvesGeometry(const int point_num, const int curve_num)
CustomData_reset(&this->point_data);
CustomData_reset(&this->curve_data);
CustomData_add_layer_named(
&this->point_data, CD_PROP_FLOAT3, CD_CONSTRUCT, this->point_num, ATTR_POSITION.c_str());
this->attributes_for_write().add<float3>(
"position", ATTR_DOMAIN_POINT, AttributeInitConstruct());
this->runtime = MEM_new<CurvesGeometryRuntime>(__func__);

View File

@ -105,7 +105,7 @@ bool CustomData_MeshMasks_are_matching(const CustomData_MeshMasks *mask_ref,
/** \} */
/* -------------------------------------------------------------------- */
/** \name Layer Type Information
/** \name Layer Type Information Struct
* \{ */
struct LayerTypeInfo {
@ -1557,6 +1557,10 @@ static void layerDefault_propquaternion(void *data, const int count)
/** \} */
/* -------------------------------------------------------------------- */
/** \name Layer Type Information (#LAYERTYPEINFO)
* \{ */
static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
/* 0: CD_MVERT */ /* DEPRECATED */
{sizeof(MVert), "MVert", 1, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr},

View File

@ -28,12 +28,12 @@
#include "MEM_guardedalloc.h"
namespace blender::bke {
/* -------------------------------------------------------------------- */
/** \name Geometry Component
* \{ */
namespace blender::bke {
GeometryComponent::GeometryComponent(Type type) : type_(type) {}
GeometryComponentPtr GeometryComponent::create(Type component_type)
@ -717,6 +717,6 @@ bool object_has_geometry_set_instances(const Object &object)
return false;
}
} // namespace blender::bke
/** \} */
} // namespace blender::bke

View File

@ -466,7 +466,7 @@ void BKE_idtype_id_foreach_cache(ID *id,
type_info = BKE_idtype_get_info_from_id(&nodetree->id);
if (type_info == NULL) {
/* Very old .blend file seem to have empty names for their embedded node trees, see
* `blo_do_versions_250()`. Assume those are nodetrees then. */
* `blo_do_versions_250()`. Assume those are node-trees then. */
type_info = BKE_idtype_get_info_from_idcode(ID_NT);
}
if (type_info->foreach_cache != NULL) {

View File

@ -593,7 +593,7 @@ static int id_copy_libmanagement_cb(LibraryIDLinkCallbackData *cb_data)
/* Remap self-references to new copied ID. */
if (id == data->id_src) {
/* We cannot use self_id here, it is not *always* id_dst (thanks to $£!+@#&/? nodetrees). */
/* We cannot use self_id here, it is not *always* id_dst (thanks to confounded node-trees!). */
id = *id_pointer = data->id_dst;
}
@ -713,15 +713,15 @@ ID *BKE_id_copy_for_duplicate(Main *bmain,
ID_NEW_SET(key, key_new);
}
/* NOTE: embedded data (root nodetrees and master collections) should never be referenced by
/* NOTE: embedded data (root node-trees and master collections) should never be referenced by
* anything else, so we do not need to set their newid pointer and flag. */
BKE_animdata_duplicate_id_action(bmain, id_new, duplicate_flags);
if (key_new != NULL) {
BKE_animdata_duplicate_id_action(bmain, key_new, duplicate_flags);
}
/* Note that actions of embedded data (root nodetrees and master collections) are handled
* by `BKE_animdata_duplicate_id_action` as well. */
/* Note that actions of embedded data (root node-trees and master collections) are handled
* by #BKE_animdata_duplicate_id_action as well. */
}
return id->newid;
}
@ -1436,7 +1436,7 @@ void BKE_libblock_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int ori
/* the duplicate should get a copy of the animdata */
if ((flag & LIB_ID_COPY_NO_ANIMDATA) == 0) {
/* Note that even though horrors like root nodetrees are not in bmain, the actions they use
/* Note that even though horrors like root node-trees are not in bmain, the actions they use
* in their anim data *are* in bmain... super-mega-hooray. */
BLI_assert((copy_data_flag & LIB_ID_COPY_ACTIONS) == 0 ||
(copy_data_flag & LIB_ID_CREATE_NO_MAIN) == 0);
@ -1837,7 +1837,7 @@ void BKE_library_make_local(Main *bmain,
BLI_linklist_prepend_arena(&todo_ids, id, linklist_mem);
id->tag |= LIB_TAG_DOIT;
/* Tag those nasty non-ID nodetrees,
/* Tag those nasty non-ID node-trees,
* but do not add them to todo list, making them local is handled by 'owner' ID.
* This is needed for library_make_local_copying_check() to work OK at step 2. */
if (ntree != NULL) {

View File

@ -160,7 +160,7 @@ static void material_free_data(ID *id)
static void material_foreach_id(ID *id, LibraryForeachIDData *data)
{
Material *material = (Material *)id;
/* Nodetrees **are owned by IDs**, treat them as mere sub-data and not real ID! */
/* Node-trees **are owned by IDs**, treat them as mere sub-data and not real ID! */
BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(
data, BKE_library_foreach_ID_embedded(data, (ID **)&material->nodetree));
if (material->texpaintslot != nullptr) {

View File

@ -205,10 +205,8 @@ void BKE_mesh_calc_edges(Mesh *mesh, bool keep_existing_edges, const bool select
}
/* Create new edges. */
if (!CustomData_has_layer_named(&mesh->ldata, CD_PROP_INT32, ".corner_edge")) {
CustomData_add_layer_named(
&mesh->ldata, CD_PROP_INT32, CD_CONSTRUCT, mesh->totloop, ".corner_edge");
}
MutableAttributeAccessor attributes = mesh->attributes_for_write();
attributes.add<int>(".corner_edge", ATTR_DOMAIN_CORNER, AttributeInitConstruct());
MutableSpan<int2> new_edges{
static_cast<int2 *>(MEM_calloc_arrayN(new_totedge, sizeof(int2), __func__)), new_totedge};
calc_edges::serialize_and_initialize_deduplicated_edges(edge_maps, new_edges);
@ -221,9 +219,8 @@ void BKE_mesh_calc_edges(Mesh *mesh, bool keep_existing_edges, const bool select
/* Free old CustomData and assign new one. */
CustomData_free(&mesh->edata, mesh->totedge);
CustomData_reset(&mesh->edata);
CustomData_add_layer_named_with_data(
&mesh->edata, CD_PROP_INT32_2D, new_edges.data(), new_totedge, ".edge_verts", nullptr);
mesh->totedge = new_totedge;
attributes.add<int2>(".edge_verts", ATTR_DOMAIN_EDGE, AttributeInitMoveArray(new_edges.data()));
if (select_new_edges) {
MutableAttributeAccessor attributes = mesh->attributes_for_write();

View File

@ -69,6 +69,7 @@ static CLG_LogRef LOG = {"bke.mesh_convert"};
static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispbase)
{
using namespace blender;
using namespace blender::bke;
int a, b, ofs;
const bool conv_polys = (
@ -127,9 +128,9 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba
"material_index", ATTR_DOMAIN_FACE);
SpanAttributeWriter<bool> sharp_faces = attributes.lookup_or_add_for_write_span<bool>(
"sharp_face", ATTR_DOMAIN_FACE);
blender::float2 *mloopuv = static_cast<blender::float2 *>(CustomData_add_layer_named(
&mesh->ldata, CD_PROP_FLOAT2, CD_SET_DEFAULT, mesh->totloop, DATA_("UVMap")));
SpanAttributeWriter<float2> uv_attribute = attributes.lookup_or_add_for_write_span<float2>(
DATA_("UVMap"), ATTR_DOMAIN_CORNER);
MutableSpan<float2> uv_map = uv_attribute.span;
int dst_vert = 0;
int dst_edge = 0;
@ -203,11 +204,9 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba
poly_offsets[dst_poly] = dst_loop;
material_indices.span[dst_poly] = dl->col;
if (mloopuv) {
for (int i = 0; i < 3; i++, mloopuv++) {
(*mloopuv)[0] = (corner_verts[dst_loop + i] - startvert) / float(dl->nr - 1);
(*mloopuv)[1] = 0.0f;
}
for (int i = 0; i < 3; i++) {
uv_map[dst_loop + i][0] = (corner_verts[dst_loop + i] - startvert) / float(dl->nr - 1);
uv_map[dst_loop + i][1] = 0.0f;
}
sharp_faces.span[dst_poly] = !is_smooth;
@ -260,35 +259,33 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba
poly_offsets[dst_poly] = dst_loop;
material_indices.span[dst_poly] = dl->col;
if (mloopuv) {
int orco_sizeu = dl->nr - 1;
int orco_sizev = dl->parts - 1;
int orco_sizeu = dl->nr - 1;
int orco_sizev = dl->parts - 1;
/* exception as handled in convertblender.c too */
if (dl->flag & DL_CYCL_U) {
orco_sizeu++;
if (dl->flag & DL_CYCL_V) {
orco_sizev++;
}
}
else if (dl->flag & DL_CYCL_V) {
/* exception as handled in convertblender.c too */
if (dl->flag & DL_CYCL_U) {
orco_sizeu++;
if (dl->flag & DL_CYCL_V) {
orco_sizev++;
}
}
else if (dl->flag & DL_CYCL_V) {
orco_sizev++;
}
for (int i = 0; i < 4; i++, mloopuv++) {
/* find uv based on vertex index into grid array */
int v = corner_verts[dst_loop + i] - startvert;
for (int i = 0; i < 4; i++) {
/* find uv based on vertex index into grid array */
int v = corner_verts[dst_loop + i] - startvert;
(*mloopuv)[0] = (v / dl->nr) / float(orco_sizev);
(*mloopuv)[1] = (v % dl->nr) / float(orco_sizeu);
uv_map[dst_loop + i][0] = (v / dl->nr) / float(orco_sizev);
uv_map[dst_loop + i][1] = (v % dl->nr) / float(orco_sizeu);
/* cyclic correction */
if (ELEM(i, 1, 2) && (*mloopuv)[0] == 0.0f) {
(*mloopuv)[0] = 1.0f;
}
if (ELEM(i, 0, 1) && (*mloopuv)[1] == 0.0f) {
(*mloopuv)[1] = 1.0f;
}
/* cyclic correction */
if (ELEM(i, 1, 2) && uv_map[dst_loop + i][0] == 0.0f) {
uv_map[dst_loop + i][0] = 1.0f;
}
if (ELEM(i, 0, 1) && uv_map[dst_loop + i][1] == 0.0f) {
uv_map[dst_loop + i][1] = 1.0f;
}
}
@ -311,6 +308,7 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba
material_indices.finish();
sharp_faces.finish();
uv_attribute.finish();
return mesh;
}

View File

@ -481,7 +481,7 @@ NlaStrip *BKE_nlastrip_new(bAction *act)
/* determine initial range
* - strip length cannot be 0... ever...
*/
BKE_action_get_frame_range(strip->act, &strip->actstart, &strip->actend);
BKE_action_frame_range_get(strip->act, &strip->actstart, &strip->actend);
strip->start = strip->actstart;
strip->end = IS_EQF(strip->actstart, strip->actend) ? (strip->actstart + 1.0f) : strip->actend;
@ -1580,7 +1580,7 @@ void BKE_nlastrip_recalculate_bounds_sync_action(NlaStrip *strip)
prev_actstart = strip->actstart;
BKE_action_get_frame_range(strip->act, &strip->actstart, &strip->actend);
BKE_action_frame_range_get(strip->act, &strip->actstart, &strip->actend);
/* Set start such that key's do not visually move, to preserve the overall animation result. */
strip->start += (strip->actstart - prev_actstart) * strip->scale;
@ -2113,7 +2113,7 @@ void BKE_nla_action_pushdown(AnimData *adt, const bool is_liboverride)
* as that will cause us grief down the track
*/
/* TODO: what about modifiers? */
if (action_has_motion(adt->action) == 0) {
if (BKE_action_has_motion(adt->action) == 0) {
CLOG_ERROR(&LOG, "action has no data");
return;
}

View File

@ -64,11 +64,8 @@ static void pointcloud_init_data(ID *id)
MEMCPY_STRUCT_AFTER(pointcloud, DNA_struct_default_get(PointCloud), id);
CustomData_reset(&pointcloud->pdata);
CustomData_add_layer_named(&pointcloud->pdata,
CD_PROP_FLOAT3,
CD_CONSTRUCT,
pointcloud->totpoint,
POINTCLOUD_ATTR_POSITION);
pointcloud->attributes_for_write().add<float3>(
"position", ATTR_DOMAIN_POINT, blender::bke::AttributeInitConstruct());
pointcloud->runtime = new blender::bke::PointCloudRuntime();
}

View File

@ -749,8 +749,6 @@ typedef struct VFontCursor_Params {
int r_string_offset;
} VFontCursor_Params;
/** \} */
enum {
VFONT_TO_CURVE_INIT = 0,
VFONT_TO_CURVE_BISECT,

View File

@ -122,6 +122,8 @@ size_t BLI_strncpy_rlen(char *__restrict dst, const char *__restrict src, const
return srclen;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name String Append
* \{ */

View File

@ -1063,7 +1063,7 @@ template<typename T> void twoface2_test()
EXPECT_EQ(out.edge.size(), 18);
EXPECT_EQ(out.face.size(), 9);
if (out.vert.size() == 10 && out.edge.size() == 18 && out.face.size() == 9) {
/* Input verts have no dups, so expect output ones match input ones. */
/* Input verts have no duplicates, so expect output ones match input ones. */
for (int i = 0; i < 6; i++) {
EXPECT_EQ(get_orig_index(out.vert_orig, i), i);
}

View File

@ -1754,7 +1754,7 @@ if (!MAIN_VERSION_ATLEAST(bmain, 266, 3)) {
{
/* Fix for a very old issue:
* Node names were nominally made unique in r24478 (2.50.8), but the do_versions check
* to update existing node names only applied to bmain->nodetree (i.e. group nodes).
* to update existing node names only applied to `bmain->nodetree` (i.e. group nodes).
* Uniqueness is now required for proper preview mapping,
* so do this now to ensure old files don't break.
*/

View File

@ -45,7 +45,7 @@ void eval_runtime_data(const ::Depsgraph *depsgraph, Object &object_eval)
} // namespace blender::deg::light_linking
/* \} */
/** \} */
/* -------------------------------------------------------------------- */
/** \name Internal builder API
@ -504,4 +504,4 @@ void Cache::eval_runtime_data(Object &object_eval) const
} // namespace blender::deg::light_linking
/* \} */
/** \} */

View File

@ -68,7 +68,7 @@ const char *nodeTypeAsString(NodeType type)
return "OBJECT_FROM_LAYER";
case NodeType::HIERARCHY:
return "HIERARCHY";
/* **** Evaluation-Related Outer Types (with Subdata) **** */
/* **** Evaluation-Related Outer Types (with Sub-data) **** */
case NodeType::EVAL_POSE:
return "EVAL_POSE";
case NodeType::BONE:

View File

@ -103,7 +103,7 @@ enum class NodeType {
* properly evaluated. Example of this is custom shapes for bones. */
VISIBILITY,
/* **** Evaluation-Related Outer Types (with Subdata) **** */
/* **** Evaluation-Related Outer Types (with Sub-data) **** */
/* Pose Component - Owner/Container of Bones Eval */
EVAL_POSE,

View File

@ -134,7 +134,7 @@ class ReflectionProbeModule {
/**
* Remove reflection probe data from the module.
* Ensures that data_buf is sequential and cubemaps are relinked to its corresponding data.
* Ensures that data_buf is sequential and cube-maps are relinked to its corresponding data.
*/
void remove_reflection_probe_data(int reflection_probe_data_index);

View File

@ -20,9 +20,9 @@ class Instance;
/* -------------------------------------------------------------------- */
/** \name Default World Node-Tree
*
* In order to support worlds without nodetree we reuse and configure a standalone nodetree that
* In order to support worlds without node-tree we reuse and configure a standalone node-tree that
* we pass for shader generation. The GPUMaterial is still stored inside the World even if
* it does not use a nodetree.
* it does not use a node-tree.
* \{ */
class DefaultWorldNodeTree {

View File

@ -41,9 +41,9 @@ void main()
velocity_local_pos_get(pos, vert_idx, prv, nxt);
/* FIXME(fclem): Evaluating before displacement avoid displacement being treated as motion but
* ignores motion from animated displacement. Supporting animated displacement motion vectors
* would require evaluating the nodetree multiple time with different nodetree UBOs evaluated at
* different times, but also with different attributes (maybe we could assume static attribute at
* least). */
* would require evaluating the node-tree multiple time with different node-tree UBOs evaluated
* at different times, but also with different attributes (maybe we could assume static attribute
* at least). */
velocity_vertex(prv, pos, nxt, motion.prev, motion.next);
#endif

View File

@ -38,9 +38,9 @@ void main()
vec3 lP_curr = transform_point(ModelMatrixInverse, interp.P);
/* FIXME(fclem): Evaluating before displacement avoid displacement being treated as motion but
* ignores motion from animated displacement. Supporting animated displacement motion vectors
* would require evaluating the nodetree multiple time with different nodetree UBOs evaluated at
* different times, but also with different attributes (maybe we could assume static attribute at
* least). */
* would require evaluating the node-tree multiple time with different node-tree UBOs evaluated
* at different times, but also with different attributes (maybe we could assume static attribute
* at least). */
velocity_vertex(lP_curr, lP_curr, lP_curr, motion.prev, motion.next);
#endif

View File

@ -80,9 +80,9 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
* which isn't so clear with option 2.
*/
/* For structname:
/* For struct-name:
* - As base, we use a custom name from the structs if one is available
* - However, if we're showing subdata of bones
* - However, if we're showing sub-data of bones
* (probably there will be other exceptions later).
* need to include that info too since it gets confusing otherwise.
* - If a pointer just refers to the ID-block, then don't repeat this info

View File

@ -361,7 +361,7 @@ TimeMarker *ED_markers_get_first_selected(ListBase *markers)
void debug_markers_print_list(ListBase *markers)
{
/* NOTE: do NOT make static or put in if-defs as "unused code".
/* NOTE: do NOT make static or use `ifdef`'s as "unused code".
* That's too much trouble when we need to use for quick debugging! */
TimeMarker *marker;
@ -780,7 +780,7 @@ static void MARKER_OT_add(wmOperatorType *ot)
* \{ */
/* operator state vars used:
* frs: delta movement
* frames: delta movement
*
* functions:
*
@ -957,7 +957,7 @@ static int ed_marker_move_invoke(bContext *C, wmOperator *op, const wmEvent *eve
/* add temp handler */
WM_event_add_modal_handler(C, op);
/* reset frs delta */
/* Reset frames delta. */
RNA_int_set(op->ptr, "frames", 0);
ed_marker_move_update_header(C, op);
@ -1144,7 +1144,7 @@ static void MARKER_OT_move(wmOperatorType *ot)
* \{ */
/* operator state vars used:
* frs: delta movement
* frames: delta movement
*
* functions:
*
@ -1201,7 +1201,7 @@ static void ed_marker_duplicate_apply(bContext *C)
static int ed_marker_duplicate_exec(bContext *C, wmOperator *op)
{
ed_marker_duplicate_apply(C);
ed_marker_move_exec(C, op); /* assumes frs delta set */
ed_marker_move_exec(C, op); /* Assumes frame delta set. */
return OPERATOR_FINISHED;
}

View File

@ -1054,7 +1054,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op)
ebone->bbone_next = ebone_iter->bbone_next->temp.ebone;
}
/* Lets try to fix any constraint subtargets that might have been duplicated. */
/* Lets try to fix any constraint sub-targets that might have been duplicated. */
updateDuplicateSubtarget(ebone, arm->edbo, ob, false);
}
}

View File

@ -236,8 +236,9 @@ static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEven
return WM_operator_props_dialog_popup(C, op, 270);
}
/* For the object with pose/action: create path curves for selected bones
* This recalculates the WHOLE path within the pchan->pathsf and pchan->pathef range
/**
* For the object with pose/action: create path curves for selected bones
* This recalculates the WHOLE path within the `pchan->pathsf` and `pchan->pathef` range.
*/
static int pose_calculate_paths_exec(bContext *C, wmOperator *op)
{
@ -272,7 +273,7 @@ static int pose_calculate_paths_exec(bContext *C, wmOperator *op)
TIMEIT_START(recalc_pose_paths);
#endif
/* Calculate the bones that now have motionpaths. */
/* Calculate the bones that now have motion-paths. */
/* TODO: only make for the selected bones? */
ED_pose_recalculate_paths(C, scene, ob, POSE_PATH_CALC_RANGE_FULL);

View File

@ -56,7 +56,8 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks,
bPoseChannel *pchan)
{
ListBase curves = {nullptr, nullptr};
int transFlags = action_get_item_transforms(act, ob, pchan, &curves);
const eAction_TransformFlags transFlags = BKE_action_get_item_transform_flags(
act, ob, pchan, &curves);
pchan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE | POSE_BBONE_SHAPE);

View File

@ -41,6 +41,8 @@ void ED_keymap_grease_pencil(struct wmKeyConfig *keyconf);
*/
eAttrDomain ED_grease_pencil_selection_domain_get(struct bContext *C);
/** \} */
#ifdef __cplusplus
}
#endif

View File

@ -75,7 +75,7 @@ static void make_prim_finish(bContext *C,
* to push this up to edges & faces. */
EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX);
/* only recalc editmode tessface if we are staying in editmode */
/* Only recalculate edit-mode tessellation if we are staying in edit-mode. */
EDBMUpdate_Params params{};
params.calc_looptri = !exit_editmode;
params.calc_normals = false;

View File

@ -374,8 +374,8 @@ static bool edbm_bevel_calc(wmOperator *op)
BMO_op_exec(em->bm, &bmop);
if (offset != 0.0f) {
/* not essential, but we may have some loose geometry that
* won't get bevel'd and better not leave it selected */
/* Not essential, but we may have some loose geometry that
* won't get beveled and better not leave it selected. */
EDBM_flag_disable_all(em, BM_ELEM_SELECT);
BMO_slot_buffer_hflag_enable(
em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true);

View File

@ -354,7 +354,7 @@ void MESH_OT_extrude_repeat(wmOperatorType *ot)
/** \name Extrude Operator
* \{ */
/* generic extern called extruder */
/** Implement generic externally called extrude function. */
static bool edbm_extrude_mesh(Object *obedit, BMEditMesh *em, wmOperator *op)
{
const bool use_normal_flip = RNA_boolean_get(op->ptr, "use_normal_flip");

View File

@ -195,7 +195,7 @@ static void ringsel_finish(bContext *C, wmOperator *op)
use_only_quads,
0);
/* when used in a macro the tessfaces will be recalculated anyway,
/* When used in a macro the tessellation will be recalculated anyway,
* this is needed here because modifiers depend on updated tessellation, see #45920 */
EDBMUpdate_Params params{};
params.calc_looptri = true;

View File

@ -35,6 +35,10 @@
#include "mesh_intern.h" /* own include */
/* -------------------------------------------------------------------- */
/** \name Local Utilities
* \{ */
/**
* helper to find edge for edge_rip,
*
@ -147,10 +151,14 @@ static float edbm_rip_edge_side_measure(
return -score;
}
/* - Advanced selection handling 'ripsel' functions ----- */
/** \} */
/* -------------------------------------------------------------------- */
/** \name Rip Selection Handling (advanced rip-select `ripsel` functions)
* \{ */
/**
* How rip selection works
* How rip selection works:
*
* Firstly - rip is basically edge split with side-selection & grab.
* Things would be much more simple if we didn't have to worry about side selection
@ -308,7 +316,11 @@ printf("%s: found contiguous edge loop of (%d)\n", __func__, uid_end - uid_start
return eloop_pairs;
}
/* - De-Select the worst rip-edge side -------------------------------- */
/** \} */
/* -------------------------------------------------------------------- */
/** \name Rip Far-Side De-Select
* \{ */
static BMEdge *edbm_ripsel_edge_uid_step(BMEdge *e_orig, BMVert **v_prev)
{
@ -366,9 +378,13 @@ static void edbm_ripsel_deselect_helper(BMesh *bm,
}
}
}
/* --- end 'ripsel' selection handling code --- */
/* --- face-fill code --- */
/** \} */
/* -------------------------------------------------------------------- */
/** \name Rip Face-Fill code
* \{ */
/**
* return an un-ordered array of loop pairs
* use for rebuilding face-fill
@ -496,7 +512,11 @@ static void edbm_tagged_loop_pairs_do_fill_faces(BMesh *bm, UnorderedLoopPair *u
}
}
/* --- end 'face-fill' code --- */
/** \} */
/* -------------------------------------------------------------------- */
/** \name Rip Vertex Implementation
* \{ */
/**
* This is the main vert ripping function (rip when one vertex is selected)
@ -857,6 +877,12 @@ static int edbm_rip_invoke__vert(bContext *C, const wmEvent *event, Object *obed
return OPERATOR_FINISHED;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Rip Edge Implementation
* \{ */
/**
* This is the main edge ripping function
*/
@ -989,6 +1015,12 @@ static int edbm_rip_invoke__edge(bContext *C, const wmEvent *event, Object *obed
return OPERATOR_FINISHED;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Rip Operator
* \{ */
/* based on mouse cursor position, it defines how is being ripped */
static int edbm_rip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
@ -1122,3 +1154,5 @@ void MESH_OT_rip(wmOperatorType *ot)
prop = RNA_def_boolean(ot->srna, "use_fill", false, "Fill", "Fill the ripped region");
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_MESH);
}
/** \} */

View File

@ -213,7 +213,7 @@ bool ED_scene_view_layer_delete(Main *bmain, Scene *scene, ViewLayer *layer, Rep
return false;
}
/* We need to unset nodetrees before removing the layer, otherwise its index will be -1. */
/* We need to unset node-trees before removing the layer, otherwise its index will be -1. */
view_layer_remove_unset_nodetrees(bmain, scene, layer);
BLI_remlink(&scene->view_layers, layer);

View File

@ -6925,18 +6925,6 @@ void PAINT_OT_add_texture_paint_slot(wmOperatorType *ot)
{0, nullptr, 0, nullptr, nullptr},
};
static const EnumPropertyItem domain_items[3] = {
{ATTR_DOMAIN_POINT, "POINT", 0, "Vertex", ""},
{ATTR_DOMAIN_CORNER, "CORNER", 0, "Face Corner", ""},
{0, nullptr, 0, nullptr, nullptr},
};
static const EnumPropertyItem attribute_type_items[3] = {
{CD_PROP_COLOR, "COLOR", 0, "Color", ""},
{CD_PROP_BYTE_COLOR, "BYTE_COLOR", 0, "Byte Color", ""},
{0, nullptr, 0, nullptr, nullptr},
};
/* identifiers */
ot->name = "Add Paint Slot";
ot->description = "Add a paint slot";
@ -6997,14 +6985,14 @@ void PAINT_OT_add_texture_paint_slot(wmOperatorType *ot)
/* Color Attribute Properties */
RNA_def_enum(ot->srna,
"domain",
domain_items,
rna_enum_color_attribute_domain_items,
ATTR_DOMAIN_POINT,
"Domain",
"Type of element that attribute is stored on");
RNA_def_enum(ot->srna,
"data_type",
attribute_type_items,
rna_enum_color_attribute_type_items,
CD_PROP_COLOR,
"Data Type",
"Type of data stored in attribute");

View File

@ -1840,8 +1840,7 @@ static void sculpt_undo_set_active_layer(bContext *C, SculptAttrRef *attr)
SculptAttrRef existing;
sculpt_save_active_attribute(ob, &existing);
CustomDataLayer *layer;
layer = BKE_id_attribute_find(&me->id, attr->name, attr->type, attr->domain);
CustomDataLayer *layer = BKE_id_attribute_find(&me->id, attr->name, attr->type, attr->domain);
/* Temporary fix for #97408. This is a fundamental
* bug in the undo stack; the operator code needs to push
@ -1864,11 +1863,8 @@ static void sculpt_undo_set_active_layer(bContext *C, SculptAttrRef *attr)
if (!layer) {
/* Memfile undo killed the layer; re-create it. */
CustomData *cdata = attr->domain == ATTR_DOMAIN_POINT ? &me->vdata : &me->ldata;
int totelem = attr->domain == ATTR_DOMAIN_POINT ? me->totvert : me->totloop;
CustomData_add_layer_named(
cdata, eCustomDataType(attr->type), CD_SET_DEFAULT, totelem, attr->name);
me->attributes_for_write().add(
attr->name, attr->domain, attr->type, blender::bke::AttributeInitDefaultValue());
layer = BKE_id_attribute_find(&me->id, attr->name, attr->type, attr->domain);
}

View File

@ -341,7 +341,7 @@ static int action_pushdown_exec(bContext *C, wmOperator *op)
if (adt) {
/* Perform the push-down operation
* - This will deal with all the AnimData-side user-counts. */
if (action_has_motion(adt->action) == 0) {
if (BKE_action_has_motion(adt->action) == 0) {
/* action may not be suitable... */
BKE_report(op->reports, RPT_WARNING, "Action must have at least one keyframe or F-Modifier");
return OPERATOR_CANCELLED;
@ -398,7 +398,7 @@ static int action_stash_exec(bContext *C, wmOperator *op)
/* Perform stashing operation */
if (adt) {
/* don't do anything if this action is empty... */
if (action_has_motion(adt->action) == 0) {
if (BKE_action_has_motion(adt->action) == 0) {
/* action may not be suitable... */
BKE_report(op->reports, RPT_WARNING, "Action must have at least one keyframe or F-Modifier");
return OPERATOR_CANCELLED;
@ -506,7 +506,7 @@ static int action_stash_create_exec(bContext *C, wmOperator *op)
}
else if (adt) {
/* Perform stashing operation */
if (action_has_motion(adt->action) == 0) {
if (BKE_action_has_motion(adt->action) == 0) {
/* don't do anything if this action is empty... */
BKE_report(op->reports, RPT_WARNING, "Action must have at least one keyframe or F-Modifier");
return OPERATOR_CANCELLED;

View File

@ -888,7 +888,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *region)
case NLASTRIP_EXTEND_HOLD_FORWARD: {
float r_start;
float r_end;
BKE_action_get_frame_range(static_cast<bAction *>(ale->data), &r_start, &r_end);
BKE_action_frame_range_get(static_cast<bAction *>(ale->data), &r_start, &r_end);
immRectf(pos, r_end, ymin + NLACHANNEL_SKIP, v2d->cur.xmax, ymax - NLACHANNEL_SKIP);
break;

View File

@ -1199,7 +1199,7 @@ void animrecord_check_state(TransInfo *t, ID *id)
float astart, aend;
/* only push down if action is more than 1-2 frames long */
calc_action_range(adt->action, &astart, &aend, 1);
BKE_action_frame_range_calc(adt->action, true, &astart, &aend);
if (aend > astart + 2.0f) {
NlaStrip *strip = BKE_nlastack_add_strip(adt, adt->action, ID_IS_OVERRIDE_LIBRARY(id));

View File

@ -389,6 +389,8 @@ static bool raycastEditMesh(SnapCache_EditMesh *em_cache,
return retval;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Surface Snap Functions
* \{ */

View File

@ -372,7 +372,7 @@ static void slider_draw(const bContext *UNUSED(C), ARegion *region, void *arg)
static void slider_update_factor(tSlider *slider, const wmEvent *event)
{
/* Normalize so no matter the factor bounds, the mouse distance travelled from min to max is
/* Normalize so no matter the factor bounds, the mouse distance traveled from min to max is
* constant. */
const float slider_range = slider->factor_bounds[1] - slider->factor_bounds[0];
const float factor_delta = (event->xy[0] - slider->last_cursor[0]) /

View File

@ -49,12 +49,8 @@ struct CDStreamConfig {
Mesh *mesh;
void *(*add_customdata_cb)(Mesh *mesh, const char *name, int data_type);
double weight;
Alembic::Abc::chrono_t time;
int timesample_index;
bool use_vertex_interpolation;
Alembic::AbcGeom::index_t index;
Alembic::AbcGeom::index_t ceil_index;
const char **modifier_error_message;
@ -80,10 +76,7 @@ struct CDStreamConfig {
pack_uvs(false),
mesh(NULL),
add_customdata_cb(NULL),
weight(0.0),
time(0.0),
index(0),
ceil_index(0),
modifier_error_message(NULL)
{
}

View File

@ -118,6 +118,9 @@ struct AbcMeshData {
Int32ArraySamplePtr face_indices;
Int32ArraySamplePtr face_counts;
/* Optional settings for reading interpolated vertices. If present, `ceil_positions` has to be
* valid. */
std::optional<SampleInterpolationSettings> interpolation_settings;
P3fArraySamplePtr positions;
P3fArraySamplePtr ceil_positions;
@ -146,10 +149,13 @@ static void read_mverts(CDStreamConfig &config, const AbcMeshData &mesh_data)
float3 *vert_positions = config.positions;
const P3fArraySamplePtr &positions = mesh_data.positions;
if (config.use_vertex_interpolation && config.weight != 0.0f &&
mesh_data.ceil_positions != nullptr && mesh_data.ceil_positions->size() == positions->size())
{
read_mverts_interp(vert_positions, positions, mesh_data.ceil_positions, config.weight);
if (mesh_data.interpolation_settings.has_value()) {
BLI_assert_msg(
mesh_data.ceil_positions != nullptr,
"AbcMeshData does not have ceil positions although it has some interpolation settings.");
const double weight = mesh_data.interpolation_settings->weight;
read_mverts_interp(vert_positions, positions, mesh_data.ceil_positions, weight);
BKE_mesh_tag_positions_changed(config.mesh);
return;
}
@ -398,18 +404,6 @@ static void *add_customdata_cb(Mesh *mesh, const char *name, int data_type)
return cd_ptr;
}
static void get_weight_and_index(CDStreamConfig &config,
Alembic::AbcCoreAbstract::TimeSamplingPtr time_sampling,
size_t samples_number)
{
Alembic::AbcGeom::index_t i0, i1;
config.weight = get_weight_and_index(config.time, time_sampling, samples_number, i0, i1);
config.index = i0;
config.ceil_index = i1;
}
static V3fArraySamplePtr get_velocity_prop(const ICompoundProperty &schema,
const ISampleSelector &selector,
const std::string &name)
@ -513,14 +507,18 @@ static void read_mesh_sample(const std::string &iobject_full_name,
abc_mesh_data.face_indices = sample.getFaceIndices();
abc_mesh_data.positions = sample.getPositions();
get_weight_and_index(config, schema.getTimeSampling(), schema.getNumSamples());
const std::optional<SampleInterpolationSettings> interpolation_settings =
get_sample_interpolation_settings(
selector, schema.getTimeSampling(), schema.getNumSamples());
if (config.weight != 0.0f) {
const bool use_vertex_interpolation = settings->read_flag & MOD_MESHSEQ_INTERPOLATE_VERTICES;
if (use_vertex_interpolation && interpolation_settings.has_value()) {
Alembic::AbcGeom::IPolyMeshSchema::Sample ceil_sample;
schema.get(ceil_sample, Alembic::Abc::ISampleSelector(config.ceil_index));
schema.get(ceil_sample, Alembic::Abc::ISampleSelector(interpolation_settings->ceil_index));
if (samples_have_same_topology(sample, ceil_sample)) {
/* Only set interpolation data if the samples are compatible. */
abc_mesh_data.ceil_positions = ceil_sample.getPositions();
abc_mesh_data.interpolation_settings = interpolation_settings;
}
}
@ -550,7 +548,7 @@ static void read_mesh_sample(const std::string &iobject_full_name,
}
}
CDStreamConfig get_config(Mesh *mesh, const bool use_vertex_interpolation)
CDStreamConfig get_config(Mesh *mesh)
{
CDStreamConfig config;
config.mesh = mesh;
@ -562,7 +560,6 @@ CDStreamConfig get_config(Mesh *mesh, const bool use_vertex_interpolation)
config.totpoly = mesh->totpoly;
config.loopdata = &mesh->ldata;
config.add_customdata_cb = add_customdata_cb;
config.use_vertex_interpolation = use_vertex_interpolation;
return config;
}
@ -823,8 +820,7 @@ Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh,
}
Mesh *mesh_to_export = new_mesh ? new_mesh : existing_mesh;
const bool use_vertex_interpolation = read_flag & MOD_MESHSEQ_INTERPOLATE_VERTICES;
CDStreamConfig config = get_config(mesh_to_export, use_vertex_interpolation);
CDStreamConfig config = get_config(mesh_to_export);
config.time = sample_sel.getRequestedTime();
config.modifier_error_message = err_str;
@ -921,14 +917,18 @@ static void read_subd_sample(const std::string &iobject_full_name,
abc_mesh_data.face_indices = sample.getFaceIndices();
abc_mesh_data.positions = sample.getPositions();
get_weight_and_index(config, schema.getTimeSampling(), schema.getNumSamples());
const std::optional<SampleInterpolationSettings> interpolation_settings =
get_sample_interpolation_settings(
selector, schema.getTimeSampling(), schema.getNumSamples());
if (config.weight != 0.0f) {
const bool use_vertex_interpolation = settings->read_flag & MOD_MESHSEQ_INTERPOLATE_VERTICES;
if (use_vertex_interpolation && interpolation_settings.has_value()) {
Alembic::AbcGeom::ISubDSchema::Sample ceil_sample;
schema.get(ceil_sample, Alembic::Abc::ISampleSelector(config.ceil_index));
schema.get(ceil_sample, Alembic::Abc::ISampleSelector(interpolation_settings->ceil_index));
if (samples_have_same_topology(sample, ceil_sample)) {
/* Only set interpolation data if the samples are compatible. */
abc_mesh_data.ceil_positions = ceil_sample.getPositions();
abc_mesh_data.interpolation_settings = interpolation_settings;
}
}
@ -1161,8 +1161,7 @@ Mesh *AbcSubDReader::read_mesh(Mesh *existing_mesh,
/* Only read point data when streaming meshes, unless we need to create new ones. */
Mesh *mesh_to_export = new_mesh ? new_mesh : existing_mesh;
const bool use_vertex_interpolation = read_flag & MOD_MESHSEQ_INTERPOLATE_VERTICES;
CDStreamConfig config = get_config(mesh_to_export, use_vertex_interpolation);
CDStreamConfig config = get_config(mesh_to_export);
config.time = sample_sel.getRequestedTime();
config.modifier_error_message = err_str;
read_subd_sample(m_iobject.getFullName(), &settings, m_schema, sample_sel, config);

View File

@ -70,6 +70,6 @@ void read_mverts(Mesh &mesh,
const Alembic::AbcGeom::P3fArraySamplePtr positions,
const Alembic::AbcGeom::N3fArraySamplePtr normals);
CDStreamConfig get_config(struct Mesh *mesh, bool use_vertex_interpolation);
CDStreamConfig get_config(struct Mesh *mesh);
} // namespace blender::io::alembic

View File

@ -119,20 +119,23 @@ static Imath::M44d blend_matrices(const Imath::M44d &m0,
Imath::M44d get_matrix(const IXformSchema &schema, const chrono_t time)
{
Alembic::AbcGeom::index_t i0, i1;
Alembic::AbcGeom::XformSample s0, s1;
Alembic::AbcGeom::ISampleSelector selector(time);
const double weight = get_weight_and_index(
time, schema.getTimeSampling(), schema.getNumSamples(), i0, i1);
const std::optional<SampleInterpolationSettings> interpolation_settings =
get_sample_interpolation_settings(
selector, schema.getTimeSampling(), schema.getNumSamples());
schema.get(s0, Alembic::AbcGeom::ISampleSelector(i0));
if (i0 != i1) {
schema.get(s1, Alembic::AbcGeom::ISampleSelector(i1));
return blend_matrices(s0.getMatrix(), s1.getMatrix(), weight);
if (!interpolation_settings.has_value()) {
/* No interpolation, just read the current time. */
Alembic::AbcGeom::XformSample s0;
schema.get(s0, selector);
return s0.getMatrix();
}
return s0.getMatrix();
Alembic::AbcGeom::XformSample s0, s1;
schema.get(s0, Alembic::AbcGeom::ISampleSelector(interpolation_settings->index));
schema.get(s1, Alembic::AbcGeom::ISampleSelector(interpolation_settings->ceil_index));
return blend_matrices(s0.getMatrix(), s1.getMatrix(), interpolation_settings->weight);
}
Mesh *AbcObjectReader::read_mesh(Mesh *existing_mesh,

View File

@ -113,7 +113,7 @@ void read_points_sample(const IPointsSchema &schema,
Mesh *AbcPointsReader::read_mesh(Mesh *existing_mesh,
const ISampleSelector &sample_sel,
int read_flag,
int /*read_flag*/,
const char * /*velocity_name*/,
const float /*velocity_scale*/,
const char **err_str)
@ -141,8 +141,7 @@ Mesh *AbcPointsReader::read_mesh(Mesh *existing_mesh,
}
Mesh *mesh_to_export = new_mesh ? new_mesh : existing_mesh;
const bool use_vertex_interpolation = read_flag & MOD_MESHSEQ_INTERPOLATE_VERTICES;
CDStreamConfig config = get_config(mesh_to_export, use_vertex_interpolation);
CDStreamConfig config = get_config(mesh_to_export);
read_points_sample(m_schema, sample_sel, config);
return mesh_to_export;

View File

@ -116,36 +116,35 @@ bool has_property(const Alembic::Abc::ICompoundProperty &prop, const std::string
using index_time_pair_t = std::pair<Alembic::AbcCoreAbstract::index_t, Alembic::AbcGeom::chrono_t>;
double get_weight_and_index(Alembic::AbcGeom::chrono_t time,
const Alembic::AbcCoreAbstract::TimeSamplingPtr &time_sampling,
int samples_number,
Alembic::AbcGeom::index_t &i0,
Alembic::AbcGeom::index_t &i1)
std::optional<SampleInterpolationSettings> get_sample_interpolation_settings(
const Alembic::AbcGeom::ISampleSelector &selector,
const Alembic::AbcCoreAbstract::TimeSamplingPtr &time_sampling,
size_t samples_number)
{
samples_number = std::max(samples_number, 1);
const chrono_t time = selector.getRequestedTime();
samples_number = std::max(samples_number, size_t(1));
index_time_pair_t t0 = time_sampling->getFloorIndex(time, samples_number);
i0 = i1 = t0.first;
Alembic::AbcCoreAbstract::index_t i0 = t0.first;
if (samples_number == 1 || (fabs(time - t0.second) < 0.0001)) {
return 0.0;
return {};
}
index_time_pair_t t1 = time_sampling->getCeilIndex(time, samples_number);
i1 = t1.first;
Alembic::AbcCoreAbstract::index_t i1 = t1.first;
if (i0 == i1) {
return 0.0;
return {};
}
const double bias = (time - t0.second) / (t1.second - t0.second);
if (fabs(1.0 - bias) < 0.0001) {
i0 = i1;
return 0.0;
return {};
}
return bias;
return SampleInterpolationSettings{i0, i1, bias};
}
//#define USE_NURBS

View File

@ -10,6 +10,8 @@
#include <Alembic/Abc/All.h>
#include <Alembic/AbcGeom/All.h>
#include <optional>
using Alembic::Abc::chrono_t;
struct ID;
@ -81,11 +83,27 @@ void get_min_max_time(const Alembic::AbcGeom::IObject &object,
bool has_property(const Alembic::Abc::ICompoundProperty &prop, const std::string &name);
double get_weight_and_index(Alembic::AbcCoreAbstract::chrono_t time,
const Alembic::AbcCoreAbstract::TimeSamplingPtr &time_sampling,
int samples_number,
Alembic::AbcGeom::index_t &i0,
Alembic::AbcGeom::index_t &i1);
/**
* The SampleInterpolationSettings struct holds information for interpolating data between two
* samples.
*/
struct SampleInterpolationSettings {
/* Index of the first ("floor") sample. */
Alembic::AbcGeom::index_t index;
/* Index of the second ("ceil") sample. */
Alembic::AbcGeom::index_t ceil_index;
/* Factor to interpolate between the `index` and `ceil_index`. */
double weight;
};
/** Check whether the requested time from the \a selector falls between two sampling time from the
* \a time_sampling. If so, returns a #SampleInterpolationSettings with the required data to
* interpolate. If not, returns nothing and we can assume that the requested time falls on a
* specific sampling time of \a time_sampling and no interpolation is necessary. */
std::optional<SampleInterpolationSettings> get_sample_interpolation_settings(
const Alembic::AbcGeom::ISampleSelector &selector,
const Alembic::AbcCoreAbstract::TimeSamplingPtr &time_sampling,
size_t samples_number);
AbcObjectReader *create_reader(const Alembic::AbcGeom::IObject &object, ImportSettings &settings);

View File

@ -25,6 +25,4 @@
/** \} */
/* clang-format off */
/** \} */
/* clang-format on */

View File

@ -242,7 +242,7 @@ static void rna_Action_active_pose_marker_index_range(
static void rna_Action_frame_range_get(PointerRNA *ptr, float *r_values)
{
BKE_action_get_frame_range((bAction *)ptr->owner_id, &r_values[0], &r_values[1]);
BKE_action_frame_range_get((bAction *)ptr->owner_id, &r_values[0], &r_values[1]);
}
static void rna_Action_frame_range_set(PointerRNA *ptr, const float *values)
@ -258,7 +258,7 @@ static void rna_Action_frame_range_set(PointerRNA *ptr, const float *values)
static void rna_Action_curve_frame_range_get(PointerRNA *ptr, float *values)
{ /* don't include modifiers because they too easily can have very large
* ranges: MINAFRAMEF to MAXFRAMEF. */
calc_action_range((bAction *)ptr->owner_id, values, values + 1, false);
BKE_action_frame_range_calc((bAction *)ptr->owner_id, false, values, values + 1);
}
static void rna_Action_use_frame_range_set(PointerRNA *ptr, bool value)
@ -268,7 +268,7 @@ static void rna_Action_use_frame_range_set(PointerRNA *ptr, bool value)
if (value) {
/* If the frame range is blank, initialize it by scanning F-Curves. */
if ((data->frame_start == data->frame_end) && (data->frame_start == 0)) {
calc_action_range(data, &data->frame_start, &data->frame_end, false);
BKE_action_frame_range_calc(data, false, &data->frame_start, &data->frame_end);
}
data->flag |= ACT_FRAME_RANGE;

View File

@ -3402,7 +3402,7 @@ static IDFilterEnumPropertyItem rna_enum_space_file_id_filter_categories[] = {
"category_shading",
ICON_MATERIAL_DATA,
"Shading",
"Show materials, nodetrees, textures and Freestyle's linestyles"},
"Show materials, node-trees, textures and Freestyle's line-styles"},
{FILTER_ID_IM | FILTER_ID_MC | FILTER_ID_MSK | FILTER_ID_SO,
"category_image",
ICON_IMAGE_DATA,

View File

@ -279,8 +279,8 @@ static void BMD_mesh_intersection(BMesh *bm,
BooleanModifierData *bmd = (BooleanModifierData *)md;
/* main bmesh intersection setup */
/* create tessface & intersect */
/* Main BMesh intersection setup. */
/* Create tessellation & intersect. */
const int looptris_tot = poly_to_tri_count(bm->totface, bm->totloop);
BMLoop *(*looptris)[3] = (BMLoop * (*)[3])
MEM_malloc_arrayN(looptris_tot, sizeof(*looptris), __func__);

View File

@ -22,6 +22,7 @@
#include "DNA_object_types.h"
#include "DNA_screen_types.h"
#include "BKE_attribute.hh"
#include "BKE_camera.h"
#include "BKE_context.h"
#include "BKE_lib_query.h"
@ -119,10 +120,8 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
/* Create a new layer if no UV Maps are available
* (e.g. if a preceding modifier could not preserve it). */
if (!CustomData_has_layer(&mesh->ldata, CD_PROP_FLOAT2)) {
CustomData_add_layer_named(
&mesh->ldata, CD_PROP_FLOAT2, CD_SET_DEFAULT, mesh->totloop, umd->uvlayer_name);
}
mesh->attributes_for_write().add<float2>(
umd->uvlayer_name, ATTR_DOMAIN_CORNER, bke::AttributeInitDefaultValue());
/* make sure we're using an existing layer */
CustomData_validate_layer_name(&mesh->ldata, CD_PROP_FLOAT2, umd->uvlayer_name, uvname);

View File

@ -714,7 +714,7 @@ static bool node_composit_poll_rlayers(const bNodeType * /*ntype*/,
Scene *scene;
/* XXX ugly: check if ntree is a local scene node tree.
* Render layers node can only be used in local scene->nodetree,
* Render layers node can only be used in local `scene->nodetree`,
* since it directly links to the scene.
*/
for (scene = (Scene *)G.main->scenes.first; scene; scene = (Scene *)scene->id.next) {

View File

@ -46,7 +46,7 @@ wmGesture *WM_gesture_new(wmWindow *window, const ARegion *region, const wmEvent
gesture->event_modifier = event->modifier;
gesture->event_keymodifier = event->keymodifier;
gesture->winrct = region->winrct;
gesture->user_data.use_free = true; /* Free if userdata is set. */
gesture->user_data.use_free = true; /* Free if user-data is set. */
gesture->modal_state = GESTURE_MODAL_NOP;
gesture->move = false;