Merge branch 'master' into refactor-mesh-position-generic

This commit is contained in:
Hans Goudey 2023-01-09 23:32:14 -05:00
commit a20055b894
60 changed files with 292 additions and 278 deletions

View File

@ -58,7 +58,7 @@ ccl_device_noinline void motion_triangle_shader_setup(KernelGlobals kg,
sd->P = motion_triangle_point_from_uv(kg, sd, isect_object, isect_prim, sd->u, sd->v, verts);
/* Compute face normal. */
float3 Ng;
if (sd->object_flag & SD_OBJECT_NEGATIVE_SCALE_APPLIED) {
if (object_negative_scale_applied(sd->object_flag)) {
Ng = normalize(cross(verts[2] - verts[0], verts[1] - verts[0]));
}
else {

View File

@ -201,6 +201,11 @@ ccl_device_inline void object_normal_transform(KernelGlobals kg,
*N = normalize(transform_direction_transposed(&tfm, *N));
}
ccl_device_inline bool object_negative_scale_applied(const int object_flag)
{
return ((object_flag & SD_OBJECT_NEGATIVE_SCALE) && (object_flag & SD_OBJECT_TRANSFORM_APPLIED));
}
/* Transform direction vector from object to world space */
ccl_device_inline void object_dir_transform(KernelGlobals kg,

View File

@ -21,7 +21,7 @@ ccl_device_inline float3 triangle_normal(KernelGlobals kg, ccl_private ShaderDat
const float3 v2 = kernel_data_fetch(tri_verts, tri_vindex.w + 2);
/* return normal */
if (sd->object_flag & SD_OBJECT_NEGATIVE_SCALE_APPLIED) {
if (object_negative_scale_applied(sd->object_flag)) {
return normalize(cross(v2 - v0, v1 - v0));
}
else {
@ -50,7 +50,7 @@ ccl_device_inline void triangle_point_normal(KernelGlobals kg,
/* get object flags */
int object_flag = kernel_data_fetch(object_flag, object);
/* compute normal */
if (object_flag & SD_OBJECT_NEGATIVE_SCALE_APPLIED) {
if (object_negative_scale_applied(object_flag)) {
*Ng = normalize(cross(v2 - v0, v1 - v0));
}
else {

View File

@ -176,8 +176,9 @@ ccl_device_forceinline void mnee_setup_manifold_vertex(KernelGlobals kg,
/* Geometric normal. */
vtx->ng = normalize(cross(dp_du, dp_dv));
if (sd_vtx->object_flag & SD_OBJECT_NEGATIVE_SCALE_APPLIED)
if (sd_vtx->object_flag & SD_OBJECT_NEGATIVE_SCALE) {
vtx->ng = -vtx->ng;
}
/* Shading normals: Interpolate normals between vertices. */
float n_len;

View File

@ -120,7 +120,7 @@ ccl_device_inline bool subsurface_disk(KernelGlobals kg,
if (path_flag & PATH_RAY_SUBSURFACE_BACKFACING) {
hit_Ng = -hit_Ng;
}
if (object_flag & SD_OBJECT_NEGATIVE_SCALE_APPLIED) {
if (object_negative_scale_applied(object_flag)) {
hit_Ng = -hit_Ng;
}

View File

@ -223,11 +223,16 @@ ccl_device bool compute_emitter_centroid_and_dir(KernelGlobals kg,
triangle_world_space_vertices(kg, object, prim_id, -1.0f, vertices);
centroid = (vertices[0] + vertices[1] + vertices[2]) / 3.0f;
if (kemitter->emission_sampling == EMISSION_SAMPLING_FRONT) {
const bool is_front_only = (kemitter->emission_sampling == EMISSION_SAMPLING_FRONT);
const bool is_back_only = (kemitter->emission_sampling == EMISSION_SAMPLING_BACK);
if (is_front_only || is_back_only) {
dir = safe_normalize(cross(vertices[1] - vertices[0], vertices[2] - vertices[0]));
}
else if (kemitter->emission_sampling == EMISSION_SAMPLING_BACK) {
dir = -safe_normalize(cross(vertices[1] - vertices[0], vertices[2] - vertices[0]));
if (is_back_only) {
dir = -dir;
}
if (kernel_data_fetch(object_flag, object) & SD_OBJECT_NEGATIVE_SCALE) {
dir = -dir;
}
}
else {
/* Double-sided: any vector in the plane. */

View File

@ -146,7 +146,7 @@ ccl_device_forceinline bool triangle_light_sample(KernelGlobals kg,
/* flip normal if necessary */
const int object_flag = kernel_data_fetch(object_flag, object);
if (object_flag & SD_OBJECT_NEGATIVE_SCALE_APPLIED) {
if (object_flag & SD_OBJECT_NEGATIVE_SCALE) {
ls->Ng = -ls->Ng;
}
ls->eval_fac = 1.0f;

View File

@ -224,7 +224,7 @@ ccl_device float3 svm_bevel(
float3 hit_Ng = isect.Ng[hit];
int object = isect.hits[hit].object;
int object_flag = kernel_data_fetch(object_flag, object);
if (object_flag & SD_OBJECT_NEGATIVE_SCALE_APPLIED) {
if (object_negative_scale_applied(object_flag)) {
hit_Ng = -hit_Ng;
}

View File

@ -850,8 +850,8 @@ enum ShaderDataObjectFlag {
SD_OBJECT_MOTION = (1 << 1),
/* Vertices have transform applied. */
SD_OBJECT_TRANSFORM_APPLIED = (1 << 2),
/* Vertices have negative scale applied. */
SD_OBJECT_NEGATIVE_SCALE_APPLIED = (1 << 3),
/* The object's transform applies a negative scale. */
SD_OBJECT_NEGATIVE_SCALE = (1 << 3),
/* Object has a volume shader. */
SD_OBJECT_HAS_VOLUME = (1 << 4),
/* Object intersects AABB of an object with volume shader. */
@ -873,7 +873,7 @@ enum ShaderDataObjectFlag {
SD_OBJECT_CAUSTICS = (SD_OBJECT_CAUSTICS_CASTER | SD_OBJECT_CAUSTICS_RECEIVER),
SD_OBJECT_FLAGS = (SD_OBJECT_HOLDOUT_MASK | SD_OBJECT_MOTION | SD_OBJECT_TRANSFORM_APPLIED |
SD_OBJECT_NEGATIVE_SCALE_APPLIED | SD_OBJECT_HAS_VOLUME |
SD_OBJECT_NEGATIVE_SCALE | SD_OBJECT_HAS_VOLUME |
SD_OBJECT_INTERSECTS_VOLUME | SD_OBJECT_SHADOW_CATCHER |
SD_OBJECT_HAS_VOLUME_ATTRIBUTES | SD_OBJECT_CAUSTICS |
SD_OBJECT_HAS_VOLUME_MOTION)

View File

@ -211,6 +211,11 @@ bool OIIOImageLoader::load_pixels(const ImageMetaData &metadata,
if (strcmp(in->format_name(), "dds") == 0) {
do_associate_alpha = true;
}
/* Workaround OIIO bug that sets oiio:UnassociatedAlpha on the last layer
* but not composite image that we read. */
if (strcmp(in->format_name(), "psd") == 0) {
do_associate_alpha = true;
}
}
}

View File

@ -94,14 +94,17 @@ LightTreePrimitive::LightTreePrimitive(Scene *scene, int prim_id, int object_id)
* seems to work fine */
centroid = (vertices[0] + vertices[1] + vertices[2]) / 3.0f;
if (shader->emission_sampling == EMISSION_SAMPLING_FRONT) {
/* Front only. */
const bool is_front_only = (shader->emission_sampling == EMISSION_SAMPLING_FRONT);
const bool is_back_only = (shader->emission_sampling == EMISSION_SAMPLING_BACK);
if (is_front_only || is_back_only) {
/* One-sided. */
bcone.axis = safe_normalize(cross(vertices[1] - vertices[0], vertices[2] - vertices[0]));
bcone.theta_o = 0;
}
else if (shader->emission_sampling == EMISSION_SAMPLING_BACK) {
/* Back only. */
bcone.axis = -safe_normalize(cross(vertices[1] - vertices[0], vertices[2] - vertices[0]));
if (is_back_only) {
bcone.axis = -bcone.axis;
}
if (transform_negative_scale(object->get_tfm())) {
bcone.axis = -bcone.axis;
}
bcone.theta_o = 0;
}
else {

View File

@ -435,6 +435,10 @@ void ObjectManager::device_update_object_transform(UpdateObjectTransformState *s
state->have_motion = true;
}
if (transform_negative_scale(tfm)) {
flag |= SD_OBJECT_NEGATIVE_SCALE;
}
if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::POINTCLOUD) {
/* TODO: why only mesh? */
Mesh *mesh = static_cast<Mesh *>(geom);
@ -970,8 +974,6 @@ void ObjectManager::apply_static_transforms(DeviceScene *dscene, Scene *scene, P
}
object_flag[i] |= SD_OBJECT_TRANSFORM_APPLIED;
if (geom->transform_negative_scaled)
object_flag[i] |= SD_OBJECT_NEGATIVE_SCALE_APPLIED;
}
}

View File

@ -16,7 +16,9 @@ void util_cdf_invert(const int resolution,
const bool make_symmetric,
vector<float> &inv_cdf)
{
assert(cdf[0] == 0.0f && cdf[resolution] == 1.0f);
const int cdf_size = cdf.size();
assert(cdf[0] == 0.0f && cdf[cdf_size - 1] == 1.0f);
const float inv_resolution = 1.0f / (float)resolution;
const float range = to - from;
inv_cdf.resize(resolution);
@ -26,12 +28,12 @@ void util_cdf_invert(const int resolution,
float x = i / (float)half_size;
int index = upper_bound(cdf.begin(), cdf.end(), x) - cdf.begin();
float t;
if (index < cdf.size() - 1) {
if (index < cdf_size - 1) {
t = (x - cdf[index]) / (cdf[index + 1] - cdf[index]);
}
else {
t = 0.0f;
index = cdf.size() - 1;
index = cdf_size - 1;
}
float y = ((index + t) / (resolution - 1)) * (2.0f * range);
inv_cdf[half_size + i] = 0.5f * (1.0f + y);
@ -43,7 +45,7 @@ void util_cdf_invert(const int resolution,
float x = (i + 0.5f) * inv_resolution;
int index = upper_bound(cdf.begin(), cdf.end(), x) - cdf.begin() - 1;
float t;
if (index < cdf.size() - 1) {
if (index < cdf_size - 1) {
t = (x - cdf[index]) / (cdf[index + 1] - cdf[index]);
}
else {

View File

@ -690,7 +690,7 @@ void nodeRemoveNode(struct Main *bmain,
void nodeDimensionsGet(const struct bNode *node, float *r_width, float *r_height);
void nodeTagUpdateID(struct bNode *node);
void nodeInternalLinks(struct bNode *node, struct bNodeLink ***r_links, int *r_len);
void nodeInternalLinks(struct bNode *node, struct bNodeLink **r_links, int *r_len);
#ifdef __cplusplus

View File

@ -254,7 +254,7 @@ class bNodeRuntime : NonCopyable, NonMovable {
float anim_ofsx;
/** List of cached internal links (input to output), for muted nodes and operators. */
Vector<bNodeLink *> internal_links;
Vector<bNodeLink> internal_links;
/** Eagerly maintained cache of the node's index in the tree. */
int index_in_tree = -1;
@ -626,7 +626,7 @@ inline bool bNode::is_group_output() const
return this->type == NODE_GROUP_OUTPUT;
}
inline blender::Span<const bNodeLink *> bNode::internal_links() const
inline blender::Span<bNodeLink> bNode::internal_links() const
{
return this->runtime->internal_links;
}

View File

@ -3048,7 +3048,7 @@ void BKE_curve_bevelList_make(Object *ob, const ListBase *nurbs, const bool for_
bevp2 = bevp1 + (bl->nr - 1);
nr = bl->nr / 2;
while (nr--) {
std::swap( *bevp1, *bevp2);
std::swap(*bevp1, *bevp2);
bevp1++;
bevp2--;
}
@ -4446,12 +4446,12 @@ void BKE_nurb_direction_switch(Nurb *nu)
swap_v3_v3(bezt2->vec[0], bezt2->vec[2]);
}
std::swap( bezt1->h1, bezt1->h2);
std::swap( bezt1->f1, bezt1->f3);
std::swap(bezt1->h1, bezt1->h2);
std::swap(bezt1->f1, bezt1->f3);
if (bezt1 != bezt2) {
std::swap( bezt2->h1, bezt2->h2);
std::swap( bezt2->f1, bezt2->f3);
std::swap(bezt2->h1, bezt2->h2);
std::swap(bezt2->f1, bezt2->f3);
bezt1->tilt = -bezt1->tilt;
bezt2->tilt = -bezt2->tilt;
}
@ -4469,7 +4469,7 @@ void BKE_nurb_direction_switch(Nurb *nu)
bp2 = bp1 + (a - 1);
a /= 2;
while (bp1 != bp2 && a > 0) {
std::swap( *bp1, *bp2);
std::swap(*bp1, *bp2);
a--;
bp1->tilt = -bp1->tilt;
bp2->tilt = -bp2->tilt;
@ -4491,7 +4491,7 @@ void BKE_nurb_direction_switch(Nurb *nu)
fp2 = fp1 + (a - 1);
a /= 2;
while (fp1 != fp2 && a > 0) {
std::swap( *fp1, *fp2);
std::swap(*fp1, *fp2);
a--;
fp1++;
fp2--;
@ -4530,7 +4530,7 @@ void BKE_nurb_direction_switch(Nurb *nu)
a /= 2;
while (bp1 != bp2 && a > 0) {
std::swap( *bp1, *bp2);
std::swap(*bp1, *bp2);
a--;
bp1++;
bp2--;

View File

@ -1959,10 +1959,10 @@ void nodeRemoveSocketEx(bNodeTree *ntree, bNode *node, bNodeSocket *sock, bool d
}
}
for (bNodeLink *link : node->runtime->internal_links) {
if (link->fromsock == sock || link->tosock == sock) {
node->runtime->internal_links.remove_first_occurrence_and_reorder(link);
MEM_freeN(link);
for (const int64_t i : node->runtime->internal_links.index_range()) {
const bNodeLink &link = node->runtime->internal_links[i];
if (link.fromsock == sock || link.tosock == sock) {
node->runtime->internal_links.remove_and_reorder(i);
BKE_ntree_update_tag_node_internal_link(ntree, node);
break;
}
@ -1986,9 +1986,6 @@ void nodeRemoveAllSockets(bNodeTree *ntree, bNode *node)
}
}
for (bNodeLink *link : node->runtime->internal_links) {
MEM_freeN(link);
}
node->runtime->internal_links.clear();
LISTBASE_FOREACH_MUTABLE (bNodeSocket *, sock, &node->inputs) {
@ -2312,14 +2309,12 @@ bNode *node_copy_with_mapping(bNodeTree *dst_tree,
node_dst->prop = IDP_CopyProperty_ex(node_src.prop, flag);
}
node_dst->runtime->internal_links.clear();
for (const bNodeLink *src_link : node_src.runtime->internal_links) {
bNodeLink *dst_link = (bNodeLink *)MEM_dupallocN(src_link);
dst_link->fromnode = node_dst;
dst_link->tonode = node_dst;
dst_link->fromsock = socket_map.lookup(src_link->fromsock);
dst_link->tosock = socket_map.lookup(src_link->tosock);
node_dst->runtime->internal_links.append(dst_link);
node_dst->runtime->internal_links = node_src.runtime->internal_links;
for (bNodeLink &dst_link : node_dst->runtime->internal_links) {
dst_link.fromnode = node_dst;
dst_link.tonode = node_dst;
dst_link.fromsock = socket_map.lookup(dst_link.fromsock);
dst_link.tosock = socket_map.lookup(dst_link.tosock);
}
if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
@ -2474,8 +2469,8 @@ static void adjust_multi_input_indices_after_removed_link(bNodeTree *ntree,
void nodeInternalRelink(bNodeTree *ntree, bNode *node)
{
/* store link pointers in output sockets, for efficient lookup */
for (bNodeLink *link : node->runtime->internal_links) {
link->tosock->link = link;
for (bNodeLink &link : node->runtime->internal_links) {
link.tosock->link = &link;
}
/* redirect downstream links */
@ -2989,11 +2984,6 @@ void node_free_node(bNodeTree *ntree, bNode *node)
MEM_freeN(sock);
}
for (bNodeLink *link : node->runtime->internal_links) {
MEM_freeN(link);
}
node->runtime->internal_links.clear();
if (node->prop) {
/* Remember, no ID user refcount management here! */
IDP_FreePropertyContent_ex(node->prop, false);
@ -3644,7 +3634,7 @@ void nodeTagUpdateID(bNode *node)
node->runtime->update |= NODE_UPDATE_ID;
}
void nodeInternalLinks(bNode *node, bNodeLink ***r_links, int *r_len)
void nodeInternalLinks(bNode *node, bNodeLink **r_links, int *r_len)
{
*r_links = node->runtime->internal_links.data();
*r_len = node->runtime->internal_links.size();

View File

@ -95,8 +95,8 @@ static void update_internal_link_inputs(const bNodeTree &ntree)
for (bNodeSocket *socket : node->runtime->outputs) {
socket->runtime->internal_link_input = nullptr;
}
for (bNodeLink *link : node->runtime->internal_links) {
link->tosock->runtime->internal_link_input = link->fromsock;
for (bNodeLink &link : node->runtime->internal_links) {
link.tosock->runtime->internal_link_input = link.fromsock;
}
}
}

View File

@ -635,8 +635,8 @@ class NodeTreeMainUpdater {
const bNodeSocket *from_socket = item.first;
const bNodeSocket *to_socket = item.second;
bool found = false;
for (const bNodeLink *internal_link : node->runtime->internal_links) {
if (from_socket == internal_link->fromsock && to_socket == internal_link->tosock) {
for (const bNodeLink &internal_link : node->runtime->internal_links) {
if (from_socket == internal_link.fromsock && to_socket == internal_link.tosock) {
found = true;
}
}
@ -682,19 +682,17 @@ class NodeTreeMainUpdater {
bNode &node,
Span<std::pair<bNodeSocket *, bNodeSocket *>> links)
{
for (bNodeLink *link : node.runtime->internal_links) {
MEM_freeN(link);
}
node.runtime->internal_links.clear();
node.runtime->internal_links.reserve(links.size());
for (const auto &item : links) {
bNodeSocket *from_socket = item.first;
bNodeSocket *to_socket = item.second;
bNodeLink *link = MEM_cnew<bNodeLink>(__func__);
link->fromnode = &node;
link->fromsock = from_socket;
link->tonode = &node;
link->tosock = to_socket;
link->flag |= NODE_LINK_VALID;
bNodeLink link{};
link.fromnode = &node;
link.fromsock = from_socket;
link.tonode = &node;
link.tosock = to_socket;
link.flag |= NODE_LINK_VALID;
node.runtime->internal_links.append(link);
}
BKE_ntree_update_tag_node_internal_link(&ntree, &node);

View File

@ -1686,14 +1686,14 @@ static void scene_undo_preserve(BlendLibReader *reader, ID *id_new, ID *id_old)
Scene *scene_new = (Scene *)id_new;
Scene *scene_old = (Scene *)id_old;
std::swap( scene_old->cursor, scene_new->cursor);
std::swap(scene_old->cursor, scene_new->cursor);
if (scene_new->toolsettings != nullptr && scene_old->toolsettings != nullptr) {
/* First try to restore ID pointers that can be and should be preserved (like brushes or
* palettes), and counteract the swap of the whole ToolSettings structs below for the others
* (like object ones). */
scene_foreach_toolsettings(
nullptr, scene_new->toolsettings, true, reader, scene_old->toolsettings);
std::swap( *scene_old->toolsettings, *scene_new->toolsettings);
std::swap(*scene_old->toolsettings, *scene_new->toolsettings);
}
}

View File

@ -181,8 +181,8 @@ void NodeGraph::add_proxies_mute(bNodeTree *b_ntree,
bNodeInstanceKey key,
bool is_active_group)
{
for (const bNodeLink *b_link : b_node->internal_links()) {
SocketProxyNode *proxy = new SocketProxyNode(b_node, b_link->fromsock, b_link->tosock, false);
for (const bNodeLink &b_link : b_node->internal_links()) {
SocketProxyNode *proxy = new SocketProxyNode(b_node, b_link.fromsock, b_link.tosock, false);
add_node(proxy, b_ntree, key, is_active_group);
}
}

View File

@ -3087,7 +3087,7 @@ static void ui_textedit_set_cursor_select(uiBut *but, uiHandleButtonData *data,
but->selsta = but->pos;
but->selend = data->sel_pos_init;
if (but->selend < but->selsta) {
std::swap(but->selsta, but->selend);
std::swap(but->selsta, but->selend);
}
ui_but_update(but);
@ -3190,7 +3190,7 @@ static void ui_textedit_move(uiBut *but,
but->selend = data->sel_pos_init;
}
if (but->selend < but->selsta) {
std::swap( but->selsta, but->selend);
std::swap(but->selsta, but->selend);
}
}
}

View File

@ -261,10 +261,10 @@ void *ED_image_paint_tile_push(PaintTileMap *paint_tile_map,
ED_IMAGE_UNDO_TILE_SIZE);
if (has_float) {
std::swap( ptile->rect.fp, (*tmpibuf)->rect_float);
std::swap(ptile->rect.fp, (*tmpibuf)->rect_float);
}
else {
std::swap(ptile->rect.uint, (*tmpibuf)->rect);
std::swap(ptile->rect.uint, (*tmpibuf)->rect);
}
PaintTileKey key = {};
@ -299,10 +299,10 @@ static void ptile_restore_runtime_map(PaintTileMap *paint_tile_map)
const bool has_float = (ibuf->rect_float != nullptr);
if (has_float) {
std::swap( ptile->rect.fp, tmpibuf->rect_float);
std::swap(ptile->rect.fp, tmpibuf->rect_float);
}
else {
std::swap(ptile->rect.uint, tmpibuf->rect);
std::swap(ptile->rect.uint, tmpibuf->rect);
}
IMB_rectcpy(ibuf,
@ -315,10 +315,10 @@ static void ptile_restore_runtime_map(PaintTileMap *paint_tile_map)
ED_IMAGE_UNDO_TILE_SIZE);
if (has_float) {
std::swap( ptile->rect.fp, tmpibuf->rect_float);
std::swap(ptile->rect.fp, tmpibuf->rect_float);
}
else {
std::swap(ptile->rect.uint, tmpibuf->rect);
std::swap(ptile->rect.uint, tmpibuf->rect);
}
/* Force OpenGL reload (maybe partial update will operate better?) */
@ -380,19 +380,19 @@ static void utile_init_from_imbuf(
const bool has_float = ibuf->rect_float;
if (has_float) {
std::swap( utile->rect.fp, tmpibuf->rect_float);
std::swap(utile->rect.fp, tmpibuf->rect_float);
}
else {
std::swap(utile->rect.uint_ptr, tmpibuf->rect);
std::swap(utile->rect.uint_ptr, tmpibuf->rect);
}
IMB_rectcpy(tmpibuf, ibuf, 0, 0, x, y, ED_IMAGE_UNDO_TILE_SIZE, ED_IMAGE_UNDO_TILE_SIZE);
if (has_float) {
std::swap( utile->rect.fp, tmpibuf->rect_float);
std::swap(utile->rect.fp, tmpibuf->rect_float);
}
else {
std::swap(utile->rect.uint_ptr, tmpibuf->rect);
std::swap(utile->rect.uint_ptr, tmpibuf->rect);
}
}

View File

@ -675,9 +675,9 @@ static void node_draw_mute_line(const bContext &C,
{
GPU_blend(GPU_BLEND_ALPHA);
for (const bNodeLink *link : node.internal_links()) {
if (!nodeLinkIsHidden(link)) {
node_draw_link_bezier(C, v2d, snode, *link, TH_WIRE_INNER, TH_WIRE_INNER, TH_WIRE, false);
for (const bNodeLink &link : node.internal_links()) {
if (!nodeLinkIsHidden(&link)) {
node_draw_link_bezier(C, v2d, snode, link, TH_WIRE_INNER, TH_WIRE_INNER, TH_WIRE, false);
}
}

View File

@ -1744,7 +1744,7 @@ void NODE_OT_mute_toggle(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Toggle Node Mute";
ot->description = "Toggle muting of the nodes";
ot->description = "Toggle muting of selected nodes";
ot->idname = "NODE_OT_mute_toggle";
/* callbacks */
@ -1783,7 +1783,7 @@ void NODE_OT_delete(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Delete";
ot->description = "Delete selected nodes";
ot->description = "Remove selected nodes";
ot->idname = "NODE_OT_delete";
/* api callbacks */
@ -1871,7 +1871,7 @@ void NODE_OT_delete_reconnect(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Delete with Reconnect";
ot->description = "Delete nodes; will reconnect nodes as if deletion was muted";
ot->description = "Remove nodes and reconnect nodes as if deletion was muted";
ot->idname = "NODE_OT_delete_reconnect";
/* api callbacks */
@ -1975,7 +1975,7 @@ void NODE_OT_output_file_remove_active_socket(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Remove File Node Socket";
ot->description = "Remove active input from a file output node";
ot->description = "Remove the active input from a file output node";
ot->idname = "NODE_OT_output_file_remove_active_socket";
/* callbacks */
@ -2171,7 +2171,7 @@ void NODE_OT_tree_socket_add(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Add Node Tree Interface Socket";
ot->description = "Add an input or output socket to the current node tree";
ot->description = "Add an input or output to the active node tree";
ot->idname = "NODE_OT_tree_socket_add";
/* api callbacks */
@ -2222,7 +2222,7 @@ void NODE_OT_tree_socket_remove(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Remove Node Tree Interface Socket";
ot->description = "Remove an input or output socket to the current node tree";
ot->description = "Remove an input or output from the active node tree";
ot->idname = "NODE_OT_tree_socket_remove";
/* api callbacks */
@ -2321,7 +2321,7 @@ void NODE_OT_tree_socket_change_type(wmOperatorType *ot)
/* identifiers */
ot->name = "Change Node Tree Interface Socket Type";
ot->description = "Change the type of a socket of the current node tree";
ot->description = "Change the type of an input or output of the active node tree";
ot->idname = "NODE_OT_tree_socket_change_type";
/* api callbacks */
@ -2402,7 +2402,7 @@ void NODE_OT_tree_socket_move(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Move Node Tree Socket";
ot->description = "Move a socket up or down in the current node tree's sockets stack";
ot->description = "Move a socket up or down in the active node tree's interface";
ot->idname = "NODE_OT_tree_socket_move";
/* api callbacks */

View File

@ -285,10 +285,10 @@ static void gizmo_node_crop_prop_matrix_set(const wmGizmo *gz,
rct_isect.ymax = 1;
BLI_rctf_isect(&rct_isect, &rct, &rct);
if (nx) {
std::swap( rct.xmin, rct.xmax);
std::swap(rct.xmin, rct.xmax);
}
if (ny) {
std::swap( rct.ymin, rct.ymax);
std::swap(rct.ymin, rct.ymax);
}
two_xy_from_rect(nxy, &rct, dims, is_relative);
gizmo_node_crop_update(crop_group);

View File

@ -393,7 +393,7 @@ static void applyAxisConstraintVec(const TransInfo *t,
if (!td && t->con.mode & CON_APPLY) {
bool is_snap_to_point = false, is_snap_to_edge = false, is_snap_to_face = false;
if (activeSnap(t)) {
if (transform_snap_is_active(t)) {
if (validSnap(t)) {
is_snap_to_edge = (t->tsnap.snapElem & SCE_SNAP_MODE_EDGE) != 0;
is_snap_to_face = (t->tsnap.snapElem & SCE_SNAP_MODE_FACE_RAYCAST) != 0;

View File

@ -1193,7 +1193,7 @@ static void restoreBones(TransDataContainer *tc)
static void recalcData_edit_armature(TransInfo *t)
{
if (t->state != TRANS_CANCEL) {
applySnappingIndividual(t);
transform_snap_project_individual_apply(t);
}
FOREACH_TRANS_DATA_CONTAINER (t, tc) {

View File

@ -419,7 +419,7 @@ static void createTransCurveVerts(bContext *UNUSED(C), TransInfo *t)
static void recalcData_curve(TransInfo *t)
{
if (t->state != TRANS_CANCEL) {
applySnappingIndividual(t);
transform_snap_project_individual_apply(t);
}
FOREACH_TRANS_DATA_CONTAINER (t, tc) {

View File

@ -102,7 +102,7 @@ static void createTransLatticeVerts(bContext *UNUSED(C), TransInfo *t)
static void recalcData_lattice(TransInfo *t)
{
if (t->state != TRANS_CANCEL) {
applySnappingIndividual(t);
transform_snap_project_individual_apply(t);
}
FOREACH_TRANS_DATA_CONTAINER (t, tc) {

View File

@ -123,7 +123,7 @@ static void createTransMBallVerts(bContext *UNUSED(C), TransInfo *t)
static void recalcData_mball(TransInfo *t)
{
if (t->state != TRANS_CANCEL) {
applySnappingIndividual(t);
transform_snap_project_individual_apply(t);
}
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
if (tc->data_len) {

View File

@ -1895,7 +1895,7 @@ static void tc_mesh_partial_types_calc(TransInfo *t, struct PartialTypeState *r_
partial_for_looptri = PARTIAL_TYPE_GROUP;
partial_for_normals = PARTIAL_TYPE_GROUP;
/* Translation can rotate when snapping to normal. */
if (activeSnap(t) && usingSnappingNormal(t) && validSnappingNormal(t)) {
if (transform_snap_is_active(t) && usingSnappingNormal(t) && validSnappingNormal(t)) {
partial_for_normals = PARTIAL_TYPE_ALL;
}
break;
@ -1926,7 +1926,7 @@ static void tc_mesh_partial_types_calc(TransInfo *t, struct PartialTypeState *r_
}
/* With projection, transform isn't affine. */
if (activeSnap_SnappingIndividual(t)) {
if (transform_snap_project_individual_is_active(t)) {
if (partial_for_looptri == PARTIAL_TYPE_GROUP) {
partial_for_looptri = PARTIAL_TYPE_ALL;
}
@ -2042,7 +2042,7 @@ static void recalcData_mesh(TransInfo *t)
bool is_canceling = t->state == TRANS_CANCEL;
/* Apply corrections. */
if (!is_canceling) {
applySnappingIndividual(t);
transform_snap_project_individual_apply(t);
bool do_mirror = !(t->flag & T_NO_MIRROR);
FOREACH_TRANS_DATA_CONTAINER (t, tc) {

View File

@ -156,7 +156,8 @@ static void node_snap_grid_apply(TransInfo *t)
{
using namespace blender;
if (!(activeSnap(t) && (t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)))) {
if (!(transform_snap_is_active(t) &&
(t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)))) {
return;
}

View File

@ -878,7 +878,7 @@ static void recalcData_objects(TransInfo *t)
bool motionpath_update = false;
if (t->state != TRANS_CANCEL) {
applySnappingIndividual(t);
transform_snap_project_individual_apply(t);
}
FOREACH_TRANS_DATA_CONTAINER (t, tc) {

View File

@ -92,7 +92,7 @@ static void recalcData_texspace(TransInfo *t)
{
if (t->state != TRANS_CANCEL) {
applySnappingIndividual(t);
transform_snap_project_individual_apply(t);
}
FOREACH_TRANS_DATA_CONTAINER (t, tc) {

View File

@ -241,7 +241,7 @@ static void flushTransParticles(TransInfo *t)
static void recalcData_particles(TransInfo *t)
{
if (t->state != TRANS_CANCEL) {
applySnappingIndividual(t);
transform_snap_project_individual_apply(t);
}
flushTransParticles(t);
}

View File

@ -84,7 +84,7 @@ static void applyNormalRotation(TransInfo *t, const int UNUSED(mval[2]))
transform_snap_increment(t, &angle);
applySnappingAsGroup(t, &angle);
transform_snap_mixed_apply(t, &angle);
applyNumInput(&t->num, &angle);

View File

@ -87,7 +87,7 @@ static void applySeqSlide(TransInfo *t, const int UNUSED(mval[2]))
}
else {
copy_v2_v2(values_final, t->values);
applySnappingAsGroup(t, values_final);
transform_snap_mixed_apply(t, values_final);
transform_convert_sequencer_channel_clamp(t, values_final);
if (t->con.mode & CON_APPLY) {

View File

@ -1447,7 +1447,7 @@ static void applyEdgeSlide(TransInfo *t, const int UNUSED(mval[2]))
final = t->values[0] + t->values_modal_offset[0];
applySnappingAsGroup(t, &final);
transform_snap_mixed_apply(t, &final);
if (!validSnap(t)) {
transform_snap_increment(t, &final);
}

View File

@ -203,7 +203,7 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2]))
constraintNumInput(t, t->values_final);
}
applySnappingAsGroup(t, t->values_final);
transform_snap_mixed_apply(t, t->values_final);
}
size_to_mat3(mat, t->values_final);

View File

@ -368,8 +368,8 @@ static void applyRotation(TransInfo *t, const int UNUSED(mval[2]))
final = large_rotation_limit(final);
}
else {
applySnappingAsGroup(t, &final);
if (!(activeSnap(t) && validSnap(t))) {
transform_snap_mixed_apply(t, &final);
if (!(transform_snap_is_active(t) && validSnap(t))) {
transform_snap_increment(t, &final);
}
}

View File

@ -99,7 +99,7 @@ static void applySkinResize(TransInfo *t, const int UNUSED(mval[2]))
constraintNumInput(t, t->values_final);
}
applySnappingAsGroup(t, t->values_final);
transform_snap_mixed_apply(t, t->values_final);
}
size_to_mat3(mat_final, t->values_final);

View File

@ -398,7 +398,7 @@ static void translate_snap_grid_apply(TransInfo *t,
static bool translate_snap_grid(TransInfo *t, float *val)
{
if (!activeSnap(t)) {
if (!transform_snap_is_active(t)) {
return false;
}
@ -475,7 +475,7 @@ static void applyTranslationValue(TransInfo *t, const float vec[3])
enum eTranslateRotateMode rotate_mode = TRANSLATE_ROTATE_OFF;
if (activeSnap(t) && usingSnappingNormal(t) && validSnappingNormal(t)) {
if (transform_snap_is_active(t) && usingSnappingNormal(t) && validSnappingNormal(t)) {
rotate_mode = TRANSLATE_ROTATE_ON;
}
@ -610,7 +610,7 @@ static void applyTranslation(TransInfo *t, const int UNUSED(mval[2]))
}
t->tsnap.snapElem = SCE_SNAP_MODE_NONE;
applySnappingAsGroup(t, global_dir);
transform_snap_mixed_apply(t, global_dir);
translate_snap_grid(t, global_dir);
if (t->con.mode & CON_APPLY) {
@ -621,7 +621,7 @@ static void applyTranslation(TransInfo *t, const int UNUSED(mval[2]))
float incr_dir[3];
copy_v3_v3(incr_dir, global_dir);
if (!(activeSnap(t) && validSnap(t)) &&
if (!(transform_snap_is_active(t) && validSnap(t)) &&
transform_snap_increment_ex(t, (t->con.mode & CON_APPLY) != 0, incr_dir)) {
/* Test for mixed snap with grid. */

View File

@ -562,7 +562,7 @@ static void applyVertSlide(TransInfo *t, const int UNUSED(mval[2]))
final = t->values[0] + t->values_modal_offset[0];
applySnappingAsGroup(t, &final);
transform_snap_mixed_apply(t, &final);
if (!validSnap(t)) {
transform_snap_increment(t, &final);
}

View File

@ -119,50 +119,12 @@ bool validSnap(const TransInfo *t)
(t->tsnap.status & (MULTI_POINTS | TARGET_INIT)) == (MULTI_POINTS | TARGET_INIT);
}
bool activeSnap(const TransInfo *t)
bool transform_snap_is_active(const TransInfo *t)
{
return ((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP) ||
((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP_INVERT);
}
bool activeSnap_SnappingIndividual(const TransInfo *t)
{
if (!activeSnap(t) || (t->flag & T_NO_PROJECT)) {
return false;
}
if (!(t->tsnap.project || (t->tsnap.mode & SCE_SNAP_MODE_FACE_NEAREST))) {
return false;
}
if (doForceIncrementSnap(t)) {
return false;
}
return true;
}
bool activeSnap_SnappingAsGroup(const TransInfo *t)
{
if (!activeSnap(t)) {
return false;
}
if (t->tsnap.mode == SCE_SNAP_MODE_FACE_RAYCAST && t->tsnap.project) {
return false;
}
if (t->tsnap.mode == SCE_SNAP_MODE_FACE_NEAREST) {
return false;
}
if (doForceIncrementSnap(t)) {
return false;
}
return true;
}
bool transformModeUseSnap(const TransInfo *t)
{
ToolSettings *ts = t->settings;
@ -190,7 +152,7 @@ static bool doForceIncrementSnap(const TransInfo *t)
void drawSnapping(const struct bContext *C, TransInfo *t)
{
uchar col[4], selectedCol[4], activeCol[4];
if (!activeSnap(t)) {
if (!transform_snap_is_active(t)) {
return;
}
@ -483,9 +445,30 @@ static void applyFaceNearest(TransInfo *t, TransDataContainer *tc, TransData *td
/* TODO: support snap alignment similar to #SCE_SNAP_MODE_FACE_RAYCAST? */
}
void applySnappingIndividual(TransInfo *t)
bool transform_snap_project_individual_is_active(const TransInfo *t)
{
if (!activeSnap_SnappingIndividual(t)) {
if (!transform_snap_is_active(t)) {
return false;
}
if (t->flag & T_NO_PROJECT) {
return false;
}
if (!(t->tsnap.project || (t->tsnap.mode & SCE_SNAP_MODE_FACE_NEAREST))) {
return false;
}
if (doForceIncrementSnap(t)) {
return false;
}
return true;
}
void transform_snap_project_individual_apply(TransInfo *t)
{
if (!transform_snap_project_individual_is_active(t)) {
return;
}
@ -514,9 +497,30 @@ void applySnappingIndividual(TransInfo *t)
}
}
void applySnappingAsGroup(TransInfo *t, float *vec)
static bool transform_snap_mixed_is_active(const TransInfo *t)
{
if (!activeSnap_SnappingAsGroup(t)) {
if (!transform_snap_is_active(t)) {
return false;
}
if (t->tsnap.mode == SCE_SNAP_MODE_FACE_RAYCAST && t->tsnap.project) {
return false;
}
if (t->tsnap.mode == SCE_SNAP_MODE_FACE_NEAREST) {
return false;
}
if (doForceIncrementSnap(t)) {
return false;
}
return true;
}
void transform_snap_mixed_apply(TransInfo *t, float *vec)
{
if (!transform_snap_mixed_is_active(t)) {
return;
}
@ -526,7 +530,7 @@ void applySnappingAsGroup(TransInfo *t, float *vec)
t->tsnap.applySnap(t, vec);
}
else if (((t->tsnap.mode & ~(SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)) != 0) &&
activeSnap(t)) {
transform_snap_is_active(t)) {
double current = PIL_check_seconds_timer();
/* Time base quirky code to go around find-nearest slowness. */
@ -1628,7 +1632,7 @@ static void snap_increment_apply(const TransInfo *t,
bool transform_snap_increment_ex(const TransInfo *t, bool use_local_space, float *r_val)
{
if (!activeSnap(t)) {
if (!transform_snap_is_active(t)) {
return false;
}
@ -1664,8 +1668,9 @@ bool transform_snap_increment(const TransInfo *t, float *r_val)
float transform_snap_increment_get(const TransInfo *t)
{
if (activeSnap(t) && (!transformModeUseSnap(t) ||
(t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)))) {
if (transform_snap_is_active(t) &&
(!transformModeUseSnap(t) ||
(t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)))) {
return (t->modifiers & MOD_PRECISION) ? t->snap[1] : t->snap[0];
}

View File

@ -43,16 +43,15 @@ bool transform_snap_increment_ex(const TransInfo *t, bool use_local_space, float
bool transform_snap_increment(const TransInfo *t, float *val);
float transform_snap_increment_get(const TransInfo *t);
bool activeSnap(const TransInfo *t);
bool activeSnap_SnappingIndividual(const TransInfo *t);
bool activeSnap_SnappingAsGroup(const TransInfo *t);
bool transform_snap_is_active(const TransInfo *t);
bool validSnap(const TransInfo *t);
void initSnapping(struct TransInfo *t, struct wmOperator *op);
void freeSnapping(struct TransInfo *t);
void applySnappingIndividual(TransInfo *t);
void applySnappingAsGroup(TransInfo *t, float *vec);
bool transform_snap_project_individual_is_active(const TransInfo *t);
void transform_snap_project_individual_apply(TransInfo *t);
void transform_snap_mixed_apply(TransInfo *t, float *vec);
void resetSnapping(TransInfo *t);
eRedrawFlag handleSnapping(TransInfo *t, const struct wmEvent *event);
void drawSnapping(const struct bContext *C, TransInfo *t);

View File

@ -34,7 +34,7 @@ short getAnimEdit_SnapMode(TransInfo *t)
}
}
else if (t->spacetype == SPACE_GRAPH) {
if ((t->mode == TFM_TRANSLATION) && activeSnap(t)) {
if ((t->mode == TFM_TRANSLATION) && transform_snap_is_active(t)) {
return autosnap;
}
SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first;

View File

@ -1640,7 +1640,7 @@ std::optional<Mesh *> mesh_merge_by_distance_connected(const Mesh &mesh,
continue;
}
if (v1 > v2) {
std::swap( v1, v2);
std::swap(v1, v2);
}
WeldVertexCluster *v1_cluster = &vert_clusters[v1];
WeldVertexCluster *v2_cluster = &vert_clusters[v2];

View File

@ -1877,7 +1877,7 @@ static void lineart_edge_neighbor_init_task(void *__restrict userdata,
adj_e->v1 = mloop[looptri->tri[i % 3]].v;
adj_e->v2 = mloop[looptri->tri[(i + 1) % 3]].v;
if (adj_e->v1 > adj_e->v2) {
std::swap( adj_e->v1, adj_e->v2);
std::swap(adj_e->v1, adj_e->v2);
}
edge_nabr->e = -1;
@ -3266,7 +3266,7 @@ static void lineart_add_isec_thread(LineartIsecThread *th,
isec_single->tri1 = tri1;
isec_single->tri2 = tri2;
if (tri1->target_reference > tri2->target_reference) {
std::swap( isec_single->tri1, isec_single->tri2);
std::swap(isec_single->tri1, isec_single->tri2);
}
th->current++;
}

View File

@ -10,15 +10,15 @@
/** \name Static constructors
* \{ */
mat2x2 mat2x2__diagonal(float v)
mat2x2 mat2x2_diagonal(float v)
{
return mat2x2(vec2(v, 0.0), vec2(0.0, v));
}
mat3x3 mat3x3__diagonal(float v)
mat3x3 mat3x3_diagonal(float v)
{
return mat3x3(vec3(v, 0.0, 0.0), vec3(0.0, v, 0.0), vec3(0.0, 0.0, v));
}
mat4x4 mat4x4__diagonal(float v)
mat4x4 mat4x4_diagonal(float v)
{
return mat4x4(vec4(v, 0.0, 0.0, 0.0),
vec4(0.0, v, 0.0, 0.0),
@ -26,43 +26,43 @@ mat4x4 mat4x4__diagonal(float v)
vec4(0.0, 0.0, 0.0, v));
}
mat2x2 mat2x2__all(float v)
mat2x2 mat2x2_all(float v)
{
return mat2x2(vec2(v), vec2(v));
}
mat3x3 mat3x3__all(float v)
mat3x3 mat3x3_all(float v)
{
return mat3x3(vec3(v), vec3(v), vec3(v));
}
mat4x4 mat4x4__all(float v)
mat4x4 mat4x4_all(float v)
{
return mat4x4(vec4(v), vec4(v), vec4(v), vec4(v));
}
mat2x2 mat2x2__zero(float v)
mat2x2 mat2x2_zero(float v)
{
return mat2x2__all(0.0);
return mat2x2_all(0.0);
}
mat3x3 mat3x3__zero(float v)
mat3x3 mat3x3_zero(float v)
{
return mat3x3__all(0.0);
return mat3x3_all(0.0);
}
mat4x4 mat4x4__zero(float v)
mat4x4 mat4x4_zero(float v)
{
return mat4x4__all(0.0);
return mat4x4_all(0.0);
}
mat2x2 mat2x2__identity()
mat2x2 mat2x2_identity()
{
return mat2x2__diagonal(1.0);
return mat2x2_diagonal(1.0);
}
mat3x3 mat3x3__identity()
mat3x3 mat3x3_identity()
{
return mat3x3__diagonal(1.0);
return mat3x3_diagonal(1.0);
}
mat4x4 mat4x4__identity()
mat4x4 mat4x4_identity()
{
return mat4x4__diagonal(1.0);
return mat4x4_diagonal(1.0);
}
/** \} */
@ -362,7 +362,7 @@ vec3 project_point(mat4x4 mat, vec3 point);
* Maps each axis range to [-1..1] range for all axes.
* The resulting matrix can be used with either #project_point or #transform_point.
*/
mat4x4 projection__orthographic(
mat4x4 projection_orthographic(
float left, float right, float bottom, float top, float near_clip, float far_clip);
/**
@ -371,7 +371,7 @@ mat4x4 projection__orthographic(
* `left`, `right`, `bottom`, `top` are frustum side distances at `z=near_clip`.
* The resulting matrix can be used with #project_point.
*/
mat4x4 projection__perspective(
mat4x4 projection_perspective(
float left, float right, float bottom, float top, float near_clip, float far_clip);
/**
@ -380,12 +380,12 @@ mat4x4 projection__perspective(
* Uses field of view angles instead of plane distances.
* The resulting matrix can be used with #project_point.
*/
mat4x4 projection__perspective_fov(float angle_left,
float angle_right,
float angle_bottom,
float angle_top,
float near_clip,
float far_clip);
mat4x4 projection_perspective_fov(float angle_left,
float angle_right,
float angle_bottom,
float angle_top,
float near_clip,
float far_clip);
/** \} */
@ -469,20 +469,18 @@ mat4x4 invert(mat4x4 mat, out bool r_success)
return r_success ? inverse(mat) : mat4x4(0.0);
}
# ifdef GPU_METAL
float2 normalize(float2 a)
vec2 normalize(vec2 a)
{
return a * rsqrt(length_squared(a));
return a * inversesqrt(length_squared(a));
}
float3 normalize(float3 a)
vec3 normalize(vec3 a)
{
return a * rsqrt(length_squared(a));
return a * inversesqrt(length_squared(a));
}
float4 normalize(float4 a)
vec4 normalize(vec4 a)
{
return a * rsqrt(length_squared(a));
return a * inversesqrt(length_squared(a));
}
# endif
mat2x2 normalize(mat2x2 mat)
{
@ -1013,7 +1011,7 @@ mat4x4 from_loc_rot_scale(vec3 location, AxisAngle rotation, vec3 scale)
return ret;
}
void detail__normalized_to_eul2(mat3 mat, out EulerXYZ eul1, out EulerXYZ eul2)
void detail_normalized_to_eul2(mat3 mat, out EulerXYZ eul1, out EulerXYZ eul2)
{
float cy = hypot(mat[0][0], mat[0][1]);
if (cy > 16.0f * FLT_EPSILON) {
@ -1044,7 +1042,7 @@ EulerXYZ to_euler(mat3x3 mat, const bool normalized)
mat = normalize(mat);
}
EulerXYZ eul1, eul2;
detail__normalized_to_eul2(mat, eul1, eul2);
detail_normalized_to_eul2(mat, eul1, eul2);
/* Return best, which is just the one with lowest values it in. */
return (length_manhattan(as_vec3(eul1)) > length_manhattan(as_vec3(eul2))) ? eul2 : eul1;
}
@ -1140,11 +1138,11 @@ Quaternion normalized_to_quat_fast(mat3 mat)
return q;
}
Quaternion detail__normalized_to_quat_with_checks(mat3x3 mat)
Quaternion detail_normalized_to_quat_with_checks(mat3x3 mat)
{
float det = determinant(mat);
if (!isfinite(det)) {
return Quaternion__identity();
return Quaternion_identity();
}
else if (det < 0.0) {
return normalized_to_quat_fast(-mat);
@ -1154,7 +1152,7 @@ Quaternion detail__normalized_to_quat_with_checks(mat3x3 mat)
Quaternion to_quaternion(mat3x3 mat)
{
return detail__normalized_to_quat_with_checks(normalize(mat));
return detail_normalized_to_quat_with_checks(normalize(mat));
}
Quaternion to_quaternion(mat3x3 mat, const bool normalized)
{
@ -1310,7 +1308,7 @@ mat4x4 interpolate_fast(mat4x4 a, mat4x4 b, float t)
return from_loc_rot_scale(location, rotation, scale);
}
mat4x4 projection__orthographic(
mat4x4 projection_orthographic(
float left, float right, float bottom, float top, float near_clip, float far_clip)
{
float x_delta = right - left;
@ -1329,7 +1327,7 @@ mat4x4 projection__orthographic(
return mat;
}
mat4x4 projection__perspective(
mat4x4 projection_perspective(
float left, float right, float bottom, float top, float near_clip, float far_clip)
{
float x_delta = right - left;
@ -1349,14 +1347,14 @@ mat4x4 projection__perspective(
return mat;
}
mat4x4 projection__perspective_fov(float angle_left,
float angle_right,
float angle_bottom,
float angle_top,
float near_clip,
float far_clip)
mat4x4 projection_perspective_fov(float angle_left,
float angle_right,
float angle_bottom,
float angle_top,
float near_clip,
float far_clip)
{
mat4x4 mat = projection__perspective(
mat4x4 mat = projection_perspective(
tan(angle_left), tan(angle_right), tan(angle_bottom), tan(angle_top), near_clip, far_clip);
mat[0][0] /= near_clip;
mat[1][1] /= near_clip;

View File

@ -29,7 +29,7 @@ struct AxisAngle {
# endif
};
AxisAngle AxisAngle__identity()
AxisAngle AxisAngle_identity()
{
return AxisAngle(vec3(0, 1, 0), 0);
}
@ -47,7 +47,7 @@ vec4 as_vec4(Quaternion quat)
return vec4(quat.x, quat.y, quat.z, quat.w);
}
Quaternion Quaternion__identity()
Quaternion Quaternion_identity()
{
return Quaternion(1, 0, 0, 0);
}
@ -65,7 +65,7 @@ vec3 as_vec3(EulerXYZ eul)
return vec3(eul.x, eul.y, eul.z);
}
EulerXYZ EulerXYZ__identity()
EulerXYZ EulerXYZ_identity()
{
return EulerXYZ(0, 0, 0);
}

View File

@ -12,15 +12,15 @@ void main()
{
TEST(math_matrix, MatrixInverse)
{
mat3x3 mat = mat3x3__diagonal(2);
mat3x3 mat = mat3x3_diagonal(2);
mat3x3 inv = invert(mat);
mat3x3 expect = mat3x3__diagonal(0.5f);
mat3x3 expect = mat3x3_diagonal(0.5f);
EXPECT_NEAR(inv, expect, 1e-5f);
bool success;
mat3x3 m2 = mat3x3__all(1);
mat3x3 m2 = mat3x3_all(1);
mat3x3 inv2 = invert(m2, success);
mat3x3 expect2 = mat3x3__all(0);
mat3x3 expect2 = mat3x3_all(0);
EXPECT_NEAR(inv2, expect2, 1e-5f);
EXPECT_FALSE(success);
}
@ -71,7 +71,7 @@ void main()
m = mat4(from_rotation(quat));
EXPECT_NEAR(m, expect, 1e-5);
m = mat4(from_rotation(axis_angle));
EXPECT_NEAR(m, expect, 1e-5);
EXPECT_NEAR(m, expect, 3e-4); /* Has some precision issue on some platform. */
m = from_scale(vec4(1, 2, 3, 4));
expect = mat4x4(vec4(1, 0, 0, 0), vec4(0, 2, 0, 0), vec4(0, 0, 3, 0), vec4(0, 0, 0, 4));
@ -211,9 +211,9 @@ void main()
vec4(0.389669f, 0.647565f, 0.168130f, 0.200000f),
vec4(-0.536231f, 0.330541f, 0.443163f, 0.300000f),
vec4(0.000000f, 0.000000f, 0.000000f, 1.000000f)));
mat4x4 m1 = mat4x4__identity();
mat4x4 m1 = mat4x4_identity();
mat4x4 result;
const float epsilon = 1e-6;
const float epsilon = 2e-5;
result = interpolate_fast(m1, m2, 0.0f);
EXPECT_NEAR(result, m1, epsilon);
result = interpolate_fast(m1, m2, 1.0f);
@ -235,7 +235,7 @@ void main()
const vec3 p = vec3(1, 2, 3);
mat4x4 m4 = from_loc_rot(vec3(10, 0, 0), EulerXYZ(M_PI_2, M_PI_2, M_PI_2));
mat3x3 m3 = from_rotation(EulerXYZ(M_PI_2, M_PI_2, M_PI_2));
mat4x4 pers4 = projection__perspective(-0.1f, 0.1f, -0.1f, 0.1f, -0.1f, -1.0f);
mat4x4 pers4 = projection_perspective(-0.1f, 0.1f, -0.1f, 0.1f, -0.1f, -1.0f);
mat3x3 pers3 = mat3x3(vec3(1, 0, 0.1f), vec3(0, 1, 0.1f), vec3(0, 0.1f, 1));
expect = vec3(13, 2, -1);
@ -264,9 +264,9 @@ void main()
TEST(math_matrix, MatrixProjection)
{
mat4x4 expect;
mat4x4 ortho = projection__orthographic(-0.2f, 0.3f, -0.2f, 0.4f, -0.2f, -0.5f);
mat4x4 pers1 = projection__perspective(-0.2f, 0.3f, -0.2f, 0.4f, -0.2f, -0.5f);
mat4x4 pers2 = projection__perspective_fov(
mat4x4 ortho = projection_orthographic(-0.2f, 0.3f, -0.2f, 0.4f, -0.2f, -0.5f);
mat4x4 pers1 = projection_perspective(-0.2f, 0.3f, -0.2f, 0.4f, -0.2f, -0.5f);
mat4x4 pers2 = projection_perspective_fov(
atan(-0.2f), atan(0.3f), atan(-0.2f), atan(0.4f), -0.2f, -0.5f);
expect = transpose(mat4x4(vec4(4.0f, 0.0f, 0.0f, -0.2f),

View File

@ -375,7 +375,7 @@ typedef struct bNode {
bool is_group_output() const;
const blender::nodes::NodeDeclaration *declaration() const;
/** A span containing all internal links when the node is muted. */
blender::Span<const bNodeLink *> internal_links() const;
blender::Span<bNodeLink> internal_links() const;
/* The following methods are only available when #bNodeTree.ensure_topology_cache has been
* called. */

View File

@ -2377,10 +2377,10 @@ static void rna_Node_parent_set(PointerRNA *ptr,
static void rna_Node_internal_links_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
bNode *node = ptr->data;
bNodeLink **begin;
bNodeLink *begin;
int len;
nodeInternalLinks(node, &begin, &len);
rna_iterator_array_begin(iter, begin, sizeof(bNodeLink *), len, false, NULL);
rna_iterator_array_begin(iter, begin, sizeof(bNodeLink), len, false, NULL);
}
static bool rna_Node_parent_poll(PointerRNA *ptr, PointerRNA value)
@ -12203,7 +12203,7 @@ static void rna_def_node(BlenderRNA *brna)
"rna_Node_internal_links_begin",
"rna_iterator_array_next",
"rna_iterator_array_end",
"rna_iterator_array_dereference_get",
"rna_iterator_array_get",
NULL,
NULL,
NULL,

View File

@ -236,8 +236,8 @@ void DOutputSocket::foreach_target_socket(ForeachTargetSocketFn target_fn,
path_info.sockets.pop_last();
}
else if (linked_node->is_muted()) {
for (const bNodeLink *internal_link : linked_node->internal_links()) {
if (internal_link->fromsock != linked_socket.bsocket()) {
for (const bNodeLink &internal_link : linked_node->internal_links()) {
if (internal_link.fromsock != linked_socket.bsocket()) {
continue;
}
/* The internal link only forwards the first incoming link. */
@ -247,7 +247,7 @@ void DOutputSocket::foreach_target_socket(ForeachTargetSocketFn target_fn,
}
}
const DInputSocket mute_input = linked_socket;
const DOutputSocket mute_output{context_, internal_link->tosock};
const DOutputSocket mute_output{context_, internal_link.tosock};
path_info.sockets.append(mute_input);
path_info.sockets.append(mute_output);
mute_output.foreach_target_socket(target_fn, path_info);

View File

@ -400,9 +400,9 @@ class LazyFunctionForMutedNode : public LazyFunction {
input_by_output_index_.reinitialize(outputs_.size());
input_by_output_index_.fill(-1);
for (const bNodeLink *internal_link : node.internal_links()) {
const int input_i = r_used_inputs.first_index_of_try(internal_link->fromsock);
const int output_i = r_used_outputs.first_index_of_try(internal_link->tosock);
for (const bNodeLink &internal_link : node.internal_links()) {
const int input_i = r_used_inputs.first_index_of_try(internal_link.fromsock);
const int output_i = r_used_outputs.first_index_of_try(internal_link.tosock);
if (ELEM(-1, input_i, output_i)) {
continue;
}
@ -1945,8 +1945,8 @@ struct GeometryNodesLazyFunctionGraphBuilder {
{
/* Find all outputs that use a specific input. */
MultiValueMap<const bNodeSocket *, const bNodeSocket *> outputs_by_input;
for (const bNodeLink *blink : bnode.internal_links()) {
outputs_by_input.add(blink->fromsock, blink->tosock);
for (const bNodeLink &blink : bnode.internal_links()) {
outputs_by_input.add(blink.fromsock, blink.tosock);
}
for (const auto item : outputs_by_input.items()) {
const bNodeSocket &input_bsocket = *item.key;

View File

@ -71,18 +71,18 @@ static void node_init_input_index(bNodeSocket *sock, int *index)
static void node_init_output_index_muted(bNodeSocket *sock,
int *index,
const blender::Span<bNodeLink *> internal_links)
const blender::MutableSpan<bNodeLink> internal_links)
{
bNodeLink *link;
const bNodeLink *link;
/* copy the stack index from internally connected input to skip the node */
for (bNodeLink *iter_link : internal_links) {
if (iter_link->tosock == sock) {
sock->stack_index = iter_link->fromsock->stack_index;
for (bNodeLink &iter_link : internal_links) {
if (iter_link.tosock == sock) {
sock->stack_index = iter_link.fromsock->stack_index;
/* set the link pointer to indicate that this socket
* should not overwrite the stack value!
*/
sock->link = iter_link;
link = iter_link;
sock->link = &iter_link;
link = &iter_link;
break;
}
}

View File

@ -220,12 +220,12 @@ static void refresh_socket_list(bNodeTree &ntree,
link->tosock = new_socket;
}
}
for (bNodeLink *internal_link : node.runtime->internal_links) {
if (internal_link->fromsock == old_socket_with_same_identifier) {
internal_link->fromsock = new_socket;
for (bNodeLink &internal_link : node.runtime->internal_links) {
if (internal_link.fromsock == old_socket_with_same_identifier) {
internal_link.fromsock = new_socket;
}
else if (internal_link->tosock == old_socket_with_same_identifier) {
internal_link->tosock = new_socket;
else if (internal_link.tosock == old_socket_with_same_identifier) {
internal_link.tosock = new_socket;
}
}
}

View File

@ -259,7 +259,7 @@ static void rasterize_half(const MBakeRast *bake_rast,
float x_r = l_stable != 0 ? (s0_l + (((s1_l - s0_l) * (y - t0_l)) / (t1_l - t0_l))) : s0_l;
if (is_mid_right != 0) {
std::swap( x_l, x_r);
std::swap(x_l, x_r);
}
iXl = int(ceilf(x_l));
@ -298,17 +298,17 @@ static void bake_rasterize(const MBakeRast *bake_rast,
/* sort by T */
if (tlo > tmi && tlo > thi) {
std::swap( shi, slo);
std::swap( thi, tlo);
std::swap(shi, slo);
std::swap(thi, tlo);
}
else if (tmi > thi) {
std::swap( shi, smi);
std::swap( thi, tmi);
std::swap(shi, smi);
std::swap(thi, tmi);
}
if (tlo > tmi) {
std::swap( slo, smi);
std::swap( tlo, tmi);
std::swap(slo, smi);
std::swap(tlo, tmi);
}
/* check if mid point is to the left or to the right of the lo-hi edge */

View File

@ -4426,7 +4426,7 @@ static void wm_event_get_keymap_from_toolsystem_ex(wmWindowManager *wm,
if (is_gizmo_visible && !is_gizmo_highlight) {
if (keymap_id_list_len == 2) {
std::swap(keymap_id_list[0], keymap_id_list[1]);
std::swap(keymap_id_list[0], keymap_id_list[1]);
}
}