Compare commits

..

14 Commits

80 changed files with 1149 additions and 2181 deletions

View File

@@ -306,64 +306,6 @@ class NODE_OT_tree_path_parent(Operator):
return {'FINISHED'}
class NODE_OT_active_preview_toggle(Operator):
'''Toggle active preview state of node'''
bl_idname = "node.active_preview_toggle"
bl_label = "Toggle Active Preview"
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
space = context.space_data
if space is None:
return False
if space.type != 'NODE_EDITOR':
return False
if space.edit_tree is None:
return False
if space.edit_tree.nodes.active is None:
return False
return True
def execute(self, context):
node_editor = context.space_data
ntree = node_editor.edit_tree
active_node = ntree.nodes.active
if active_node.active_preview:
self.disable_preview(context, ntree, active_node)
else:
self.enable_preview(context, node_editor, ntree, active_node)
return {'FINISHED'}
def enable_preview(self, context, node_editor, ntree, active_node):
spreadsheets = self.find_unpinned_spreadsheets(context)
for spreadsheet in spreadsheets:
spreadsheet.set_geometry_node_context(node_editor, active_node)
for node in ntree.nodes:
node.active_preview = False
active_node.active_preview = True
def disable_preview(self, context, ntree, active_node):
spreadsheets = self.find_unpinned_spreadsheets(context)
for spreadsheet in spreadsheets:
spreadsheet.context_path.clear()
active_node.active_preview = False
def find_unpinned_spreadsheets(self, context):
spreadsheets = []
for window in context.window_manager.windows:
for area in window.screen.areas:
space = area.spaces.active
if space.type == 'SPREADSHEET' and not space.is_pinned:
spreadsheets.append(space)
return spreadsheets
classes = (
NodeSetting,
@@ -372,5 +314,4 @@ classes = (
NODE_OT_add_search,
NODE_OT_collapse_hide_unused_toggle,
NODE_OT_tree_path_parent,
NODE_OT_active_preview_toggle,
)

View File

@@ -56,7 +56,7 @@ class SPREADSHEET_OT_toggle_pin(Operator):
for node_editor in node_editors:
ntree = node_editor.edit_tree
for node in ntree.nodes:
if node.active_preview:
if node.bl_idname == "GeometryNodeViewer":
space.set_geometry_node_context(node_editor, node)
return

View File

@@ -5035,10 +5035,6 @@ class VIEW3D_MT_edit_gpencil_stroke(Menu):
layout.operator("gpencil.stroke_flip", text="Switch Direction")
layout.prop(settings, "use_scale_thickness", text="Scale Thickness")
layout.separator()
layout.operator("gpencil.stroke_normalize", text="Normalize Thickness").mode = 'THICKNESS'
layout.operator("gpencil.stroke_normalize", text="Normalize Opacity").mode = 'OPACITY'
layout.separator()
layout.operator("gpencil.reset_transform_fill", text="Reset Fill Transform")

View File

@@ -566,6 +566,9 @@ geometry_node_categories = [
NodeItem("ShaderNodeVectorMath"),
NodeItem("ShaderNodeVectorRotate"),
]),
GeometryNodeCategory("GEO_OUTPUT", "Output", items=[
NodeItem("GeometryNodeViewer"),
]),
GeometryNodeCategory("GEO_VOLUME", "Volume", items=[
NodeItem("GeometryNodePointsToVolume"),
NodeItem("GeometryNodeVolumeToMesh"),

View File

@@ -333,21 +333,6 @@ class CustomDataAttributes {
void reallocate(const int size);
std::optional<blender::fn::GSpan> get_for_read(const blender::StringRef name) const;
blender::fn::GVArrayPtr get_for_read(const StringRef name,
const CustomDataType data_type,
const void *default_value) const;
template<typename T>
blender::fn::GVArray_Typed<T> get_for_read(const blender::StringRef name,
const T &default_value) const
{
const blender::fn::CPPType &cpp_type = blender::fn::CPPType::get<T>();
const CustomDataType type = blender::bke::cpp_type_to_custom_data_type(cpp_type);
GVArrayPtr varray = this->get_for_read(name, type, &default_value);
return blender::fn::GVArray_Typed<T>(std::move(varray));
}
std::optional<blender::fn::GMutableSpan> get_for_write(const blender::StringRef name);
bool create(const blender::StringRef name, const CustomDataType data_type);
bool create_by_move(const blender::StringRef name, const CustomDataType data_type, void *buffer);

View File

@@ -33,7 +33,6 @@ extern "C" {
struct BMLoop;
struct BMesh;
struct BMesh_PartialInfo;
struct BoundBox;
struct Depsgraph;
struct Mesh;
@@ -86,8 +85,6 @@ typedef struct BMEditMesh {
/* editmesh.c */
void BKE_editmesh_looptri_calc(BMEditMesh *em);
void BKE_editmesh_looptri_calc_with_partial(BMEditMesh *em, struct BMesh_PartialInfo *bmpinfo);
BMEditMesh *BKE_editmesh_create(BMesh *bm, const bool do_tessellate);
BMEditMesh *BKE_editmesh_copy(BMEditMesh *em);
BMEditMesh *BKE_editmesh_from_object(struct Object *ob);

View File

@@ -1431,6 +1431,7 @@ int ntreeTexExecTree(struct bNodeTree *ntree,
#define GEO_NODE_MATERIAL_REPLACE 1051
#define GEO_NODE_MESH_TO_CURVE 1052
#define GEO_NODE_DELETE_GEOMETRY 1053
#define GEO_NODE_VIEWER 1054
/** \} */

View File

@@ -101,14 +101,15 @@ class Spline {
Spline(const Type type) : type_(type)
{
}
Spline(Spline &other) : attributes(other.attributes), type_(other.type_)
Spline(Spline &other)
: normal_mode(other.normal_mode),
attributes(other.attributes),
type_(other.type_),
is_cyclic_(other.is_cyclic_)
{
copy_base_settings(other, *this);
}
virtual SplinePtr copy() const = 0;
/** Return a new spline with the same type and settings like "cyclic", but without any data. */
virtual SplinePtr copy_settings() const = 0;
Spline::Type type() const;
@@ -182,12 +183,6 @@ class Spline {
protected:
virtual void correct_end_tangents() const = 0;
/** Copy settings stored in the base spline class. */
static void copy_base_settings(const Spline &src, Spline &dst)
{
dst.normal_mode = src.normal_mode;
dst.is_cyclic_ = src.is_cyclic_;
}
};
/**
@@ -241,7 +236,6 @@ class BezierSpline final : public Spline {
public:
virtual SplinePtr copy() const final;
SplinePtr copy_settings() const final;
BezierSpline() : Spline(Type::Bezier)
{
}
@@ -383,7 +377,6 @@ class NURBSpline final : public Spline {
public:
SplinePtr copy() const final;
SplinePtr copy_settings() const final;
NURBSpline() : Spline(Type::NURBS)
{
}
@@ -451,7 +444,6 @@ class PolySpline final : public Spline {
public:
SplinePtr copy() const final;
SplinePtr copy_settings() const final;
PolySpline() : Spline(Type::Poly)
{
}

View File

@@ -46,8 +46,6 @@ using blender::StringRef;
using blender::StringRefNull;
using blender::fn::GMutableSpan;
using blender::fn::GSpan;
using blender::fn::GVArray_For_GSpan;
using blender::fn::GVArray_For_SingleValue;
namespace blender::bke {
@@ -630,32 +628,6 @@ std::optional<GSpan> CustomDataAttributes::get_for_read(const StringRef name) co
return {};
}
/**
* Return a virtual array for a stored attribute, or a single value virtual array with the default
* value if the attribute doesn't exist. If no default value is provided, the default value for the
* type will be used.
*/
GVArrayPtr CustomDataAttributes::get_for_read(const StringRef name,
const CustomDataType data_type,
const void *default_value) const
{
const CPPType *type = blender::bke::custom_data_type_to_cpp_type(data_type);
std::optional<GSpan> attribute = this->get_for_read(name);
if (!attribute) {
const int domain_size = this->size_;
return std::make_unique<GVArray_For_SingleValue>(
*type, domain_size, (default_value == nullptr) ? type->default_value() : default_value);
}
if (attribute->type() == *type) {
return std::make_unique<GVArray_For_GSpan>(*attribute);
}
const blender::nodes::DataTypeConversions &conversions =
blender::nodes::get_implicit_type_conversions();
return conversions.try_convert(std::make_unique<GVArray_For_GSpan>(*attribute), *type);
}
std::optional<GMutableSpan> CustomDataAttributes::get_for_write(const StringRef name)
{
BLI_assert(size_ != 0);

View File

@@ -149,14 +149,6 @@ void BKE_editmesh_looptri_calc(BMEditMesh *em)
#endif
}
void BKE_editmesh_looptri_calc_with_partial(BMEditMesh *em, struct BMesh_PartialInfo *bmpinfo)
{
BLI_assert(em->tottri == poly_to_tri_count(em->bm->totface, em->bm->totloop));
/* after allocating the em->looptris, we're ready to tessellate */
BM_mesh_calc_tessellation_with_partial(em->bm, em->looptris, bmpinfo);
}
void BKE_editmesh_free_derivedmesh(BMEditMesh *em)
{
if (em->mesh_eval_cage) {

View File

@@ -1559,7 +1559,8 @@ void BKE_fcurve_correct_bezpart(const float v1[2], float v2[2], float v3[2], con
}
/**
* Find roots of cubic equation (c0 x^3 + c1 x^2 + c2 x + c3)
.
* Find roots of cubic equation (c0 x³ + c1 x² + c2 x + c3)
* \return number of roots in `o`.
*
* \note it is up to the caller to allocate enough memory for `o`.

View File

@@ -3147,8 +3147,8 @@ void ntreeSetOutput(bNodeTree *ntree)
if (ntree->type == NTREE_COMPOSIT) {
/* same type, exception for viewer */
if (tnode->type == node->type ||
(ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER) &&
ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))) {
(ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER, GEO_NODE_VIEWER) &&
ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER, GEO_NODE_VIEWER))) {
if (tnode->flag & NODE_DO_OUTPUT) {
output++;
if (output > 1) {
@@ -5082,6 +5082,7 @@ static void registerGeometryNodes()
register_node_type_geo_switch();
register_node_type_geo_transform();
register_node_type_geo_triangulate();
register_node_type_geo_viewer();
register_node_type_geo_volume_to_mesh();
}

View File

@@ -31,14 +31,6 @@ SplinePtr BezierSpline::copy() const
return std::make_unique<BezierSpline>(*this);
}
SplinePtr BezierSpline::copy_settings() const
{
std::unique_ptr<BezierSpline> copy = std::make_unique<BezierSpline>();
copy_base_settings(*this, *copy);
copy->resolution_ = resolution_;
return copy;
}
int BezierSpline::size() const
{
const int size = positions_.size();

View File

@@ -32,16 +32,6 @@ SplinePtr NURBSpline::copy() const
return std::make_unique<NURBSpline>(*this);
}
SplinePtr NURBSpline::copy_settings() const
{
std::unique_ptr<NURBSpline> copy = std::make_unique<NURBSpline>();
copy_base_settings(*this, *copy);
copy->knots_mode = knots_mode;
copy->resolution_ = resolution_;
copy->order_ = order_;
return copy;
}
int NURBSpline::size() const
{
const int size = positions_.size();

View File

@@ -28,13 +28,6 @@ SplinePtr PolySpline::copy() const
return std::make_unique<PolySpline>(*this);
}
SplinePtr PolySpline::copy_settings() const
{
std::unique_ptr<PolySpline> copy = std::make_unique<PolySpline>();
copy_base_settings(*this, *copy);
return copy;
}
int PolySpline::size() const
{
const int size = positions_.size();

View File

@@ -729,12 +729,6 @@ static AVStream *alloc_video_stream(FFMpegContext *context,
}
}
/* Use 4:4:4 instead of 4:2:0 pixel format for lossless rendering. */
if ((codec_id == AV_CODEC_ID_H264 || codec_id == AV_CODEC_ID_VP9) &&
context->ffmpeg_crf == 0) {
c->pix_fmt = AV_PIX_FMT_YUV444P;
}
if (codec_id == AV_CODEC_ID_PNG) {
if (rd->im_format.planes == R_IMF_PLANES_RGBA) {
c->pix_fmt = AV_PIX_FMT_RGBA;

View File

@@ -110,7 +110,7 @@ class IndexMask {
}
/**
* Returns the n-th index referenced by this IndexMask. The `index_range` method returns an
* Returns the n-th index referenced by this IndexMask. The `index_mask` method returns an
* IndexRange containing all indices that can be used as parameter here.
*/
int64_t operator[](int64_t n) const

View File

@@ -161,7 +161,7 @@ class Vector {
}
/**
* Create a vector from a span. The values in the vector are copy constructed.
* Create a vector from an array ref. The values in the vector are copy constructed.
*/
template<typename U, typename std::enable_if_t<std::is_convertible_v<U, T>> * = nullptr>
Vector(Span<U> values, Allocator allocator = {}) : Vector(NoExceptConstructor(), allocator)

View File

@@ -149,9 +149,11 @@ class TriMeshTopology : NonCopyable {
* Else return NO_INDEX. */
int other_tri_if_manifold(Edge e, int t) const
{
auto p = edge_tri_.lookup_ptr(e);
if (p != nullptr && (*p)->size() == 2) {
return ((**p)[0] == t) ? (**p)[1] : (**p)[0];
if (edge_tri_.contains(e)) {
auto *p = edge_tri_.lookup(e);
if (p->size() == 2) {
return ((*p)[0] == t) ? (*p)[1] : (*p)[0];
}
}
return NO_INDEX;
}
@@ -1827,19 +1829,6 @@ static mpq_class closest_on_tri_to_point(const mpq3 &p,
return mpq3::distance_squared_with_buffer(p, r, m);
}
static float closest_on_tri_to_point_float_dist_squared(const float3 &p,
const double3 &a,
const double3 &b,
const double3 &c)
{
float3 fa, fb, fc, closest;
copy_v3fl_v3db(fa, a);
copy_v3fl_v3db(fb, b);
copy_v3fl_v3db(fc, c);
closest_on_tri_to_point_v3(closest, p, fa, fb, fc);
return len_squared_v3v3(p, closest);
}
struct ComponentContainer {
int containing_component{NO_INDEX};
int nearest_cell{NO_INDEX};
@@ -1876,8 +1865,6 @@ static Vector<ComponentContainer> find_component_containers(int comp,
if (dbg_level > 0) {
std::cout << "test vertex in comp: " << test_v << "\n";
}
const double3 &test_v_d = test_v->co;
float3 test_v_f(test_v_d[0], test_v_d[1], test_v_d[2]);
mpq3 buf[7];
@@ -1892,7 +1879,6 @@ static Vector<ComponentContainer> find_component_containers(int comp,
int nearest_tri_close_vert = -1;
int nearest_tri_close_edge = -1;
mpq_class nearest_tri_dist_squared;
float nearest_tri_dist_squared_float = FLT_MAX;
for (int p : components[comp_other]) {
const Patch &patch = pinfo.patch(p);
for (int t : patch.tris()) {
@@ -1902,12 +1888,6 @@ static Vector<ComponentContainer> find_component_containers(int comp,
}
int close_vert;
int close_edge;
/* Try a cheap float test first. */
float d2_f = closest_on_tri_to_point_float_dist_squared(
test_v_f, tri[0]->co, tri[1]->co, tri[2]->co);
if (d2_f - FLT_EPSILON > nearest_tri_dist_squared_float) {
continue;
}
mpq_class d2 = closest_on_tri_to_point(test_v->co_exact,
tri[0]->co_exact,
tri[1]->co_exact,
@@ -1930,7 +1910,6 @@ static Vector<ComponentContainer> find_component_containers(int comp,
nearest_tri_close_edge = close_edge;
nearest_tri_close_vert = close_vert;
nearest_tri_dist_squared = d2;
nearest_tri_dist_squared_float = d2_f;
}
}
}
@@ -3334,13 +3313,9 @@ static IMesh polymesh_from_trimesh_with_dissolve(const IMesh &tm_out,
std::cout << "\nPOLYMESH_FROM_TRIMESH_WITH_DISSOLVE\n";
}
/* For now: need plane normals for all triangles. */
const int grainsize = 1024;
parallel_for(tm_out.face_index_range(), grainsize, [&](IndexRange range) {
for (int i : range) {
Face *tri = tm_out.face(i);
tri->populate_plane(false);
}
});
for (Face *tri : tm_out.faces()) {
tri->populate_plane(false);
}
/* Gather all output triangles that are part of each input face.
* face_output_tris[f] will be indices of triangles in tm_out
* that have f as their original face. */

View File

@@ -104,8 +104,6 @@ set(SRC
intern/bmesh_mesh_duplicate.h
intern/bmesh_mesh_tessellate.c
intern/bmesh_mesh_tessellate.h
intern/bmesh_mesh_partial.c
intern/bmesh_mesh_partial.h
intern/bmesh_mesh_validate.c
intern/bmesh_mesh_validate.h
intern/bmesh_mods.c

View File

@@ -40,7 +40,6 @@
#include "atomic_ops.h"
#include "intern/bmesh_mesh_partial.h"
#include "intern/bmesh_private.h"
/* used as an extern, defined in bmesh.h */
@@ -374,16 +373,15 @@ typedef struct BMVertsCalcNormalsData {
float (*vnos)[3];
} BMVertsCalcNormalsData;
static void mesh_verts_calc_normals_accum(
BMFace *f,
const float *f_no,
const float (*edgevec)[3],
/* Read-write data, protected by an atomic-based fake spin-lock like system. */
float (*vnos)[3])
static void mesh_verts_calc_normals_accum_cb(void *userdata, MempoolIterData *mp_f)
{
#define FLT_EQ_NONAN(_fa, _fb) (*((const uint32_t *)&_fa) == *((const uint32_t *)&_fb))
BMVertsCalcNormalsData *data = userdata;
BMFace *f = (BMFace *)mp_f;
const float *f_no = data->fnos ? data->fnos[BM_elem_index_get(f)] : f->no;
BMLoop *l_first, *l_iter;
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
do {
@@ -393,8 +391,8 @@ static void mesh_verts_calc_normals_accum(
/* calculate the dot product of the two edges that
* meet at the loop's vertex */
e1diff = edgevec[BM_elem_index_get(l_iter->prev->e)];
e2diff = edgevec[BM_elem_index_get(l_iter->e)];
e1diff = data->edgevec[BM_elem_index_get(l_iter->prev->e)];
e2diff = data->edgevec[BM_elem_index_get(l_iter->e)];
dotprod = dot_v3v3(e1diff, e2diff);
/* edge vectors are calculated from e->v1 to e->v2, so
@@ -412,7 +410,7 @@ static void mesh_verts_calc_normals_accum(
}
/* accumulate weighted face normal into the vertex's normal */
float *v_no = vnos ? vnos[BM_elem_index_get(l_iter->v)] : l_iter->v->no;
float *v_no = data->vnos ? data->vnos[BM_elem_index_get(l_iter->v)] : l_iter->v->no;
/* This block is a lockless threadsafe madd_v3_v3fl.
* It uses the first float of the vector as a sort of cheap spin-lock,
@@ -449,14 +447,6 @@ static void mesh_verts_calc_normals_accum(
#undef FLT_EQ_NONAN
}
static void mesh_verts_calc_normals_accum_cb(void *userdata, MempoolIterData *mp_f)
{
BMVertsCalcNormalsData *data = userdata;
BMFace *f = (BMFace *)mp_f;
const float *f_no = data->fnos ? data->fnos[BM_elem_index_get(f)] : f->no;
mesh_verts_calc_normals_accum(f, f_no, data->edgevec, data->vnos);
}
static void mesh_verts_calc_normals_normalize_cb(void *userdata, MempoolIterData *mp_v)
{
BMVertsCalcNormalsData *data = userdata;
@@ -502,6 +492,11 @@ static void mesh_faces_calc_normals_cb(void *UNUSED(userdata), MempoolIterData *
BM_face_normal_update(f);
}
/**
* \brief BMesh Compute Normals
*
* Updates the normals of a mesh.
*/
void BM_mesh_normals_update(BMesh *bm)
{
float(*edgevec)[3] = MEM_mallocN(sizeof(*edgevec) * bm->totedge, __func__);
@@ -534,111 +529,6 @@ void BM_mesh_normals_update(BMesh *bm)
MEM_freeN(edgevec);
}
static void mesh_faces_parallel_range_calc_normals_cb(
void *userdata, const int iter, const TaskParallelTLS *__restrict UNUSED(tls))
{
BMFace *f = ((BMFace **)userdata)[iter];
BM_face_normal_update(f);
}
static void mesh_edges_parallel_range_calc_vectors_cb(
void *userdata, const int iter, const TaskParallelTLS *__restrict UNUSED(tls))
{
BMEdge *e = ((BMEdge **)((void **)userdata)[0])[iter];
float *r_edgevec = ((float(*)[3])((void **)userdata)[1])[iter];
sub_v3_v3v3(r_edgevec, e->v1->co, e->v2->co);
normalize_v3(r_edgevec);
}
static void mesh_verts_parallel_range_calc_normals_accum_cb(
void *userdata, const int iter, const TaskParallelTLS *__restrict UNUSED(tls))
{
BMFace *f = ((BMFace **)((void **)userdata)[0])[iter];
const float(*edgevec)[3] = (float(*)[3])((void **)userdata)[1];
mesh_verts_calc_normals_accum(f, f->no, edgevec, NULL);
}
static void mesh_verts_parallel_range_calc_normals_normalize_cb(
void *userdata, const int iter, const TaskParallelTLS *__restrict UNUSED(tls))
{
BMVert *v = ((BMVert **)userdata)[iter];
if (UNLIKELY(normalize_v3(v->no) == 0.0f)) {
normalize_v3_v3(v->no, v->co);
}
}
void BM_mesh_normals_update_with_partial(BMesh *bm, struct BMesh_PartialInfo *bmpinfo)
{
BMVert **verts = bmpinfo->verts;
BMEdge **edges = bmpinfo->edges;
BMFace **faces = bmpinfo->faces;
const int verts_len = bmpinfo->verts_len;
const int edges_len = bmpinfo->edges_len;
const int faces_len = bmpinfo->faces_len;
float(*edgevec)[3] = MEM_mallocN(sizeof(*edgevec) * edges_len, __func__);
for (int i = 0; i < verts_len; i++) {
zero_v3(verts[i]->no);
}
TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
{
/* Faces. */
BLI_task_parallel_range(
0, faces_len, faces, mesh_faces_parallel_range_calc_normals_cb, &settings);
}
int *edge_index_value = NULL;
if ((bm->elem_index_dirty & BM_EDGE) == 0) {
edge_index_value = MEM_mallocN(sizeof(*edge_index_value) * edges_len, __func__);
for (int i = 0; i < edges_len; i++) {
BMEdge *e = edges[i];
edge_index_value[i] = BM_elem_index_get(e);
BM_elem_index_set(e, i); /* et_dirty! (restore before this function exits). */
}
}
else {
for (int i = 0; i < edges_len; i++) {
BMEdge *e = edges[i];
BM_elem_index_set(e, i); /* set_dirty! (already dirty) */
}
}
{
/* Verts. */
/* Compute normalized direction vectors for each edge.
* Directions will be used for calculating the weights of the face normals on the vertex
* normals. */
void *data[2] = {edges, edgevec};
BLI_task_parallel_range(
0, edges_len, data, mesh_edges_parallel_range_calc_vectors_cb, &settings);
/* Add weighted face normals to vertices. */
data[0] = faces;
BLI_task_parallel_range(
0, faces_len, data, mesh_verts_parallel_range_calc_normals_accum_cb, &settings);
/* Normalize the accumulated vertex normals. */
BLI_task_parallel_range(
0, verts_len, verts, mesh_verts_parallel_range_calc_normals_normalize_cb, &settings);
}
if (edge_index_value != NULL) {
for (int i = 0; i < edges_len; i++) {
BMEdge *e = edges[i];
BM_elem_index_set(e, edge_index_value[i]); /* set_ok (restore) */
}
MEM_freeN(edge_index_value);
}
MEM_freeN(edgevec);
}
/**
* \brief BMesh Compute Normals from/to external data.
*
@@ -1834,7 +1724,7 @@ static int bm_loop_normal_mark_indiv(BMesh *bm, BLI_bitmap *loops, const bool do
if (use_sel_face_history) {
/* Using face history allows to select a single loop from a single face...
* Note that this is O(n^2) piece of code,
* Note that this is O piece of code,
* but it is not designed to be used with huge selection sets,
* rather with only a few items selected at most.*/
/* Goes from last selected to the first selected element. */

View File

@@ -25,7 +25,6 @@
struct BMAllocTemplate;
struct BMLoopNorEditDataArray;
struct MLoopNorSpaceArray;
struct BMesh_PartialInfo;
void BM_mesh_elem_toolflags_ensure(BMesh *bm);
void BM_mesh_elem_toolflags_clear(BMesh *bm);
@@ -42,8 +41,6 @@ void BM_mesh_data_free(BMesh *bm);
void BM_mesh_clear(BMesh *bm);
void BM_mesh_normals_update(BMesh *bm);
void BM_mesh_normals_update_with_partial(BMesh *bm, struct BMesh_PartialInfo *bmpinfo);
void BM_verts_calc_normal_vcos(BMesh *bm,
const float (*fnos)[3],
const float (*vcos)[3],

View File

@@ -1,168 +0,0 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/** \file
* \ingroup bmesh
*
* Duplicate geometry from one mesh from another.
*/
#include "DNA_object_types.h"
#include "MEM_guardedalloc.h"
#include "BLI_alloca.h"
#include "BLI_bitmap.h"
#include "BLI_math_vector.h"
#include "bmesh.h"
#include "intern/bmesh_mesh_partial.h"
#include "intern/bmesh_private.h" /* for element checking */
/* Grow by 1.5x (rounding up). */
#define GROW(len_alloc) ((len_alloc) + ((len_alloc) - ((len_alloc) / 2)))
#define GROW_ARRAY(mem, len_alloc) \
{ \
mem = MEM_reallocN(mem, (sizeof(*mem)) * ((len_alloc) = GROW(len_alloc))); \
} \
((void)0)
#define MAYBE_GROW_ARRAY(mem, len_alloc, index) \
if (UNLIKELY(len_alloc == index)) { \
GROW_ARRAY(mem, len_alloc); \
}
BLI_INLINE bool partial_elem_ensure_vert(struct BMesh_PartialInfo *bmpinfo, BMVert *v)
{
const int i = BM_elem_index_get(v);
if (!BLI_BITMAP_TEST(bmpinfo->verts_tag, i)) {
BLI_BITMAP_ENABLE(bmpinfo->verts_tag, i);
MAYBE_GROW_ARRAY(bmpinfo->verts, bmpinfo->verts_len_alloc, bmpinfo->verts_len);
bmpinfo->verts[bmpinfo->verts_len++] = v;
return true;
}
return false;
}
BLI_INLINE bool partial_elem_ensure_edge(struct BMesh_PartialInfo *bmpinfo, BMEdge *e)
{
const int i = BM_elem_index_get(e);
if (!BLI_BITMAP_TEST(bmpinfo->edges_tag, i)) {
BLI_BITMAP_ENABLE(bmpinfo->edges_tag, i);
MAYBE_GROW_ARRAY(bmpinfo->edges, bmpinfo->edges_len_alloc, bmpinfo->edges_len);
bmpinfo->edges[bmpinfo->edges_len++] = e;
return true;
}
return false;
}
BLI_INLINE bool partial_elem_ensure_face(struct BMesh_PartialInfo *bmpinfo, BMFace *f)
{
const int i = BM_elem_index_get(f);
if (!BLI_BITMAP_TEST(bmpinfo->faces_tag, i)) {
BLI_BITMAP_ENABLE(bmpinfo->faces_tag, i);
MAYBE_GROW_ARRAY(bmpinfo->faces, bmpinfo->faces_len_alloc, bmpinfo->faces_len);
bmpinfo->faces[bmpinfo->faces_len++] = f;
return true;
}
return false;
}
struct BMesh_PartialInfo *BM_mesh_partial_info_create_from_verts(
BMesh *bm, const int verts_len, bool (*filter_fn)(BMVert *, void *user_data), void *user_data)
{
struct BMesh_PartialInfo *bmpinfo = MEM_callocN(sizeof(*bmpinfo), __func__);
bmpinfo->verts_len_alloc = verts_len;
bmpinfo->verts = MEM_mallocN((sizeof(BMVert *) * verts_len), __func__);
bmpinfo->edges_len_alloc = verts_len;
bmpinfo->edges = MEM_mallocN((sizeof(BMEdge *) * bmpinfo->edges_len_alloc), __func__);
bmpinfo->faces_len_alloc = verts_len;
bmpinfo->faces = MEM_mallocN((sizeof(BMFace *) * bmpinfo->faces_len_alloc), __func__);
bmpinfo->verts_tag = BLI_BITMAP_NEW((size_t)bm->totvert, __func__);
bmpinfo->edges_tag = BLI_BITMAP_NEW((size_t)bm->totedge, __func__);
bmpinfo->faces_tag = BLI_BITMAP_NEW((size_t)bm->totface, __func__);
/* Set vert inline. */
BM_mesh_elem_index_ensure(bm, (BM_EDGE | BM_FACE));
{
BMVert *v;
BMIter iter;
int i;
BM_ITER_MESH_INDEX (v, &iter, bm, BM_VERTS_OF_MESH, i) {
BM_elem_index_set(v, i); /* set_inline */
if (!filter_fn(v, user_data)) {
continue;
}
BMEdge *e_iter = v->e;
if (e_iter != NULL) {
/* Loop over edges. */
BMEdge *e_first = v->e;
do {
BMLoop *l_iter = e_iter->l;
if (e_iter->l != NULL) {
BMLoop *l_first = e_iter->l;
/* Loop over radial loops. */
do {
if (l_iter->v == v) {
partial_elem_ensure_face(bmpinfo, l_iter->f);
}
} while ((l_iter = l_iter->radial_next) != l_first);
}
} while ((e_iter = bmesh_disk_edge_next(e_iter, v)) != e_first);
}
}
}
for (int i = 0; i < bmpinfo->faces_len; i++) {
BMFace *f = bmpinfo->faces[i];
BMLoop *l_iter, *l_first;
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
do {
if (!partial_elem_ensure_vert(bmpinfo, l_iter->v)) {
continue;
}
BMVert *v = l_iter->v;
BMEdge *e_first = v->e;
BMEdge *e_iter = e_first;
do {
if (e_iter->l) {
partial_elem_ensure_edge(bmpinfo, e_iter);
}
} while ((e_iter = bmesh_disk_edge_next(e_iter, v)) != e_first);
} while ((l_iter = l_iter->next) != l_first);
/* End indirect loop. */
}
MEM_freeN(bmpinfo->verts_tag);
MEM_freeN(bmpinfo->edges_tag);
MEM_freeN(bmpinfo->faces_tag);
return bmpinfo;
}
void BM_mesh_partial_info_destroy(struct BMesh_PartialInfo *bmpinfo)
{
MEM_freeN(bmpinfo->verts);
MEM_freeN(bmpinfo->edges);
MEM_freeN(bmpinfo->faces);
MEM_freeN(bmpinfo);
}

View File

@@ -36,8 +36,6 @@
#include "bmesh.h"
#include "bmesh_tools.h"
#include "intern/bmesh_mesh_partial.h"
/* -------------------------------------------------------------------- */
/** \name Default Mesh Tessellation
* \{ */
@@ -153,32 +151,6 @@ void BM_mesh_calc_tessellation(BMesh *bm, BMLoop *(*looptris)[3])
/** \} */
void BM_mesh_calc_tessellation_with_partial(BMesh *bm,
BMLoop *(*looptris)[3],
struct BMesh_PartialInfo *bmpinfo)
{
const int faces_len = bmpinfo->faces_len;
BMFace **faces = bmpinfo->faces;
MemArena *pf_arena = NULL;
/* This could potentially cause a lot of excessive looping. */
BM_mesh_elem_index_ensure(bm, BM_LOOP | BM_FACE);
for (int index = 0; index < faces_len; index++) {
BMFace *f = faces[index];
BMLoop *l = BM_FACE_FIRST_LOOP(faces[index]);
const int offset = BM_elem_index_get(l) - (BM_elem_index_get(f) * 2);
mesh_calc_tessellation_for_face(looptris + offset, faces[index], &pf_arena);
}
if (pf_arena) {
BLI_memarena_free(pf_arena);
pf_arena = NULL;
}
}
/* -------------------------------------------------------------------- */
/** \name Beauty Mesh Tessellation
*

View File

@@ -22,7 +22,3 @@
void BM_mesh_calc_tessellation(BMesh *bm, BMLoop *(*looptris)[3]);
void BM_mesh_calc_tessellation_beauty(BMesh *bm, BMLoop *(*looptris)[3]);
void BM_mesh_calc_tessellation_with_partial(BMesh *bm,
BMLoop *(*looptris)[3],
struct BMesh_PartialInfo *bmpinfo);

View File

@@ -21,7 +21,6 @@
*/
struct Heap;
struct BMesh_PartialInfo;
#include "BLI_compiler_attrs.h"

View File

@@ -96,7 +96,7 @@ static float light_shape_power_get(const Light *la, const EEVEE_Light *evli)
}
}
else if (ELEM(la->type, LA_SPOT, LA_LOCAL)) {
power = 1.0f / (4.0f * evli->radius * evli->radius * M_PI * M_PI); /* `1/(4*(r^2)*(Pi^2))` */
power = 1.0f / (4.0f * evli->radius * evli->radius * M_PI * M_PI); /* 1/(4*r²*Pi²) */
/* for point lights (a.k.a radius == 0.0) */
// power = M_PI * M_PI * 0.78; /* XXX : Empirical, Fit cycles power */
@@ -106,7 +106,7 @@ static float light_shape_power_get(const Light *la, const EEVEE_Light *evli)
/* Make illumination power closer to cycles for bigger radii. Cycles uses a cos^3 term that we
* cannot reproduce so we account for that by scaling the light power. This function is the
* result of a rough manual fitting. */
power += 1.0f / (2.0f * M_PI); /* `power *= 1 + (r^2)/2` */
power += 1.0f / (2.0f * M_PI); /* power *= 1 + /2 */
}
return power;
}
@@ -257,7 +257,7 @@ void EEVEE_lights_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
float power = max_fff(UNPACK3(evli->color)) * evli->volume;
if (power > 0.0f && evli->light_type != LA_SUN) {
/* The limit of the power attenuation function when the distance to the light goes to 0 is
* `2 / r^2` where r is the light radius. We need to find the right radius that emits at most
* 2 / r² where r is the light radius. We need to find the right radius that emits at most
* the volume light upper bound. Inverting the function we get: */
float min_radius = 1.0f / sqrtf(0.5f * upper_bound / power);
/* Square it here to avoid a multiplication inside the shader. */

View File

@@ -79,7 +79,7 @@ bool EEVEE_renderpasses_only_first_sample_pass_active(EEVEE_Data *vedata)
* type the rest of the bits are used for the name hash. */
int EEVEE_renderpasses_aov_hash(const ViewLayerAOV *aov)
{
int hash = BLI_hash_string(aov->name) << 1;
int hash = BLI_hash_string(aov->name);
SET_FLAG_FROM_TEST(hash, aov->type == AOV_TYPE_COLOR, EEVEE_AOV_HASH_COLOR_TYPE_MASK);
return hash;
}

View File

@@ -369,6 +369,9 @@ BLI_INLINE void extract_run_and_finish_init(const MeshRenderData *mr,
/** \name ExtractTaskData
* \{ */
struct ExtractTaskData {
void *next = nullptr;
void *prev = nullptr;
const MeshRenderData *mr = nullptr;
MeshBatchCache *cache = nullptr;
/* #UserData is shared between the iterations as it holds counters to detect if the
@@ -866,7 +869,7 @@ static void mesh_buffer_cache_create_requested(struct TaskGraph *task_graph,
const bool use_thread = (mr->loop_len + mr->loop_loose_len) > CHUNK_SIZE;
if (use_thread) {
uint single_threaded_extractors_len = 0;
uint threads_to_use = 0;
/* First run the requested extractors that do not support asynchronous ranges. */
for (const ExtractorRunData &run_data : extractors) {
@@ -879,8 +882,8 @@ static void mesh_buffer_cache_create_requested(struct TaskGraph *task_graph,
struct TaskNode *task_node = extract_single_threaded_task_node_create(task_graph,
taskdata);
BLI_task_graph_edge_create(task_node_mesh_render_data, task_node);
single_threaded_extractors_len++;
}
threads_to_use++;
}
/* Distribute the remaining extractors into ranges per core. */
@@ -893,7 +896,9 @@ static void mesh_buffer_cache_create_requested(struct TaskGraph *task_graph,
* fill the rest of the threads for range operations.
*/
int num_threads = BLI_task_scheduler_num_threads();
num_threads -= single_threaded_extractors_len % num_threads;
if (threads_to_use < num_threads) {
num_threads -= threads_to_use;
}
UserDataInitTaskData *user_data_init_task_data = new UserDataInitTaskData();
struct TaskNode *task_node_user_data_init = user_data_init_task_node_create(

View File

@@ -454,7 +454,8 @@ MeshRenderData *mesh_render_data_create(Mesh *me,
const ToolSettings *ts,
const eMRIterType iter_type);
void mesh_render_data_free(MeshRenderData *mr);
void mesh_render_data_update_normals(MeshRenderData *mr, const eMRDataType data_flag);
void mesh_render_data_update_normals(MeshRenderData *mr,
const eMRDataType data_flag);
void mesh_render_data_update_looptris(MeshRenderData *mr,
const eMRIterType iter_type,
const eMRDataType data_flag);

View File

@@ -150,7 +150,8 @@ void mesh_render_data_update_looptris(MeshRenderData *mr,
}
}
void mesh_render_data_update_normals(MeshRenderData *mr, const eMRDataType data_flag)
void mesh_render_data_update_normals(MeshRenderData *mr,
const eMRDataType data_flag)
{
Mesh *me = mr->me;
const bool is_auto_smooth = (me->flag & ME_AUTOSMOOTH) != 0;

View File

@@ -5347,181 +5347,3 @@ void GPENCIL_OT_stroke_merge_by_distance(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Stroke Normalize Operator
* \{ */
typedef enum eGP_NormalizeMode {
GP_NORMALIZE_THICKNESS = 0,
GP_NORMALIZE_OPACITY,
} eGP_NormalizeMode;
static bool gpencil_stroke_normalize_poll(bContext *C)
{
Object *ob = CTX_data_active_object(C);
if ((ob == NULL) || (ob->type != OB_GPENCIL)) {
return false;
}
bGPdata *gpd = (bGPdata *)ob->data;
if (gpd == NULL) {
return false;
}
bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd);
return ((gpl != NULL) && (ob->mode == OB_MODE_EDIT_GPENCIL));
}
static void gpencil_stroke_normalize_ui(bContext *UNUSED(C), wmOperator *op)
{
uiLayout *layout = op->layout;
uiLayout *row;
const eGP_NormalizeMode mode = RNA_enum_get(op->ptr, "mode");
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
row = uiLayoutRow(layout, true);
uiItemR(row, op->ptr, "mode", 0, NULL, ICON_NONE);
if (mode == GP_NORMALIZE_THICKNESS) {
row = uiLayoutRow(layout, true);
uiItemR(row, op->ptr, "value", 0, NULL, ICON_NONE);
}
else if (mode == GP_NORMALIZE_OPACITY) {
row = uiLayoutRow(layout, true);
uiItemR(row, op->ptr, "factor", 0, NULL, ICON_NONE);
}
}
static int gpencil_stroke_normalize_exec(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
/* Sanity checks. */
if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
}
const eGP_NormalizeMode mode = RNA_enum_get(op->ptr, "mode");
const int value = RNA_int_get(op->ptr, "value");
const float factor = RNA_float_get(op->ptr, "factor");
/* Go through each editable + selected stroke. */
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
if (gpf == NULL) {
continue;
}
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
/* Skip strokes that are invalid for current view. */
if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
}
bool selected = (is_curve_edit) ? gps->editcurve->flag |= GP_CURVE_SELECT :
(gps->flag & GP_STROKE_SELECT);
if (!selected) {
continue;
}
float stroke_thickness_inv = 1.0f / max_ii(gps->thickness, 1);
/* Fill opacity need to be managed before. */
if (mode == GP_NORMALIZE_OPACITY) {
gps->fill_opacity_fac = factor;
CLAMP(gps->fill_opacity_fac, 0.0f, 1.0f);
}
/* Loop all Polyline points. */
if (!is_curve_edit) {
for (int i = 0; i < gps->totpoints; i++) {
bGPDspoint *pt = &gps->points[i];
if (mode == GP_NORMALIZE_THICKNESS) {
pt->pressure = max_ff((float)value * stroke_thickness_inv, 0.0f);
}
else if (mode == GP_NORMALIZE_OPACITY) {
pt->strength = factor;
CLAMP(pt->strength, 0.0f, 1.0f);
}
}
}
else {
/* Loop all Bezier points. */
for (int i = 0; i < gps->editcurve->tot_curve_points; i++) {
bGPDcurve_point *gpc_pt = &gps->editcurve->curve_points[i];
if (mode == GP_NORMALIZE_THICKNESS) {
gpc_pt->pressure = max_ff((float)value * stroke_thickness_inv, 0.0f);
}
else if (mode == GP_NORMALIZE_OPACITY) {
gpc_pt->strength = factor;
CLAMP(gpc_pt->strength, 0.0f, 1.0f);
}
}
gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
BKE_gpencil_stroke_geometry_update(gpd, gps);
}
}
/* If not multiedit, exit loop. */
if (!is_multiedit) {
break;
}
}
}
}
CTX_DATA_END;
/* notifiers */
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
}
void GPENCIL_OT_stroke_normalize(wmOperatorType *ot)
{
static const EnumPropertyItem prop_gpencil_normalize_modes[] = {
{GP_NORMALIZE_THICKNESS,
"THICKNESS",
0,
"Thickness",
"Normalizes the stroke thickness by making all points use the same thickness value"},
{GP_NORMALIZE_OPACITY,
"OPACITY",
0,
"Opacity",
"Normalizes the stroke opacity by making all points use the same opacity value"},
{0, NULL, 0, NULL, NULL},
};
/* identifiers */
ot->name = "Normalize Stroke";
ot->idname = "GPENCIL_OT_stroke_normalize";
ot->description = "Normalize stroke attributes";
/* api callbacks */
ot->exec = gpencil_stroke_normalize_exec;
ot->poll = gpencil_stroke_normalize_poll;
ot->ui = gpencil_stroke_normalize_ui;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
ot->prop = RNA_def_enum(
ot->srna, "mode", prop_gpencil_normalize_modes, 0, "Mode", "Attribute to be normalized");
RNA_def_float(ot->srna, "factor", 1.0f, 0.0f, 1.0f, "Factor", "", 0.0f, 1.0f);
RNA_def_int(ot->srna, "value", 10, 0, 1000, "Value", "Value", 0, 1000);
}
/** \} */

View File

@@ -488,7 +488,6 @@ void GPENCIL_OT_stroke_trim(struct wmOperatorType *ot);
void GPENCIL_OT_stroke_merge_by_distance(struct wmOperatorType *ot);
void GPENCIL_OT_stroke_merge_material(struct wmOperatorType *ot);
void GPENCIL_OT_stroke_reset_vertex_color(struct wmOperatorType *ot);
void GPENCIL_OT_stroke_normalize(struct wmOperatorType *ot);
void GPENCIL_OT_material_to_vertex_color(struct wmOperatorType *ot);
void GPENCIL_OT_extract_palette_vertex(struct wmOperatorType *ot);

View File

@@ -649,7 +649,6 @@ void ED_operatortypes_gpencil(void)
WM_operatortype_append(GPENCIL_OT_stroke_merge_by_distance);
WM_operatortype_append(GPENCIL_OT_stroke_merge_material);
WM_operatortype_append(GPENCIL_OT_stroke_reset_vertex_color);
WM_operatortype_append(GPENCIL_OT_stroke_normalize);
WM_operatortype_append(GPENCIL_OT_material_to_vertex_color);
WM_operatortype_append(GPENCIL_OT_extract_palette_vertex);

View File

@@ -40,6 +40,7 @@ struct bNodeSocketType;
struct bNodeTree;
struct bNodeTreeType;
struct bNodeType;
struct SpaceNode;
typedef enum {
NODE_TOP = 1,
@@ -109,6 +110,7 @@ bool ED_node_select_check(ListBase *lb);
void ED_node_select_all(ListBase *lb, int action);
void ED_node_post_apply_transform(struct bContext *C, struct bNodeTree *ntree);
void ED_node_set_active(struct Main *bmain,
struct SpaceNode *snode,
struct bNodeTree *ntree,
struct bNode *node,
bool *r_active_texture_changed);

View File

@@ -451,7 +451,7 @@ static void template_texture_select(bContext *C, void *user_p, void *UNUSED(arg)
/* set user as active */
if (user->node) {
ED_node_set_active(CTX_data_main(C), user->ntree, user->node, NULL);
ED_node_set_active(CTX_data_main(C), NULL, user->ntree, user->node, NULL);
ct->texture = NULL;
/* Not totally sure if we should also change selection? */

View File

@@ -1744,7 +1744,7 @@ static bool file_execute(bContext *C, SpaceFile *sfile)
/* directory change */
if (file && (file->typeflag & FILE_TYPE_DIR)) {
if (!file->relpath) {
return false;
return OPERATOR_CANCELLED;
}
if (FILENAME_IS_PARENT(file->relpath)) {
@@ -1783,7 +1783,7 @@ static bool file_execute(bContext *C, SpaceFile *sfile)
WM_event_fileselect_event(CTX_wm_manager(C), op, EVT_FILESELECT_EXEC);
}
return true;
return OPERATOR_FINISHED;
}
static int file_exec(bContext *C, wmOperator *UNUSED(op))

View File

@@ -37,20 +37,20 @@ set(INC
set(SRC
drawnode.cc
node_add.cc
drawnode.c
node_add.c
node_buttons.c
node_draw.cc
node_edit.cc
node_edit.c
node_geometry_attribute_search.cc
node_gizmo.c
node_group.cc
node_group.c
node_ops.c
node_relationships.cc
node_select.cc
node_templates.cc
node_toolbar.cc
node_view.cc
node_relationships.c
node_select.c
node_templates.c
node_toolbar.c
node_view.c
space_node.c
node_intern.h

View File

@@ -65,13 +65,13 @@
/**
* XXX Does some additional initialization on top of #nodeAddNode
* Can be used with both custom and static nodes,
* if `idname == nullptr` the static int type will be used instead.
* if `idname == NULL` the static int type will be used instead.
*/
bNode *node_add_node(const bContext *C, const char *idname, int type, float locx, float locy)
{
SpaceNode *snode = CTX_wm_space_node(C);
Main *bmain = CTX_data_main(C);
bNode *node = nullptr;
bNode *node = NULL;
node_deselect_all(snode);
@@ -90,7 +90,7 @@ bNode *node_add_node(const bContext *C, const char *idname, int type, float locx
nodeSetSelected(node, true);
ntreeUpdateTree(bmain, snode->edittree);
ED_node_set_active(bmain, snode->edittree, node, nullptr);
ED_node_set_active(bmain, snode, snode->edittree, node, NULL);
snode_update(snode, node);
@@ -114,7 +114,7 @@ static bool add_reroute_intersect_check(bNodeLink *link,
{
float coord_array[NODE_LINK_RESOL + 1][2];
if (node_link_bezier_points(nullptr, nullptr, link, coord_array, NODE_LINK_RESOL)) {
if (node_link_bezier_points(NULL, NULL, link, coord_array, NODE_LINK_RESOL)) {
for (int i = 0; i < tot - 1; i++) {
for (int b = 0; b < NODE_LINK_RESOL; b++) {
if (isect_seg_seg_v2_point(
@@ -127,13 +127,13 @@ static bool add_reroute_intersect_check(bNodeLink *link,
return false;
}
struct bNodeSocketLink {
typedef struct bNodeSocketLink {
struct bNodeSocketLink *next, *prev;
struct bNodeSocket *sock;
struct bNodeLink *link;
float point[2];
};
} bNodeSocketLink;
static bNodeSocketLink *add_reroute_insert_socket_link(ListBase *lb,
bNodeSocket *sock,
@@ -142,12 +142,12 @@ static bNodeSocketLink *add_reroute_insert_socket_link(ListBase *lb,
{
bNodeSocketLink *socklink, *prev;
socklink = (bNodeSocketLink *)MEM_callocN(sizeof(bNodeSocketLink), "socket link");
socklink = MEM_callocN(sizeof(bNodeSocketLink), "socket link");
socklink->sock = sock;
socklink->link = link;
copy_v2_v2(socklink->point, point);
for (prev = (bNodeSocketLink *)lb->last; prev; prev = prev->prev) {
for (prev = lb->last; prev; prev = prev->prev) {
if (prev->sock == sock) {
break;
}
@@ -162,7 +162,7 @@ static bNodeSocketLink *add_reroute_do_socket_section(bContext *C,
{
SpaceNode *snode = CTX_wm_space_node(C);
bNodeTree *ntree = snode->edittree;
bNode *reroute_node = nullptr;
bNode *reroute_node = NULL;
bNodeSocket *cursock = socklink->sock;
float insert_point[2];
int num_links;
@@ -184,12 +184,12 @@ static bNodeSocketLink *add_reroute_do_socket_section(bContext *C,
socklink->link->fromnode,
socklink->link->fromsock,
reroute_node,
(bNodeSocket *)reroute_node->inputs.first);
reroute_node->inputs.first);
}
else {
nodeAddLink(ntree,
reroute_node,
(bNodeSocket *)reroute_node->outputs.first,
reroute_node->outputs.first,
socklink->link->tonode,
socklink->link->tosock);
}
@@ -198,11 +198,11 @@ static bNodeSocketLink *add_reroute_do_socket_section(bContext *C,
/* insert the reroute node into the link */
if (in_out == SOCK_OUT) {
socklink->link->fromnode = reroute_node;
socklink->link->fromsock = (bNodeSocket *)reroute_node->outputs.first;
socklink->link->fromsock = reroute_node->outputs.first;
}
else {
socklink->link->tonode = reroute_node;
socklink->link->tosock = (bNodeSocket *)reroute_node->inputs.first;
socklink->link->tosock = reroute_node->inputs.first;
}
add_v2_v2(insert_point, socklink->point);
@@ -259,7 +259,7 @@ static int add_reroute_exec(bContext *C, wmOperator *op)
BLI_listbase_clear(&output_links);
BLI_listbase_clear(&input_links);
for (link = (bNodeLink *)ntree->links.first; link; link = link->next) {
for (link = ntree->links.first; link; link = link->next) {
if (nodeLinkIsHidden(link)) {
continue;
}
@@ -275,11 +275,11 @@ static int add_reroute_exec(bContext *C, wmOperator *op)
/* Create reroute nodes for intersected links.
* Only one reroute if links share the same input/output socket.
*/
socklink = (bNodeSocketLink *)output_links.first;
socklink = output_links.first;
while (socklink) {
socklink = add_reroute_do_socket_section(C, socklink, SOCK_OUT);
}
socklink = (bNodeSocketLink *)input_links.first;
socklink = input_links.first;
while (socklink) {
socklink = add_reroute_do_socket_section(C, socklink, SOCK_IN);
}
@@ -317,7 +317,7 @@ void NODE_OT_add_reroute(wmOperatorType *ot)
/* properties */
PropertyRNA *prop;
prop = RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
RNA_def_property_flag(prop, (PropertyFlag)(PROP_HIDDEN | PROP_SKIP_SAVE));
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
/* internal */
RNA_def_int(ot->srna, "cursor", WM_CURSOR_CROSS, 0, INT_MAX, "Cursor", "", 0, INT_MAX);
}
@@ -337,10 +337,10 @@ static bNodeTree *node_add_group_get_and_poll_group_node_tree(Main *bmain,
bNodeTree *node_group = (bNodeTree *)BKE_libblock_find_name(bmain, ID_NT, name);
if (!node_group) {
return nullptr;
return NULL;
}
const char *disabled_hint = nullptr;
const char *disabled_hint = NULL;
if ((node_group->type != ntree->type) || !nodeGroupPoll(ntree, node_group, &disabled_hint)) {
if (disabled_hint) {
BKE_reportf(op->reports,
@@ -358,7 +358,7 @@ static bNodeTree *node_add_group_get_and_poll_group_node_tree(Main *bmain,
ntree->id.name + 2);
}
return nullptr;
return NULL;
}
return node_group;
@@ -450,7 +450,7 @@ static Object *node_add_object_get_and_poll_object_node_tree(Main *bmain, wmOper
Object *object = (Object *)BKE_libblock_find_name(bmain, ID_OB, name);
if (!object) {
return nullptr;
return NULL;
}
return object;
@@ -470,7 +470,7 @@ static int node_add_object_exec(bContext *C, wmOperator *op)
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
bNode *object_node = node_add_node(
C, nullptr, GEO_NODE_OBJECT_INFO, snode->runtime->cursor[0], snode->runtime->cursor[1]);
C, NULL, GEO_NODE_OBJECT_INFO, snode->runtime->cursor[0], snode->runtime->cursor[1]);
if (!object_node) {
BKE_report(op->reports, RPT_WARNING, "Could not add node object");
return OPERATOR_CANCELLED;
@@ -482,7 +482,7 @@ static int node_add_object_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
bNodeSocketValueObject *socket_data = (bNodeSocketValueObject *)sock->default_value;
bNodeSocketValueObject *socket_data = sock->default_value;
socket_data->value = object;
id_us_plus(&object->id);
@@ -554,7 +554,7 @@ static Tex *node_add_texture_get_and_poll_texture_node_tree(Main *bmain, wmOpera
Tex *texture = (Tex *)BKE_libblock_find_name(bmain, ID_TE, name);
if (!texture) {
return nullptr;
return NULL;
}
return texture;
@@ -574,7 +574,7 @@ static int node_add_texture_exec(bContext *C, wmOperator *op)
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
bNode *texture_node = node_add_node(C,
nullptr,
NULL,
GEO_NODE_ATTRIBUTE_SAMPLE_TEXTURE,
snode->runtime->cursor[0],
snode->runtime->cursor[1]);
@@ -655,7 +655,7 @@ static Collection *node_add_collection_get_and_poll_collection_node_tree(Main *b
Collection *collection = (Collection *)BKE_libblock_find_name(bmain, ID_GR, name);
if (!collection) {
return nullptr;
return NULL;
}
return collection;
@@ -675,7 +675,7 @@ static int node_add_collection_exec(bContext *C, wmOperator *op)
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
bNode *collection_node = node_add_node(
C, nullptr, GEO_NODE_COLLECTION_INFO, snode->runtime->cursor[0], snode->runtime->cursor[1]);
C, NULL, GEO_NODE_COLLECTION_INFO, snode->runtime->cursor[0], snode->runtime->cursor[1]);
if (!collection_node) {
BKE_report(op->reports, RPT_WARNING, "Could not add node collection");
return OPERATOR_CANCELLED;
@@ -687,7 +687,7 @@ static int node_add_collection_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
bNodeSocketValueCollection *socket_data = (bNodeSocketValueCollection *)sock->default_value;
bNodeSocketValueCollection *socket_data = sock->default_value;
socket_data->value = collection;
id_us_plus(&collection->id);
@@ -788,7 +788,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op)
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
node = node_add_node(C, nullptr, type, snode->runtime->cursor[0], snode->runtime->cursor[1]);
node = node_add_node(C, NULL, type, snode->runtime->cursor[0], snode->runtime->cursor[1]);
if (!node) {
BKE_report(op->reports, RPT_WARNING, "Could not add an image node");
@@ -801,7 +801,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op)
* to get proper image source.
*/
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
BKE_image_signal(bmain, ima, nullptr, IMA_SIGNAL_RELOAD);
BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_RELOAD);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
}
@@ -876,7 +876,7 @@ static int node_add_mask_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
bNode *node;
ID *mask = nullptr;
ID *mask = NULL;
/* check input variables */
char name[MAX_ID_NAME - 2];
@@ -890,7 +890,7 @@ static int node_add_mask_exec(bContext *C, wmOperator *op)
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
node = node_add_node(
C, nullptr, CMP_NODE_MASK, snode->runtime->cursor[0], snode->runtime->cursor[1]);
C, NULL, CMP_NODE_MASK, snode->runtime->cursor[0], snode->runtime->cursor[1]);
if (!node) {
BKE_report(op->reports, RPT_WARNING, "Could not add a mask node");
@@ -976,7 +976,7 @@ static int new_node_tree_exec(bContext *C, wmOperator *op)
id_us_min(&ntree->id);
RNA_id_pointer_create(&ntree->id, &idptr);
RNA_property_pointer_set(&ptr, prop, idptr, nullptr);
RNA_property_pointer_set(&ptr, prop, idptr, NULL);
RNA_property_update(C, &ptr, prop);
}
else if (snode) {
@@ -993,7 +993,7 @@ static const EnumPropertyItem *new_node_tree_type_itemf(bContext *UNUSED(C),
PropertyRNA *UNUSED(prop),
bool *r_free)
{
return rna_node_tree_type_itemf(nullptr, nullptr, r_free);
return rna_node_tree_type_itemf(NULL, NULL, r_free);
}
void NODE_OT_new_node_tree(wmOperatorType *ot)

View File

@@ -1404,28 +1404,6 @@ static void node_draw_basis(const bContext *C,
"");
UI_block_emboss_set(node->block, UI_EMBOSS);
}
if (ntree->type == NTREE_GEOMETRY) {
/* Active preview toggle. */
iconofs -= iconbutw;
UI_block_emboss_set(node->block, UI_EMBOSS_NONE);
int icon = (node->flag & NODE_ACTIVE_PREVIEW) ? ICON_RESTRICT_VIEW_OFF : ICON_RESTRICT_VIEW_ON;
uiBut *but = uiDefIconBut(node->block,
UI_BTYPE_BUT_TOGGLE,
0,
icon,
iconofs,
rct->ymax - NODE_DY,
iconbutw,
UI_UNIT_Y,
nullptr,
0,
0,
0,
0,
"Show this node's geometry output in the spreadsheet");
UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_active_preview_toggle");
UI_block_emboss_set(node->block, UI_EMBOSS);
}
node_add_error_message_button(C, *ntree, *node, *rct, iconofs);

View File

@@ -54,6 +54,7 @@
#include "ED_render.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_spreadsheet.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -83,7 +84,7 @@ enum {
COM_RECALC_VIEWER = 2,
};
struct CompoJob {
typedef struct CompoJob {
/* Input parameters. */
Main *bmain;
Scene *scene;
@@ -97,7 +98,7 @@ struct CompoJob {
const short *stop;
short *do_update;
float *progress;
};
} CompoJob;
float node_socket_calculate_height(const bNodeSocket *socket)
{
@@ -150,7 +151,7 @@ static int compo_get_recalc_flags(const bContext *C)
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
if (area->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)area->spacedata.first;
SpaceImage *sima = area->spacedata.first;
if (sima->image) {
if (sima->image->type == IMA_TYPE_R_RESULT) {
recalc_flags |= COM_RECALC_COMPOSITE;
@@ -161,7 +162,7 @@ static int compo_get_recalc_flags(const bContext *C)
}
}
else if (area->spacetype == SPACE_NODE) {
SpaceNode *snode = (SpaceNode *)area->spacedata.first;
SpaceNode *snode = area->spacedata.first;
if (snode->flag & SNODE_BACKDRAW) {
recalc_flags |= COM_RECALC_VIEWER;
}
@@ -175,7 +176,7 @@ static int compo_get_recalc_flags(const bContext *C)
/* called by compo, only to check job 'stop' value */
static int compo_breakjob(void *cjv)
{
CompoJob *cj = (CompoJob *)cjv;
CompoJob *cj = cjv;
/* without G.is_break 'ESC' wont quit - which annoys users */
return (*(cj->stop)
@@ -188,7 +189,7 @@ static int compo_breakjob(void *cjv)
/* called by compo, wmJob sends notifier */
static void compo_statsdrawjob(void *cjv, const char *UNUSED(str))
{
CompoJob *cj = (CompoJob *)cjv;
CompoJob *cj = cjv;
*(cj->do_update) = true;
}
@@ -196,19 +197,19 @@ static void compo_statsdrawjob(void *cjv, const char *UNUSED(str))
/* called by compo, wmJob sends notifier */
static void compo_redrawjob(void *cjv)
{
CompoJob *cj = (CompoJob *)cjv;
CompoJob *cj = cjv;
*(cj->do_update) = true;
}
static void compo_freejob(void *cjv)
{
CompoJob *cj = (CompoJob *)cjv;
CompoJob *cj = cjv;
if (cj->localtree) {
ntreeLocalMerge(cj->bmain, cj->localtree, cj->ntree);
}
if (cj->compositor_depsgraph != nullptr) {
if (cj->compositor_depsgraph != NULL) {
DEG_graph_free(cj->compositor_depsgraph);
}
MEM_freeN(cj);
@@ -218,7 +219,7 @@ static void compo_freejob(void *cjv)
* sliding buttons doesn't frustrate */
static void compo_initjob(void *cjv)
{
CompoJob *cj = (CompoJob *)cjv;
CompoJob *cj = cjv;
Main *bmain = cj->bmain;
Scene *scene = cj->scene;
ViewLayer *view_layer = cj->view_layer;
@@ -243,12 +244,12 @@ static void compo_initjob(void *cjv)
/* called before redraw notifiers, it moves finished previews over */
static void compo_updatejob(void *UNUSED(cjv))
{
WM_main_add_notifier(NC_SCENE | ND_COMPO_RESULT, nullptr);
WM_main_add_notifier(NC_SCENE | ND_COMPO_RESULT, NULL);
}
static void compo_progressjob(void *cjv, float progress)
{
CompoJob *cj = (CompoJob *)cjv;
CompoJob *cj = cjv;
*(cj->progress) = progress;
}
@@ -261,7 +262,7 @@ static void compo_startjob(void *cjv,
short *do_update,
float *progress)
{
CompoJob *cj = (CompoJob *)cjv;
CompoJob *cj = cjv;
bNodeTree *ntree = cj->localtree;
Scene *scene = cj->scene;
@@ -311,9 +312,9 @@ static void compo_startjob(void *cjv,
}
}
ntree->test_break = nullptr;
ntree->stats_draw = nullptr;
ntree->progress = nullptr;
ntree->test_break = NULL;
ntree->stats_draw = NULL;
ntree->progress = NULL;
}
/**
@@ -347,7 +348,7 @@ void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene
"Compositing",
WM_JOB_EXCL_RENDER | WM_JOB_PROGRESS,
WM_JOB_TYPE_COMPOSITE);
CompoJob *cj = (CompoJob *)MEM_callocN(sizeof(CompoJob), "compo job");
CompoJob *cj = MEM_callocN(sizeof(CompoJob), "compo job");
/* customdata for preview thread */
cj->bmain = bmain;
@@ -359,7 +360,7 @@ void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene
/* setup job */
WM_jobs_customdata_set(wm_job, cj, compo_freejob);
WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_COMPO_RESULT, NC_SCENE | ND_COMPO_RESULT);
WM_jobs_callbacks(wm_job, compo_startjob, compo_initjob, compo_updatejob, nullptr);
WM_jobs_callbacks(wm_job, compo_startjob, compo_initjob, compo_updatejob, NULL);
WM_jobs_start(CTX_wm_manager(C), wm_job);
}
@@ -383,7 +384,7 @@ bool composite_node_editable(bContext *C)
{
if (ED_operator_node_editable(C)) {
SpaceNode *snode = CTX_wm_space_node(C);
if (ED_node_is_compositor(snode)) {
if (ED_node_is_compositor(snode) || ED_node_is_geometry(snode)) {
return true;
}
}
@@ -412,7 +413,7 @@ void snode_notify(bContext *C, SpaceNode *snode)
{
ID *id = snode->id;
WM_event_add_notifier(C, NC_NODE | NA_EDITED, nullptr);
WM_event_add_notifier(C, NC_NODE | NA_EDITED, NULL);
if (ED_node_is_shader(snode)) {
if (GS(id->name) == ID_MA) {
@@ -490,15 +491,15 @@ void ED_node_shader_default(const bContext *C, ID *id)
}
else if (ELEM(GS(id->name), ID_WO, ID_LA)) {
/* Emission */
bNodeTree *ntree = ntreeAddTree(nullptr, "Shader Nodetree", ntreeType_Shader->idname);
bNodeTree *ntree = ntreeAddTree(NULL, "Shader Nodetree", ntreeType_Shader->idname);
bNode *shader, *output;
if (GS(id->name) == ID_WO) {
World *world = (World *)id;
world->nodetree = ntree;
shader = nodeAddStaticNode(nullptr, ntree, SH_NODE_BACKGROUND);
output = nodeAddStaticNode(nullptr, ntree, SH_NODE_OUTPUT_WORLD);
shader = nodeAddStaticNode(NULL, ntree, SH_NODE_BACKGROUND);
output = nodeAddStaticNode(NULL, ntree, SH_NODE_OUTPUT_WORLD);
nodeAddLink(ntree,
shader,
nodeFindSocket(shader, SOCK_OUT, "Background"),
@@ -512,8 +513,8 @@ void ED_node_shader_default(const bContext *C, ID *id)
Light *light = (Light *)id;
light->nodetree = ntree;
shader = nodeAddStaticNode(nullptr, ntree, SH_NODE_EMISSION);
output = nodeAddStaticNode(nullptr, ntree, SH_NODE_OUTPUT_LIGHT);
shader = nodeAddStaticNode(NULL, ntree, SH_NODE_EMISSION);
output = nodeAddStaticNode(NULL, ntree, SH_NODE_OUTPUT_LIGHT);
nodeAddLink(ntree,
shader,
nodeFindSocket(shader, SOCK_OUT, "Emission"),
@@ -546,7 +547,7 @@ void ED_node_composit_default(const bContext *C, struct Scene *sce)
return;
}
sce->nodetree = ntreeAddTree(nullptr, "Compositing Nodetree", ntreeType_Composite->idname);
sce->nodetree = ntreeAddTree(NULL, "Compositing Nodetree", ntreeType_Composite->idname);
sce->nodetree->chunksize = 256;
sce->nodetree->edit_quality = NTREE_QUALITY_HIGH;
@@ -562,8 +563,8 @@ void ED_node_composit_default(const bContext *C, struct Scene *sce)
nodeSetActive(sce->nodetree, in);
/* links from color to color */
bNodeSocket *fromsock = (bNodeSocket *)in->outputs.first;
bNodeSocket *tosock = (bNodeSocket *)out->inputs.first;
bNodeSocket *fromsock = in->outputs.first;
bNodeSocket *tosock = out->inputs.first;
nodeAddLink(sce->nodetree, in, fromsock, out, tosock);
ntreeUpdateTree(CTX_data_main(C), sce->nodetree);
@@ -581,7 +582,7 @@ void ED_node_texture_default(const bContext *C, Tex *tex)
return;
}
tex->nodetree = ntreeAddTree(nullptr, "Texture Nodetree", ntreeType_Texture->idname);
tex->nodetree = ntreeAddTree(NULL, "Texture Nodetree", ntreeType_Texture->idname);
bNode *out = nodeAddStaticNode(C, tex->nodetree, TEX_NODE_OUTPUT);
out->locx = 300.0f;
@@ -592,8 +593,8 @@ void ED_node_texture_default(const bContext *C, Tex *tex)
in->locy = 300.0f;
nodeSetActive(tex->nodetree, in);
bNodeSocket *fromsock = (bNodeSocket *)in->outputs.first;
bNodeSocket *tosock = (bNodeSocket *)out->inputs.first;
bNodeSocket *fromsock = in->outputs.first;
bNodeSocket *tosock = out->inputs.first;
nodeAddLink(tex->nodetree, in, fromsock, out, tosock);
ntreeUpdateTree(CTX_data_main(C), tex->nodetree);
@@ -618,24 +619,24 @@ void snode_set_context(const bContext *C)
if (snode->nodetree && !STREQ(snode->nodetree->idname, snode->tree_idname)) {
/* current tree does not match selected type, clear tree path */
ntree = nullptr;
id = nullptr;
from = nullptr;
ntree = NULL;
id = NULL;
from = NULL;
}
if (!(snode->flag & SNODE_PIN) || ntree == nullptr) {
if (!(snode->flag & SNODE_PIN) || ntree == NULL) {
if (treetype->get_from_context) {
/* reset and update from context */
ntree = nullptr;
id = nullptr;
from = nullptr;
ntree = NULL;
id = NULL;
from = NULL;
treetype->get_from_context(C, treetype, &ntree, &id, &from);
}
}
if (snode->nodetree != ntree || snode->id != id || snode->from != from ||
(snode->treepath.last == nullptr && ntree)) {
(snode->treepath.last == NULL && ntree)) {
ED_node_tree_start(snode, ntree, id, from);
}
}
@@ -648,7 +649,7 @@ void snode_update(SpaceNode *snode, bNode *node)
*/
/* update all edited group nodes */
bNodeTreePath *path = (bNodeTreePath *)snode->treepath.last;
bNodeTreePath *path = snode->treepath.last;
if (path) {
bNodeTree *ngroup = path->nodetree;
for (path = path->prev; path; path = path->prev) {
@@ -662,7 +663,8 @@ void snode_update(SpaceNode *snode, bNode *node)
}
}
void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node, bool *r_active_texture_changed)
void ED_node_set_active(
Main *bmain, SpaceNode *snode, bNodeTree *ntree, bNode *node, bool *r_active_texture_changed)
{
const bool was_active_texture = (node->flag & NODE_ACTIVE_TEXTURE) != 0;
if (r_active_texture_changed) {
@@ -685,7 +687,7 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node, bool *r_acti
node->flag |= NODE_DO_OUTPUT;
if (!was_output) {
do_update = true;
do_update = 1;
}
}
@@ -734,7 +736,7 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node, bool *r_acti
*r_active_texture_changed = true;
}
ED_node_tag_update_nodetree(bmain, ntree, node);
WM_main_add_notifier(NC_IMAGE, nullptr);
WM_main_add_notifier(NC_IMAGE, NULL);
}
WM_main_add_notifier(NC_MATERIAL | ND_NODES, node->id);
@@ -782,6 +784,30 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node, bool *r_acti
}
#endif
}
else if (ntree->type == NTREE_GEOMETRY) {
if (node->type == GEO_NODE_VIEWER) {
LISTBASE_FOREACH (bNode *, node_iter, &ntree->nodes) {
if (node_iter->type == GEO_NODE_VIEWER) {
node_iter->flag &= ~NODE_DO_OUTPUT;
}
}
node->flag |= NODE_DO_OUTPUT;
wmWindowManager *wm = bmain->wm.first;
LISTBASE_FOREACH (wmWindow *, window, &wm->windows) {
bScreen *screen = BKE_workspace_active_screen_get(window->workspace_hook);
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
SpaceLink *sl = (SpaceLink *)area->spacedata.first;
if (sl->spacetype == SPACE_SPREADSHEET) {
SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)sl;
if ((sspreadsheet->flag & SPREADSHEET_FLAG_PINNED) == 0) {
ED_spreadsheet_set_geometry_node_context(sspreadsheet, snode, node);
ED_area_tag_redraw(area);
}
}
}
}
}
}
}
}
@@ -806,7 +832,7 @@ static bool edit_node_poll(bContext *C)
static void edit_node_properties(wmOperatorType *ot)
{
/* XXX could node be a context pointer? */
RNA_def_string(ot->srna, "node", nullptr, MAX_NAME, "Node", "");
RNA_def_string(ot->srna, "node", NULL, MAX_NAME, "Node", "");
RNA_def_int(ot->srna, "socket", 0, 0, MAX_SOCKET, "Socket", "", 0, MAX_SOCKET);
RNA_def_enum(ot->srna, "in_out", rna_enum_node_socket_in_out_items, SOCK_IN, "Socket Side", "");
}
@@ -838,7 +864,7 @@ static void edit_node_properties_get(
wmOperator *op, bNodeTree *ntree, bNode **r_node, bNodeSocket **r_sock, int *r_in_out)
{
bNode *node;
bNodeSocket *sock = nullptr;
bNodeSocket *sock = NULL;
char nodename[MAX_NAME];
int sockindex;
int in_out;
@@ -876,30 +902,29 @@ static void edit_node_properties_get(
static bNode *visible_node(SpaceNode *snode, const rctf *rct)
{
LISTBASE_FOREACH_BACKWARD (bNode *, node, &snode->edittree->nodes) {
if (BLI_rctf_isect(&node->totr, rct, nullptr)) {
if (BLI_rctf_isect(&node->totr, rct, NULL)) {
return node;
}
}
return nullptr;
return NULL;
}
/* ********************** size widget operator ******************** */
struct NodeSizeWidget {
typedef struct NodeSizeWidget {
float mxstart, mystart;
float oldlocx, oldlocy;
float oldoffsetx, oldoffsety;
float oldwidth, oldheight;
int directions;
};
} NodeSizeWidget;
static void node_resize_init(
bContext *C, wmOperator *op, const wmEvent *UNUSED(event), bNode *node, int dir)
{
SpaceNode *snode = CTX_wm_space_node(C);
NodeSizeWidget *nsw = (NodeSizeWidget *)MEM_callocN(sizeof(NodeSizeWidget),
"size widget op data");
NodeSizeWidget *nsw = MEM_callocN(sizeof(NodeSizeWidget), "size widget op data");
op->customdata = nsw;
nsw->mxstart = snode->runtime->cursor[0] * UI_DPI_FAC;
@@ -927,7 +952,7 @@ static void node_resize_exit(bContext *C, wmOperator *op, bool cancel)
if (cancel) {
SpaceNode *snode = CTX_wm_space_node(C);
bNode *node = nodeGetActive(snode->edittree);
NodeSizeWidget *nsw = (NodeSizeWidget *)op->customdata;
NodeSizeWidget *nsw = op->customdata;
node->locx = nsw->oldlocx;
node->locy = nsw->oldlocy;
@@ -938,7 +963,7 @@ static void node_resize_exit(bContext *C, wmOperator *op, bool cancel)
}
MEM_freeN(op->customdata);
op->customdata = nullptr;
op->customdata = NULL;
}
static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event)
@@ -946,7 +971,7 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event)
SpaceNode *snode = CTX_wm_space_node(C);
ARegion *region = CTX_wm_region(C);
bNode *node = nodeGetActive(snode->edittree);
NodeSizeWidget *nsw = (NodeSizeWidget *)op->customdata;
NodeSizeWidget *nsw = op->customdata;
switch (event->type) {
case MOUSEMOVE: {
@@ -1113,7 +1138,7 @@ void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set)
else {
/* hide unused sockets */
LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
if (sock->link == nullptr) {
if (sock->link == NULL) {
sock->flag |= SOCK_HIDDEN;
}
}
@@ -1129,17 +1154,17 @@ void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set)
static bool cursor_isect_multi_input_socket(const float cursor[2], const bNodeSocket *socket)
{
const float node_socket_height = node_socket_calculate_height(socket);
rctf multi_socket_rect;
/*.xmax = socket->locx + NODE_SOCKSIZE * 5.5f
* would be the same behavior as for regular sockets.
* But keep it smaller because for multi-input socket you
* sometimes want to drag the link to the other side, if you may
* accidentally pick the wrong link otherwise. */
BLI_rctf_init(&multi_socket_rect,
socket->locx - NODE_SOCKSIZE * 4.0f,
socket->locx + NODE_SOCKSIZE * 2.0f,
socket->locy - node_socket_height,
socket->locy + node_socket_height);
const rctf multi_socket_rect = {
.xmin = socket->locx - NODE_SOCKSIZE * 4.0f,
.xmax = socket->locx + NODE_SOCKSIZE * 2.0f,
/*.xmax = socket->locx + NODE_SOCKSIZE * 5.5f
* would be the same behavior as for regular sockets.
* But keep it smaller because for multi-input socket you
* sometimes want to drag the link to the other side, if you may
* accidentally pick the wrong link otherwise. */
.ymin = socket->locy - node_socket_height,
.ymax = socket->locy + node_socket_height,
};
if (BLI_rctf_isect_pt(&multi_socket_rect, cursor[0], cursor[1])) {
return true;
}
@@ -1152,8 +1177,8 @@ int node_find_indicated_socket(
{
rctf rect;
*nodep = nullptr;
*sockp = nullptr;
*nodep = NULL;
*sockp = NULL;
/* check if we click in a socket */
LISTBASE_FOREACH (bNode *, node, &snode->edittree->nodes) {
@@ -1245,7 +1270,7 @@ static int node_duplicate_exec(bContext *C, wmOperator *op)
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
bNode *lastnode = (bNode *)ntree->nodes.last;
bNode *lastnode = ntree->nodes.last;
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->flag & SELECT) {
BKE_node_copy_store_new_pointers(ntree, node, LIB_ID_COPY_DEFAULT);
@@ -1263,14 +1288,14 @@ static int node_duplicate_exec(bContext *C, wmOperator *op)
/* copy links between selected nodes
* NB: this depends on correct node->new_node and sock->new_sock pointers from above copy!
*/
bNodeLink *lastlink = (bNodeLink *)ntree->links.last;
bNodeLink *lastlink = ntree->links.last;
LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) {
/* This creates new links between copied nodes.
* If keep_inputs is set, also copies input links from unselected (when fromnode==nullptr)!
* If keep_inputs is set, also copies input links from unselected (when fromnode==NULL)!
*/
if (link->tonode && (link->tonode->flag & NODE_SELECT) &&
(keep_inputs || (link->fromnode && (link->fromnode->flag & NODE_SELECT)))) {
bNodeLink *newlink = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "bNodeLink");
bNodeLink *newlink = MEM_callocN(sizeof(bNodeLink), "bNodeLink");
newlink->flag = link->flag;
newlink->tonode = link->tonode->new_node;
newlink->tosock = link->tosock->new_sock;
@@ -1318,7 +1343,6 @@ static int node_duplicate_exec(bContext *C, wmOperator *op)
nodeSetSelected(node, false);
node->flag &= ~(NODE_ACTIVE | NODE_ACTIVE_TEXTURE);
nodeSetSelected(newnode, true);
newnode->flag &= ~NODE_ACTIVE_PREVIEW;
do_tag_update |= (do_tag_update || node_connected_to_output(bmain, ntree, newnode));
}
@@ -1354,7 +1378,7 @@ void NODE_OT_duplicate(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(
ot->srna, "keep_inputs", false, "Keep Inputs", "Keep the input links to duplicated nodes");
ot->srna, "keep_inputs", 0, "Keep Inputs", "Keep the input links to duplicated nodes");
}
bool ED_node_select_check(ListBase *lb)
@@ -1415,7 +1439,7 @@ static int node_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op))
if ((node->type == CMP_NODE_R_LAYERS) ||
(node->type == CMP_NODE_CRYPTOMATTE && node->custom1 == CMP_CRYPTOMATTE_SRC_RENDER)) {
ID *id = node->id;
if (id == nullptr) {
if (id == NULL) {
continue;
}
if (id->tag & LIB_TAG_DOIT) {
@@ -1454,7 +1478,7 @@ int node_render_changed_exec(bContext *C, wmOperator *UNUSED(op))
/* This is actually a test whether scene is used by the compositor or not.
* All the nodes are using same render result, so there is no need to do
* anything smart about check how exactly scene is used. */
bNode *node = nullptr;
bNode *node = NULL;
LISTBASE_FOREACH (bNode *, node_iter, &sce->nodetree->nodes) {
if (node_iter->id == (ID *)sce) {
node = node_iter;
@@ -1463,7 +1487,7 @@ int node_render_changed_exec(bContext *C, wmOperator *UNUSED(op))
}
if (node) {
ViewLayer *view_layer = (ViewLayer *)BLI_findlink(&sce->view_layers, node->custom1);
ViewLayer *view_layer = BLI_findlink(&sce->view_layers, node->custom1);
if (view_layer) {
PointerRNA op_ptr;
@@ -1472,7 +1496,7 @@ int node_render_changed_exec(bContext *C, wmOperator *UNUSED(op))
RNA_string_set(&op_ptr, "layer", view_layer->name);
RNA_string_set(&op_ptr, "scene", sce->id.name + 2);
/* To keep keyframe positions. */
/* to keep keypositions */
sce->r.scemode |= R_NO_FRAME_UPDATE;
WM_operator_name_call(C, "RENDER_OT_render", WM_OP_INVOKE_DEFAULT, &op_ptr);
@@ -1555,13 +1579,13 @@ static int node_hide_toggle_exec(bContext *C, wmOperator *UNUSED(op))
SpaceNode *snode = CTX_wm_space_node(C);
/* sanity checking (poll callback checks this already) */
if ((snode == nullptr) || (snode->edittree == nullptr)) {
if ((snode == NULL) || (snode->edittree == NULL)) {
return OPERATOR_CANCELLED;
}
node_flag_toggle_exec(snode, NODE_HIDDEN);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
return OPERATOR_FINISHED;
}
@@ -1586,7 +1610,7 @@ static int node_preview_toggle_exec(bContext *C, wmOperator *UNUSED(op))
SpaceNode *snode = CTX_wm_space_node(C);
/* sanity checking (poll callback checks this already) */
if ((snode == nullptr) || (snode->edittree == nullptr)) {
if ((snode == NULL) || (snode->edittree == NULL)) {
return OPERATOR_CANCELLED;
}
@@ -1619,13 +1643,13 @@ static int node_options_toggle_exec(bContext *C, wmOperator *UNUSED(op))
SpaceNode *snode = CTX_wm_space_node(C);
/* sanity checking (poll callback checks this already) */
if ((snode == nullptr) || (snode->edittree == nullptr)) {
if ((snode == NULL) || (snode->edittree == NULL)) {
return OPERATOR_CANCELLED;
}
node_flag_toggle_exec(snode, NODE_OPTIONS);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
return OPERATOR_FINISHED;
}
@@ -1650,7 +1674,7 @@ static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op))
SpaceNode *snode = CTX_wm_space_node(C);
/* sanity checking (poll callback checks this already) */
if ((snode == nullptr) || (snode->edittree == nullptr)) {
if ((snode == NULL) || (snode->edittree == NULL)) {
return OPERATOR_CANCELLED;
}
@@ -1675,7 +1699,7 @@ static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op))
ntreeUpdateTree(CTX_data_main(C), snode->edittree);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
return OPERATOR_FINISHED;
}
@@ -1871,12 +1895,12 @@ static int node_output_file_add_socket_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
SpaceNode *snode = CTX_wm_space_node(C);
PointerRNA ptr = CTX_data_pointer_get(C, "node");
bNodeTree *ntree = nullptr;
bNode *node = nullptr;
bNodeTree *ntree = NULL;
bNode *node = NULL;
char file_path[MAX_NAME];
if (ptr.data) {
node = (bNode *)ptr.data;
node = ptr.data;
ntree = (bNodeTree *)ptr.owner_id;
}
else if (snode && snode->edittree) {
@@ -1920,11 +1944,11 @@ static int node_output_file_remove_active_socket_exec(bContext *C, wmOperator *U
{
SpaceNode *snode = CTX_wm_space_node(C);
PointerRNA ptr = CTX_data_pointer_get(C, "node");
bNodeTree *ntree = nullptr;
bNode *node = nullptr;
bNodeTree *ntree = NULL;
bNode *node = NULL;
if (ptr.data) {
node = (bNode *)ptr.data;
node = ptr.data;
ntree = (bNodeTree *)ptr.owner_id;
}
else if (snode && snode->edittree) {
@@ -1966,10 +1990,10 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op)
{
SpaceNode *snode = CTX_wm_space_node(C);
PointerRNA ptr = CTX_data_pointer_get(C, "node");
bNode *node = nullptr;
bNode *node = NULL;
if (ptr.data) {
node = (bNode *)ptr.data;
node = ptr.data;
}
else if (snode && snode->edittree) {
node = nodeGetActive(snode->edittree);
@@ -1979,9 +2003,9 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
NodeImageMultiFile *nimf = (NodeImageMultiFile *)node->storage;
NodeImageMultiFile *nimf = node->storage;
bNodeSocket *sock = (bNodeSocket *)BLI_findlink(&node->inputs, nimf->active_input);
bNodeSocket *sock = BLI_findlink(&node->inputs, nimf->active_input);
if (!sock) {
return OPERATOR_CANCELLED;
}
@@ -2015,7 +2039,7 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op)
void NODE_OT_output_file_move_active_socket(wmOperatorType *ot)
{
static const EnumPropertyItem direction_items[] = {
{1, "UP", 0, "Up", ""}, {2, "DOWN", 0, "Down", ""}, {0, nullptr, 0, nullptr, nullptr}};
{1, "UP", 0, "Up", ""}, {2, "DOWN", 0, "Down", ""}, {0, NULL, 0, NULL, NULL}};
/* identifiers */
ot->name = "Move File Node Socket";
@@ -2060,7 +2084,7 @@ static int node_copy_color_exec(bContext *C, wmOperator *UNUSED(op))
}
ED_node_sort(ntree);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
return OPERATOR_FINISHED;
}
@@ -2098,7 +2122,7 @@ static int node_clipboard_copy_exec(bContext *C, wmOperator *UNUSED(op))
/* No ID refcounting, this node is virtual,
* detached from any actual Blender data currently. */
bNode *new_node = BKE_node_copy_store_new_pointers(
nullptr, node, LIB_ID_CREATE_NO_USER_REFCOUNT | LIB_ID_CREATE_NO_MAIN);
NULL, node, LIB_ID_CREATE_NO_USER_REFCOUNT | LIB_ID_CREATE_NO_MAIN);
BKE_node_clipboard_add_node(new_node);
}
}
@@ -2128,7 +2152,7 @@ static int node_clipboard_copy_exec(bContext *C, wmOperator *UNUSED(op))
/* This creates new links between copied nodes. */
if (link->tonode && (link->tonode->flag & NODE_SELECT) && link->fromnode &&
(link->fromnode->flag & NODE_SELECT)) {
bNodeLink *newlink = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "bNodeLink");
bNodeLink *newlink = MEM_callocN(sizeof(bNodeLink), "bNodeLink");
newlink->flag = link->flag;
newlink->tonode = link->tonode->new_node;
newlink->tosock = link->tosock->new_sock;
@@ -2189,7 +2213,7 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op)
/* make sure all clipboard nodes would be valid in the target tree */
bool all_nodes_valid = true;
LISTBASE_FOREACH (bNode *, node, clipboard_nodes_lb) {
const char *disabled_hint = nullptr;
const char *disabled_hint = NULL;
if (!node->typeinfo->poll_instance ||
!node->typeinfo->poll_instance(node, ntree, &disabled_hint)) {
all_nodes_valid = false;
@@ -2287,7 +2311,7 @@ static bNodeSocket *ntree_get_active_interface_socket(ListBase *lb)
return socket;
}
}
return nullptr;
return NULL;
}
static int ntree_socket_add_exec(bContext *C, wmOperator *op)
@@ -2298,7 +2322,7 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op)
PointerRNA ntree_ptr;
RNA_id_pointer_create((ID *)ntree, &ntree_ptr);
const eNodeSocketInOut in_out = (eNodeSocketInOut)RNA_enum_get(op->ptr, "in_out");
const eNodeSocketInOut in_out = RNA_enum_get(op->ptr, "in_out");
ListBase *sockets = (in_out == SOCK_IN) ? &ntree->inputs : &ntree->outputs;
const char *default_name = (in_out == SOCK_IN) ? "Input" : "Output";
@@ -2329,7 +2353,7 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op)
snode_notify(C, snode);
snode_dag_update(C, snode);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
return OPERATOR_FINISHED;
}
@@ -2357,11 +2381,11 @@ static int ntree_socket_remove_exec(bContext *C, wmOperator *op)
{
SpaceNode *snode = CTX_wm_space_node(C);
bNodeTree *ntree = snode->edittree;
const eNodeSocketInOut in_out = (eNodeSocketInOut)RNA_enum_get(op->ptr, "in_out");
const eNodeSocketInOut in_out = RNA_enum_get(op->ptr, "in_out");
bNodeSocket *iosock = ntree_get_active_interface_socket(in_out == SOCK_IN ? &ntree->inputs :
&ntree->outputs);
if (iosock == nullptr) {
if (iosock == NULL) {
return OPERATOR_CANCELLED;
}
@@ -2379,7 +2403,7 @@ static int ntree_socket_remove_exec(bContext *C, wmOperator *op)
snode_notify(C, snode);
snode_dag_update(C, snode);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
return OPERATOR_FINISHED;
}
@@ -2405,7 +2429,7 @@ void NODE_OT_tree_socket_remove(wmOperatorType *ot)
static const EnumPropertyItem move_direction_items[] = {
{1, "UP", 0, "Up", ""},
{2, "DOWN", 0, "Down", ""},
{0, nullptr, 0, nullptr, nullptr},
{0, NULL, 0, NULL, NULL},
};
static int ntree_socket_move_exec(bContext *C, wmOperator *op)
@@ -2414,12 +2438,12 @@ static int ntree_socket_move_exec(bContext *C, wmOperator *op)
bNodeTree *ntree = snode->edittree;
int direction = RNA_enum_get(op->ptr, "direction");
const eNodeSocketInOut in_out = (eNodeSocketInOut)RNA_enum_get(op->ptr, "in_out");
const eNodeSocketInOut in_out = RNA_enum_get(op->ptr, "in_out");
ListBase *sockets = in_out == SOCK_IN ? &ntree->inputs : &ntree->outputs;
bNodeSocket *iosock = ntree_get_active_interface_socket(sockets);
if (iosock == nullptr) {
if (iosock == NULL) {
return OPERATOR_CANCELLED;
}
@@ -2454,7 +2478,7 @@ static int ntree_socket_move_exec(bContext *C, wmOperator *op)
snode_notify(C, snode);
snode_dag_update(C, snode);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
return OPERATOR_FINISHED;
}
@@ -2487,18 +2511,18 @@ static bool node_shader_script_update_poll(bContext *C)
/* test if we have a render engine that supports shaders scripts */
if (!(type && type->update_script_node)) {
return false;
return 0;
}
/* see if we have a shader script node in context */
bNode *node = (bNode *)CTX_data_pointer_get_type(C, "node", &RNA_ShaderNodeScript).data;
bNode *node = CTX_data_pointer_get_type(C, "node", &RNA_ShaderNodeScript).data;
if (!node && snode && snode->edittree) {
node = nodeGetActive(snode->edittree);
}
if (node && node->type == SH_NODE_SCRIPT) {
NodeShaderScript *nss = (NodeShaderScript *)node->storage;
NodeShaderScript *nss = node->storage;
if (node->id || nss->filepath[0]) {
return ED_operator_node_editable(C);
@@ -2506,14 +2530,14 @@ static bool node_shader_script_update_poll(bContext *C)
}
/* see if we have a text datablock in context */
Text *text = (Text *)CTX_data_pointer_get_type(C, "edit_text", &RNA_Text).data;
Text *text = CTX_data_pointer_get_type(C, "edit_text", &RNA_Text).data;
if (text) {
return true;
return 1;
}
/* we don't check if text datablock is actually in use, too slow for poll */
return false;
return 0;
}
/* recursively check for script nodes in groups using this text and update */
@@ -2557,11 +2581,11 @@ static int node_shader_script_update_exec(bContext *C, wmOperator *op)
engine->reports = op->reports;
/* get node */
bNodeTree *ntree_base = nullptr;
bNode *node = nullptr;
bNodeTree *ntree_base = NULL;
bNode *node = NULL;
if (nodeptr.data) {
ntree_base = (bNodeTree *)nodeptr.owner_id;
node = (bNode *)nodeptr.data;
node = nodeptr.data;
}
else if (snode && snode->edittree) {
ntree_base = snode->edittree;
@@ -2576,7 +2600,7 @@ static int node_shader_script_update_exec(bContext *C, wmOperator *op)
}
else {
/* update all nodes using text datablock */
Text *text = (Text *)CTX_data_pointer_get_type(C, "edit_text", &RNA_Text).data;
Text *text = CTX_data_pointer_get_type(C, "edit_text", &RNA_Text).data;
if (text) {
/* clear flags for recursion check */
@@ -2648,7 +2672,7 @@ static int viewer_border_exec(bContext *C, wmOperator *op)
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
Image *ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, nullptr, &lock);
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (ibuf) {
ARegion *region = CTX_wm_region(C);
@@ -2684,7 +2708,7 @@ static int viewer_border_exec(bContext *C, wmOperator *op)
}
snode_notify(C, snode);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
}
else {
btree->flag &= ~NTREE_VIEWER_BORDER;
@@ -2724,7 +2748,7 @@ static int clear_viewer_border_exec(bContext *C, wmOperator *UNUSED(op))
btree->flag &= ~NTREE_VIEWER_BORDER;
snode_notify(C, snode);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
return OPERATOR_FINISHED;
}
@@ -2750,11 +2774,11 @@ static int node_cryptomatte_add_socket_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceNode *snode = CTX_wm_space_node(C);
PointerRNA ptr = CTX_data_pointer_get(C, "node");
bNodeTree *ntree = nullptr;
bNode *node = nullptr;
bNodeTree *ntree = NULL;
bNode *node = NULL;
if (ptr.data) {
node = (bNode *)ptr.data;
node = ptr.data;
ntree = (bNodeTree *)ptr.owner_id;
}
else if (snode && snode->edittree) {
@@ -2794,11 +2818,11 @@ static int node_cryptomatte_remove_socket_exec(bContext *C, wmOperator *UNUSED(o
{
SpaceNode *snode = CTX_wm_space_node(C);
PointerRNA ptr = CTX_data_pointer_get(C, "node");
bNodeTree *ntree = nullptr;
bNode *node = nullptr;
bNodeTree *ntree = NULL;
bNode *node = NULL;
if (ptr.data) {
node = (bNode *)ptr.data;
node = ptr.data;
ntree = (bNodeTree *)ptr.owner_id;
}
else if (snode && snode->edittree) {

View File

@@ -21,7 +21,7 @@
* \ingroup spnode
*/
#include <cstdlib>
#include <stdlib.h>
#include "MEM_guardedalloc.h"
@@ -135,7 +135,7 @@ static bNode *node_group_get_active(bContext *C, const char *node_idname)
if (node && STREQ(node->idname, node_idname)) {
return node;
}
return nullptr;
return NULL;
}
/** \} */
@@ -165,7 +165,7 @@ static int node_group_edit_exec(bContext *C, wmOperator *op)
ED_node_tree_pop(snode);
}
WM_event_add_notifier(C, NC_SCENE | ND_NODES, nullptr);
WM_event_add_notifier(C, NC_SCENE | ND_NODES, NULL);
return OPERATOR_FINISHED;
}
@@ -200,8 +200,7 @@ void NODE_OT_group_edit(wmOperatorType *ot)
static AnimationBasePathChange *animation_basepath_change_new(const char *src_basepath,
const char *dst_basepath)
{
AnimationBasePathChange *basepath_change = (AnimationBasePathChange *)MEM_callocN(
sizeof(*basepath_change), AT);
AnimationBasePathChange *basepath_change = MEM_callocN(sizeof(*basepath_change), AT);
basepath_change->src_basepath = src_basepath;
basepath_change->dst_basepath = dst_basepath;
return basepath_change;
@@ -219,13 +218,13 @@ static void animation_basepath_change_free(AnimationBasePathChange *basepath_cha
/* returns 1 if its OK */
static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
{
/* Clear new pointers, set in #ntreeCopyTree_ex_new_pointers. */
/* clear new pointers, set in copytree */
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
node->new_node = nullptr;
node->new_node = NULL;
}
ListBase anim_basepaths = {nullptr, nullptr};
LinkNode *nodes_delayed_free = nullptr;
ListBase anim_basepaths = {NULL, NULL};
LinkNode *nodes_delayed_free = NULL;
bNodeTree *ngroup = (bNodeTree *)gnode->id;
/* wgroup is a temporary copy of the NodeTree we're merging in
@@ -248,7 +247,7 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
/* keep track of this node's RNA "base" path (the part of the path identifying the node)
* if the old nodetree has animation data which potentially covers this node
*/
const char *old_animation_basepath = nullptr;
const char *old_animation_basepath = NULL;
if (wgroup->adt) {
PointerRNA ptr;
RNA_pointer_create(&wgroup->id, &RNA_Node, node, &ptr);
@@ -278,7 +277,7 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
node->flag |= NODE_SELECT;
}
bNodeLink *glinks_first = (bNodeLink *)ntree->links.last;
bNodeLink *glinks_first = ntree->links.last;
/* Add internal links to the ntree */
LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &wgroup->links) {
@@ -286,10 +285,10 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
BLI_addtail(&ntree->links, link);
}
bNodeLink *glinks_last = (bNodeLink *)ntree->links.last;
bNodeLink *glinks_last = ntree->links.last;
/* and copy across the animation,
* note that the animation data's action can be nullptr here */
* note that the animation data's action can be NULL here */
if (wgroup->adt) {
bAction *waction;
@@ -308,7 +307,7 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
/* free temp action too */
if (waction) {
BKE_id_free(bmain, waction);
wgroup->adt->action = nullptr;
wgroup->adt->action = NULL;
}
}
@@ -318,14 +317,14 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
/* restore external links to and from the gnode */
/* input links */
if (glinks_first != nullptr) {
if (glinks_first != NULL) {
for (bNodeLink *link = glinks_first->next; link != glinks_last->next; link = link->next) {
if (link->fromnode->type == NODE_GROUP_INPUT) {
const char *identifier = link->fromsock->identifier;
int num_external_links = 0;
/* find external links to this input */
for (bNodeLink *tlink = (bNodeLink *)ntree->links.first; tlink != glinks_first->next;
for (bNodeLink *tlink = ntree->links.first; tlink != glinks_first->next;
tlink = tlink->next) {
if (tlink->tonode == gnode && STREQ(tlink->tosock->identifier, identifier)) {
nodeAddLink(ntree, tlink->fromnode, tlink->fromsock, link->tonode, link->tosock);
@@ -349,11 +348,10 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
}
/* Also iterate over new links to cover passthrough links. */
glinks_last = (bNodeLink *)ntree->links.last;
glinks_last = ntree->links.last;
/* output links */
for (bNodeLink *link = (bNodeLink *)ntree->links.first; link != glinks_first->next;
link = link->next) {
for (bNodeLink *link = ntree->links.first; link != glinks_first->next; link = link->next) {
if (link->fromnode == gnode) {
const char *identifier = link->fromsock->identifier;
int num_internal_links = 0;
@@ -386,7 +384,7 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
}
while (nodes_delayed_free) {
bNode *node = (bNode *)BLI_linklist_pop(&nodes_delayed_free);
bNode *node = BLI_linklist_pop(&nodes_delayed_free);
nodeRemoveNode(bmain, ntree, node, false);
}
@@ -457,10 +455,10 @@ static int node_group_separate_selected(
/* clear new pointers, set in BKE_node_copy_ex(). */
LISTBASE_FOREACH (bNode *, node, &ngroup->nodes) {
node->new_node = nullptr;
node->new_node = NULL;
}
ListBase anim_basepaths = {nullptr, nullptr};
ListBase anim_basepaths = {NULL, NULL};
/* add selected nodes into the ntree */
LISTBASE_FOREACH_MUTABLE (bNode *, node, &ngroup->nodes) {
@@ -545,7 +543,7 @@ static int node_group_separate_selected(
}
/* and copy across the animation,
* note that the animation data's action can be nullptr here */
* note that the animation data's action can be NULL here */
if (ngroup->adt) {
/* now perform the moving */
BKE_animdata_transfer_by_basepath(bmain, &ngroup->id, &ntree->id, &anim_basepaths);
@@ -564,16 +562,16 @@ static int node_group_separate_selected(
return 1;
}
enum eNodeGroupSeparateType {
typedef enum eNodeGroupSeparateType {
NODE_GS_COPY,
NODE_GS_MOVE,
};
} eNodeGroupSeparateType;
/* Operator Property */
static const EnumPropertyItem node_group_separate_types[] = {
{NODE_GS_COPY, "COPY", 0, "Copy", "Copy to parent node tree, keep group intact"},
{NODE_GS_MOVE, "MOVE", 0, "Move", "Move to parent node tree, remove from group"},
{0, nullptr, 0, nullptr, nullptr},
{0, NULL, 0, NULL, NULL},
};
static int node_group_separate_exec(bContext *C, wmOperator *op)
@@ -630,8 +628,8 @@ static int node_group_separate_invoke(bContext *C,
uiLayout *layout = UI_popup_menu_layout(pup);
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
uiItemEnumO(layout, "NODE_OT_group_separate", nullptr, 0, "type", NODE_GS_COPY);
uiItemEnumO(layout, "NODE_OT_group_separate", nullptr, 0, "type", NODE_GS_MOVE);
uiItemEnumO(layout, "NODE_OT_group_separate", NULL, 0, "type", NODE_GS_COPY);
uiItemEnumO(layout, "NODE_OT_group_separate", NULL, 0, "type", NODE_GS_MOVE);
UI_popup_menu_end(C, pup);
@@ -676,12 +674,12 @@ static bool node_group_make_test_selected(bNodeTree *ntree,
int ok = true;
/* make a local pseudo node tree to pass to the node poll functions */
bNodeTree *ngroup = ntreeAddTree(nullptr, "Pseudo Node Group", ntree_idname);
bNodeTree *ngroup = ntreeAddTree(NULL, "Pseudo Node Group", ntree_idname);
/* check poll functions for selected nodes */
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node_group_make_use_node(node, gnode)) {
const char *disabled_hint = nullptr;
const char *disabled_hint = NULL;
if (node->typeinfo->poll_instance &&
!node->typeinfo->poll_instance(node, ngroup, &disabled_hint)) {
if (disabled_hint) {
@@ -783,7 +781,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
expose_visible = true;
}
ListBase anim_basepaths = {nullptr, nullptr};
ListBase anim_basepaths = {NULL, NULL};
/* move nodes over */
LISTBASE_FOREACH_MUTABLE (bNode *, node, &ntree->nodes) {
@@ -997,10 +995,10 @@ static bNode *node_group_make_from_selected(const bContext *C,
Main *bmain = CTX_data_main(C);
float min[2], max[2];
const int totselect = node_get_selected_minmax(ntree, nullptr, min, max, false);
const int totselect = node_get_selected_minmax(ntree, NULL, min, max, false);
/* don't make empty group */
if (totselect == 0) {
return nullptr;
return NULL;
}
/* new nodetree */
@@ -1031,7 +1029,7 @@ static int node_group_make_exec(bContext *C, wmOperator *op)
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
if (!node_group_make_test_selected(ntree, nullptr, ntree_idname, op->reports)) {
if (!node_group_make_test_selected(ntree, NULL, ntree_idname, op->reports)) {
return OPERATOR_CANCELLED;
}
@@ -1044,7 +1042,7 @@ static int node_group_make_exec(bContext *C, wmOperator *op)
if (ngroup) {
ED_node_tree_push(snode, ngroup, gnode);
LISTBASE_FOREACH (bNode *, node, &ngroup->nodes) {
sort_multi_input_socket_links(snode, node, nullptr, nullptr);
sort_multi_input_socket_links(snode, node, NULL, NULL);
}
ntreeUpdateTree(bmain, ngroup);
}

View File

@@ -275,7 +275,6 @@ void NODE_OT_hide_toggle(struct wmOperatorType *ot);
void NODE_OT_hide_socket_toggle(struct wmOperatorType *ot);
void NODE_OT_preview_toggle(struct wmOperatorType *ot);
void NODE_OT_options_toggle(struct wmOperatorType *ot);
void NODE_OT_active_preview_toggle(struct wmOperatorType *ot);
void NODE_OT_node_copy_color(struct wmOperatorType *ot);
void NODE_OT_read_viewlayers(struct wmOperatorType *ot);

View File

@@ -55,14 +55,12 @@
#include "node_intern.h" /* own include */
/* -------------------------------------------------------------------- */
/** \name Relations Helpers
* \{ */
/* ****************** Relations helpers *********************** */
static bool ntree_has_drivers(bNodeTree *ntree)
{
const AnimData *adt = BKE_animdata_from_id(&ntree->id);
if (adt == nullptr) {
if (adt == NULL) {
return false;
}
return !BLI_listbase_is_empty(&adt->drivers);
@@ -104,7 +102,7 @@ static bool node_group_has_output_dfs(bNode *node)
return false;
}
ntree->id.tag |= LIB_TAG_DOIT;
for (bNode *current_node = (bNode *)ntree->nodes.first; current_node != nullptr;
for (bNode *current_node = ntree->nodes.first; current_node != NULL;
current_node = current_node->next) {
if (current_node->type == NODE_GROUP) {
if (current_node->id && node_group_has_output_dfs(current_node)) {
@@ -122,7 +120,7 @@ static bool node_group_has_output(Main *bmain, bNode *node)
{
BLI_assert(ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP));
bNodeTree *ntree = (bNodeTree *)node->id;
if (ntree == nullptr) {
if (ntree == NULL) {
return false;
}
BKE_main_id_tag_listbase(&bmain->nodetrees, LIB_TAG_DOIT, false);
@@ -147,7 +145,7 @@ bool node_connected_to_output(Main *bmain, bNodeTree *ntree, bNode *node)
* is connected to and so eventually.
*/
if (ELEM(current_node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) {
if (current_node->id != nullptr && ntree_has_drivers((bNodeTree *)current_node->id)) {
if (current_node->id != NULL && ntree_has_drivers((bNodeTree *)current_node->id)) {
return true;
}
if (ntree_check_nodes_connected(ntree, node, current_node) &&
@@ -160,22 +158,23 @@ bool node_connected_to_output(Main *bmain, bNodeTree *ntree, bNode *node)
return true;
}
}
if (current_node->type == GEO_NODE_VIEWER) {
if (ntree_check_nodes_connected(ntree, node, current_node)) {
return true;
}
}
}
return false;
}
/** \} */
/* ****************** Add *********************** */
/* -------------------------------------------------------------------- */
/** \name Add Node
* \{ */
struct bNodeListItem {
typedef struct bNodeListItem {
struct bNodeListItem *next, *prev;
struct bNode *node;
};
} bNodeListItem;
struct NodeInsertOfsData {
typedef struct NodeInsertOfsData {
bNodeTree *ntree;
bNode *insert; /* inserted node */
bNode *prev, *next; /* prev/next node in the chain */
@@ -184,7 +183,7 @@ struct NodeInsertOfsData {
wmTimer *anim_timer;
float offset_x; /* offset to apply to node chain */
};
} NodeInsertOfsData;
static void clear_picking_highlight(ListBase *links)
{
@@ -195,8 +194,8 @@ static void clear_picking_highlight(ListBase *links)
static LinkData *create_drag_link(Main *bmain, SpaceNode *snode, bNode *node, bNodeSocket *sock)
{
LinkData *linkdata = (LinkData *)MEM_callocN(sizeof(LinkData), "drag link op link data");
bNodeLink *oplink = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "drag link op link");
LinkData *linkdata = MEM_callocN(sizeof(LinkData), "drag link op link data");
bNodeLink *oplink = MEM_callocN(sizeof(bNodeLink), "drag link op link");
linkdata->data = oplink;
if (sock->in_out == SOCK_OUT) {
oplink->fromnode = node;
@@ -231,10 +230,10 @@ static void pick_link(const bContext *C,
BLI_addtail(&nldrag->links, linkdata);
nodeRemLink(snode->edittree, link_to_pick);
BLI_assert(nldrag->last_node_hovered_while_dragging_a_link != nullptr);
BLI_assert(nldrag->last_node_hovered_while_dragging_a_link != NULL);
sort_multi_input_socket_links(
snode, nldrag->last_node_hovered_while_dragging_a_link, nullptr, nullptr);
snode, nldrag->last_node_hovered_while_dragging_a_link, NULL, NULL);
/* Send changed event to original link->tonode. */
if (node) {
@@ -262,7 +261,7 @@ static void pick_input_link_by_link_intersect(const bContext *C,
const int resolution = NODE_LINK_RESOL;
bNodeLink *link_to_pick = nullptr;
bNodeLink *link_to_pick = NULL;
clear_picking_highlight(&snode->edittree->links);
LISTBASE_FOREACH (bNodeLink *, link, &snode->edittree->links) {
if (link->tosock == socket) {
@@ -311,8 +310,8 @@ static void pick_input_link_by_link_intersect(const bContext *C,
static int sort_nodes_locx(const void *a, const void *b)
{
const bNodeListItem *nli1 = (const bNodeListItem *)a;
const bNodeListItem *nli2 = (const bNodeListItem *)b;
const bNodeListItem *nli1 = a;
const bNodeListItem *nli2 = b;
const bNode *node1 = nli1->node;
const bNode *node2 = nli2->node;
@@ -325,14 +324,14 @@ static int sort_nodes_locx(const void *a, const void *b)
static bool socket_is_available(bNodeTree *UNUSED(ntree), bNodeSocket *sock, const bool allow_used)
{
if (nodeSocketIsHidden(sock)) {
return false;
return 0;
}
if (!allow_used && (sock->flag & SOCK_IN_USE)) {
return false;
return 0;
}
return true;
return 1;
}
static bNodeSocket *best_socket_output(bNodeTree *ntree,
@@ -380,10 +379,10 @@ static bNodeSocket *best_socket_output(bNodeTree *ntree,
/* Always allow linking to an reroute node. The socket type of the reroute sockets might change
* after the link has been created. */
if (node->type == NODE_REROUTE) {
return (bNodeSocket *)node->outputs.first;
return node->outputs.first;
}
return nullptr;
return NULL;
}
/* this is a bit complicated, but designed to prioritize finding
@@ -415,7 +414,7 @@ static bNodeSocket *best_socket_input(bNodeTree *ntree, bNode *node, int num, in
}
}
return nullptr;
return NULL;
}
static bool snode_autoconnect_input(SpaceNode *snode,
@@ -436,10 +435,10 @@ static bool snode_autoconnect_input(SpaceNode *snode,
return true;
}
struct LinkAndPosition {
typedef struct LinkAndPosition {
struct bNodeLink *link;
float multi_socket_position[2];
};
} LinkAndPosition;
static int compare_link_by_y_position(const void *a, const void *b)
{
@@ -463,14 +462,14 @@ void sort_multi_input_socket_links(SpaceNode *snode,
}
/* The total is calculated in #node_update_nodetree, which runs before this draw step. */
int total_inputs = socket->total_inputs + 1;
struct LinkAndPosition **input_links = (LinkAndPosition **)MEM_malloc_arrayN(
struct LinkAndPosition **input_links = MEM_malloc_arrayN(
total_inputs, sizeof(LinkAndPosition *), __func__);
int index = 0;
LISTBASE_FOREACH (bNodeLink *, link, &snode->edittree->links) {
if (link->tosock == socket) {
struct LinkAndPosition *link_and_position = (LinkAndPosition *)MEM_callocN(
sizeof(struct LinkAndPosition), __func__);
struct LinkAndPosition *link_and_position = MEM_callocN(sizeof(struct LinkAndPosition),
__func__);
link_and_position->link = link;
node_link_calculate_multi_input_position(link->tosock->locx,
link->tosock->locy,
@@ -483,8 +482,7 @@ void sort_multi_input_socket_links(SpaceNode *snode,
}
if (drag_link) {
LinkAndPosition *link_and_position = (LinkAndPosition *)MEM_callocN(sizeof(LinkAndPosition),
__func__);
LinkAndPosition *link_and_position = MEM_callocN(sizeof(LinkAndPosition), __func__);
link_and_position->link = drag_link;
copy_v2_v2(link_and_position->multi_socket_position, cursor);
input_links[index] = link_and_position;
@@ -512,12 +510,11 @@ static void snode_autoconnect(Main *bmain,
const bool replace)
{
bNodeTree *ntree = snode->edittree;
ListBase *nodelist = (ListBase *)MEM_callocN(sizeof(ListBase), "items_list");
ListBase *nodelist = MEM_callocN(sizeof(ListBase), "items_list");
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->flag & NODE_SELECT) {
bNodeListItem *nli = (bNodeListItem *)MEM_mallocN(sizeof(bNodeListItem),
"temporary node list item");
bNodeListItem *nli = MEM_mallocN(sizeof(bNodeListItem), "temporary node list item");
nli->node = node;
BLI_addtail(nodelist, nli);
}
@@ -530,7 +527,7 @@ static void snode_autoconnect(Main *bmain,
LISTBASE_FOREACH (bNodeListItem *, nli, nodelist) {
bool has_selected_inputs = false;
if (nli->next == nullptr) {
if (nli->next == NULL) {
break;
}
@@ -544,7 +541,7 @@ static void snode_autoconnect(Main *bmain,
/* if there are selected sockets, connect those */
LISTBASE_FOREACH (bNodeSocket *, sock_to, &node_to->inputs) {
if (sock_to->flag & SELECT) {
has_selected_inputs = true;
has_selected_inputs = 1;
if (!socket_is_available(ntree, sock_to, replace)) {
continue;
@@ -596,28 +593,24 @@ static void snode_autoconnect(Main *bmain,
MEM_freeN(nodelist);
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Link Viewer Operator
* \{ */
/* *************************** link viewer op ******************** */
static int node_link_viewer(const bContext *C, bNode *tonode)
{
SpaceNode *snode = CTX_wm_space_node(C);
/* context check */
if (tonode == nullptr || BLI_listbase_is_empty(&tonode->outputs)) {
if (tonode == NULL || BLI_listbase_is_empty(&tonode->outputs)) {
return OPERATOR_CANCELLED;
}
if (ELEM(tonode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
if (ELEM(tonode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER, GEO_NODE_VIEWER)) {
return OPERATOR_CANCELLED;
}
/* get viewer */
bNode *viewer_node = nullptr;
bNode *viewer_node = NULL;
LISTBASE_FOREACH (bNode *, node, &snode->edittree->nodes) {
if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER, GEO_NODE_VIEWER)) {
if (node->flag & NODE_DO_OUTPUT) {
viewer_node = node;
break;
@@ -625,9 +618,9 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
}
}
/* no viewer, we make one active */
if (viewer_node == nullptr) {
if (viewer_node == NULL) {
LISTBASE_FOREACH (bNode *, node, &snode->edittree->nodes) {
if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER, GEO_NODE_VIEWER)) {
node->flag |= NODE_DO_OUTPUT;
viewer_node = node;
break;
@@ -635,14 +628,14 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
}
}
bNodeSocket *sock = nullptr;
bNodeLink *link = nullptr;
bNodeSocket *sock = NULL;
bNodeLink *link = NULL;
/* try to find an already connected socket to cycle to the next */
if (viewer_node) {
link = nullptr;
link = NULL;
for (link = (bNodeLink *)snode->edittree->links.first; link; link = link->next) {
for (link = snode->edittree->links.first; link; link = link->next) {
if (link->tonode == viewer_node && link->fromnode == tonode) {
if (link->tosock == viewer_node->inputs.first) {
break;
@@ -675,7 +668,7 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
/* find a socket starting from the first socket */
if (!sock) {
for (sock = (bNodeSocket *)tonode->outputs.first; sock; sock = sock->next) {
for (sock = tonode->outputs.first; sock; sock = sock->next) {
if (!nodeSocketIsHidden(sock)) {
break;
}
@@ -686,25 +679,24 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
/* add a new viewer if none exists yet */
if (!viewer_node) {
/* XXX location is a quick hack, just place it next to the linked socket */
viewer_node = node_add_node(C, nullptr, CMP_NODE_VIEWER, sock->locx + 100, sock->locy);
viewer_node = node_add_node(C, NULL, CMP_NODE_VIEWER, sock->locx + 100, sock->locy);
if (!viewer_node) {
return OPERATOR_CANCELLED;
}
link = nullptr;
link = NULL;
}
else {
/* get link to viewer */
for (link = (bNodeLink *)snode->edittree->links.first; link; link = link->next) {
for (link = snode->edittree->links.first; link; link = link->next) {
if (link->tonode == viewer_node && link->tosock == viewer_node->inputs.first) {
break;
}
}
}
if (link == nullptr) {
nodeAddLink(
snode->edittree, tonode, sock, viewer_node, (bNodeSocket *)viewer_node->inputs.first);
if (link == NULL) {
nodeAddLink(snode->edittree, tonode, sock, viewer_node, viewer_node->inputs.first);
}
else {
link->fromnode = tonode;
@@ -754,11 +746,7 @@ void NODE_OT_link_viewer(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Add Link Operator
* \{ */
/* *************************** add link op ******************** */
static void node_link_update_header(bContext *C, bNodeLinkDrag *UNUSED(nldrag))
{
@@ -796,7 +784,7 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeLink *link)
if (tlink && tlink->fromsock == from) {
if (from_count > from_link_limit) {
nodeRemLink(ntree, tlink);
tlink = nullptr;
tlink = NULL;
from_count--;
}
}
@@ -804,13 +792,13 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeLink *link)
if (tlink && tlink->tosock == to) {
if (to_count > to_link_limit) {
nodeRemLink(ntree, tlink);
tlink = nullptr;
tlink = NULL;
to_count--;
}
else if (tlink->fromsock == from) {
/* Also remove link if it comes from the same output. */
nodeRemLink(ntree, tlink);
tlink = nullptr;
tlink = NULL;
to_count--;
from_count--;
}
@@ -823,13 +811,13 @@ static void node_link_exit(bContext *C, wmOperator *op, bool apply_links)
Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
bNodeTree *ntree = snode->edittree;
bNodeLinkDrag *nldrag = (bNodeLinkDrag *)op->customdata;
bNodeLinkDrag *nldrag = op->customdata;
bool do_tag_update = false;
/* avoid updates while applying links */
ntree->is_updating = true;
LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) {
bNodeLink *link = (bNodeLink *)linkdata->data;
bNodeLink *link = linkdata->data;
/* See note below, but basically TEST flag means that the link
* was connected to output (or to a node which affects the
@@ -884,14 +872,14 @@ static void node_link_exit(bContext *C, wmOperator *op, bool apply_links)
static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
{
SpaceNode *snode = CTX_wm_space_node(C);
bNodeLinkDrag *nldrag = (bNodeLinkDrag *)op->customdata;
bNodeLinkDrag *nldrag = op->customdata;
if (nldrag->in_out == SOCK_OUT) {
bNode *tnode;
bNodeSocket *tsock = nullptr;
bNodeSocket *tsock = NULL;
if (node_find_indicated_socket(snode, &tnode, &tsock, cursor, SOCK_IN)) {
LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) {
bNodeLink *link = (bNodeLink *)linkdata->data;
bNodeLink *link = linkdata->data;
/* skip if socket is on the same node as the fromsock */
if (tnode && link->fromnode == tnode) {
@@ -899,7 +887,7 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
}
/* Skip if tsock is already linked with this output. */
bNodeLink *existing_link_connected_to_fromsock = nullptr;
bNodeLink *existing_link_connected_to_fromsock = NULL;
LISTBASE_FOREACH (bNodeLink *, existing_link, &snode->edittree->links) {
if (existing_link->fromsock == link->fromsock && existing_link->tosock == tsock) {
existing_link_connected_to_fromsock = existing_link;
@@ -923,22 +911,22 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
}
else {
LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) {
bNodeLink *link = (bNodeLink *)linkdata->data;
bNodeLink *link = linkdata->data;
if (nldrag->last_node_hovered_while_dragging_a_link) {
sort_multi_input_socket_links(
snode, nldrag->last_node_hovered_while_dragging_a_link, nullptr, cursor);
snode, nldrag->last_node_hovered_while_dragging_a_link, NULL, cursor);
}
link->tonode = nullptr;
link->tosock = nullptr;
link->tonode = NULL;
link->tosock = NULL;
}
}
}
else {
bNode *tnode;
bNodeSocket *tsock = nullptr;
bNodeSocket *tsock = NULL;
if (node_find_indicated_socket(snode, &tnode, &tsock, cursor, SOCK_OUT)) {
LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) {
bNodeLink *link = (bNodeLink *)linkdata->data;
bNodeLink *link = linkdata->data;
/* skip if this is already the target socket */
if (link->fromsock == tsock) {
@@ -956,10 +944,10 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
}
else {
LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) {
bNodeLink *link = (bNodeLink *)linkdata->data;
bNodeLink *link = linkdata->data;
link->fromnode = nullptr;
link->fromsock = nullptr;
link->fromnode = NULL;
link->fromsock = NULL;
}
}
}
@@ -969,7 +957,7 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
/* in_out = starting socket */
static int node_link_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
bNodeLinkDrag *nldrag = (bNodeLinkDrag *)op->customdata;
bNodeLinkDrag *nldrag = op->customdata;
ARegion *region = CTX_wm_region(C);
float cursor[2];
@@ -994,7 +982,7 @@ static int node_link_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (event->val == KM_RELEASE) {
node_link_exit(C, op, true);
ED_workspace_status_text(C, nullptr);
ED_workspace_status_text(C, NULL);
ED_region_tag_redraw(region);
SpaceNode *snode = CTX_wm_space_node(C);
clear_picking_highlight(&snode->edittree->links);
@@ -1010,13 +998,13 @@ static int node_link_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* return 1 when socket clicked */
static bNodeLinkDrag *node_link_init(Main *bmain, SpaceNode *snode, float cursor[2], bool detach)
{
bNodeLinkDrag *nldrag = nullptr;
bNodeLinkDrag *nldrag = NULL;
/* output indicated? */
bNode *node;
bNodeSocket *sock;
if (node_find_indicated_socket(snode, &node, &sock, cursor, SOCK_OUT)) {
nldrag = (bNodeLinkDrag *)MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata");
nldrag = MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata");
const int num_links = nodeCountSocketLinks(snode->edittree, sock);
int link_limit = nodeSocketLinkLimit(sock);
@@ -1026,11 +1014,11 @@ static bNodeLinkDrag *node_link_init(Main *bmain, SpaceNode *snode, float cursor
/* detach current links and store them in the operator data */
LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &snode->edittree->links) {
if (link->fromsock == sock) {
LinkData *linkdata = (LinkData *)MEM_callocN(sizeof(LinkData), "drag link op link data");
bNodeLink *oplink = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "drag link op link");
LinkData *linkdata = MEM_callocN(sizeof(LinkData), "drag link op link data");
bNodeLink *oplink = MEM_callocN(sizeof(bNodeLink), "drag link op link");
linkdata->data = oplink;
*oplink = *link;
oplink->next = oplink->prev = nullptr;
oplink->next = oplink->prev = NULL;
oplink->flag |= NODE_LINK_VALID;
/* The link could be disconnected and in that case we
@@ -1060,7 +1048,7 @@ static bNodeLinkDrag *node_link_init(Main *bmain, SpaceNode *snode, float cursor
}
/* or an input? */
else if (node_find_indicated_socket(snode, &node, &sock, cursor, SOCK_IN)) {
nldrag = (bNodeLinkDrag *)MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata");
nldrag = MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata");
nldrag->last_node_hovered_while_dragging_a_link = node;
const int num_links = nodeCountSocketLinks(snode->edittree, sock);
@@ -1078,12 +1066,12 @@ static bNodeLinkDrag *node_link_init(Main *bmain, SpaceNode *snode, float cursor
}
}
if (link_to_pick != nullptr && !nldrag->from_multi_input_socket) {
LinkData *linkdata = (LinkData *)MEM_callocN(sizeof(LinkData), "drag link op link data");
bNodeLink *oplink = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "drag link op link");
if (link_to_pick != NULL && !nldrag->from_multi_input_socket) {
LinkData *linkdata = MEM_callocN(sizeof(LinkData), "drag link op link data");
bNodeLink *oplink = MEM_callocN(sizeof(bNodeLink), "drag link op link");
linkdata->data = oplink;
*oplink = *link_to_pick;
oplink->next = oplink->prev = nullptr;
oplink->next = oplink->prev = NULL;
oplink->flag |= NODE_LINK_VALID;
oplink->flag &= ~NODE_LINK_TEST;
if (node_connected_to_output(bmain, snode->edittree, link_to_pick->tonode)) {
@@ -1144,7 +1132,7 @@ static int node_link_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void node_link_cancel(bContext *C, wmOperator *op)
{
SpaceNode *snode = CTX_wm_space_node(C);
bNodeLinkDrag *nldrag = (bNodeLinkDrag *)op->customdata;
bNodeLinkDrag *nldrag = op->customdata;
BLI_remlink(&snode->runtime->linkdrag, nldrag);
@@ -1184,7 +1172,7 @@ void NODE_OT_link(wmOperatorType *ot)
RNA_def_float_array(ot->srna,
"drag_start",
2,
nullptr,
0,
-UI_PRECISION_FLOAT_MAX,
UI_PRECISION_FLOAT_MAX,
"Drag Start",
@@ -1195,11 +1183,7 @@ void NODE_OT_link(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_HIDDEN);
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Make Link Operator
* \{ */
/* ********************** Make Link operator ***************** */
/* makes a link between selected output and input sockets */
static int node_make_link_exec(bContext *C, wmOperator *op)
@@ -1210,11 +1194,11 @@ static int node_make_link_exec(bContext *C, wmOperator *op)
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
snode_autoconnect(bmain, snode, true, replace);
snode_autoconnect(bmain, snode, 1, replace);
/* deselect sockets after linking */
node_deselect_all_input_sockets(snode, false);
node_deselect_all_output_sockets(snode, false);
node_deselect_all_input_sockets(snode, 0);
node_deselect_all_output_sockets(snode, 0);
ntreeUpdateTree(CTX_data_main(C), snode->edittree);
snode_notify(C, snode);
@@ -1239,37 +1223,27 @@ void NODE_OT_link_make(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(
ot->srna, "replace", false, "Replace", "Replace socket connections with the new links");
ot->srna, "replace", 0, "Replace", "Replace socket connections with the new links");
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Node Link Intersect
* \{ */
/* ********************** Node Link Intersect ***************** */
static bool node_links_intersect(bNodeLink *link, const float mcoords[][2], int tot)
{
float coord_array[NODE_LINK_RESOL + 1][2];
if (node_link_bezier_points(nullptr, nullptr, link, coord_array, NODE_LINK_RESOL)) {
if (node_link_bezier_points(NULL, NULL, link, coord_array, NODE_LINK_RESOL)) {
for (int i = 0; i < tot - 1; i++) {
for (int b = 0; b < NODE_LINK_RESOL; b++) {
if (isect_seg_seg_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0) {
return true;
return 1;
}
}
}
}
return false;
return 0;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Cut Link Operator
* \{ */
/* ********************** Cut Link operator ***************** */
static int cut_links_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
@@ -1316,7 +1290,7 @@ static int cut_links_exec(bContext *C, wmOperator *op)
snode_update(snode, link->tonode);
bNode *to_node = link->tonode;
nodeRemLink(snode->edittree, link);
sort_multi_input_socket_links(snode, to_node, nullptr, nullptr);
sort_multi_input_socket_links(snode, to_node, NULL, NULL);
}
}
@@ -1355,17 +1329,13 @@ void NODE_OT_links_cut(wmOperatorType *ot)
/* properties */
PropertyRNA *prop;
prop = RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
RNA_def_property_flag(prop, (PropertyFlag)(PROP_HIDDEN | PROP_SKIP_SAVE));
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
/* internal */
RNA_def_int(ot->srna, "cursor", WM_CURSOR_KNIFE, 0, INT_MAX, "Cursor", "", 0, INT_MAX);
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Mute Links Operator
* \{ */
/* ********************** Mute links operator ***************** */
static int mute_links_exec(bContext *C, wmOperator *op)
{
@@ -1461,17 +1431,13 @@ void NODE_OT_links_mute(wmOperatorType *ot)
/* properties */
PropertyRNA *prop;
prop = RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
RNA_def_property_flag(prop, (PropertyFlag)(PROP_HIDDEN | PROP_SKIP_SAVE));
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
/* internal */
RNA_def_int(ot->srna, "cursor", WM_CURSOR_MUTE, 0, INT_MAX, "Cursor", "", 0, INT_MAX);
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Detach Links Operator
* \{ */
/* ********************** Detach links operator ***************** */
static int detach_links_exec(bContext *C, wmOperator *UNUSED(op))
{
@@ -1508,11 +1474,7 @@ void NODE_OT_links_detach(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Set Parent Operator
* \{ */
/* ****************** Set Parent ******************* */
static int node_parent_set_exec(bContext *C, wmOperator *UNUSED(op))
{
@@ -1534,7 +1496,7 @@ static int node_parent_set_exec(bContext *C, wmOperator *UNUSED(op))
}
ED_node_sort(ntree);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
return OPERATOR_FINISHED;
}
@@ -1554,11 +1516,7 @@ void NODE_OT_parent_set(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Join Nodes Operator
* \{ */
/* ****************** Join Nodes ******************* */
/* tags for depth-first search */
#define NODE_JOIN_DONE 1
@@ -1610,7 +1568,7 @@ static int node_join_exec(bContext *C, wmOperator *UNUSED(op))
}
}
bNode *frame = node_add_node(C, nullptr, NODE_FRAME, 0.0f, 0.0f);
bNode *frame = node_add_node(C, NULL, NODE_FRAME, 0.0f, 0.0f);
/* reset tags */
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
@@ -1631,7 +1589,7 @@ static int node_join_exec(bContext *C, wmOperator *UNUSED(op))
}
ED_node_sort(ntree);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
return OPERATOR_FINISHED;
}
@@ -1651,11 +1609,7 @@ void NODE_OT_join(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Attach Operator
* \{ */
/* ****************** Attach ******************* */
static bNode *node_find_frame_to_attach(ARegion *region,
const bNodeTree *ntree,
@@ -1675,7 +1629,7 @@ static bNode *node_find_frame_to_attach(ARegion *region,
}
}
return nullptr;
return NULL;
}
static int node_attach_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
@@ -1688,7 +1642,7 @@ static int node_attach_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent
if (frame) {
LISTBASE_FOREACH_BACKWARD (bNode *, node, &ntree->nodes) {
if (node->flag & NODE_SELECT) {
if (node->parent == nullptr) {
if (node->parent == NULL) {
/* disallow moving a parent into its child */
if (nodeAttachNodeCheck(frame, node) == false) {
/* attach all unparented nodes */
@@ -1717,7 +1671,7 @@ static int node_attach_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent
}
ED_node_sort(ntree);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
return OPERATOR_FINISHED;
}
@@ -1738,11 +1692,7 @@ void NODE_OT_attach(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Detach Operator
* \{ */
/* ****************** Detach ******************* */
/* tags for depth-first search */
#define NODE_DETACH_DONE 1
@@ -1793,7 +1743,7 @@ static int node_detach_exec(bContext *C, wmOperator *UNUSED(op))
}
ED_node_sort(ntree);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
return OPERATOR_FINISHED;
}
@@ -1813,11 +1763,7 @@ void NODE_OT_detach(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Automatic Node Insert on Dragging
* \{ */
/* ********************* automatic node insert on dragging ******************* */
/* prevent duplicate testing code below */
static bool ed_node_link_conditions(ScrArea *area,
@@ -1825,13 +1771,13 @@ static bool ed_node_link_conditions(ScrArea *area,
SpaceNode **r_snode,
bNode **r_select)
{
SpaceNode *snode = area ? (SpaceNode *)area->spacedata.first : nullptr;
SpaceNode *snode = area ? area->spacedata.first : NULL;
*r_snode = snode;
*r_select = nullptr;
*r_select = NULL;
/* no unlucky accidents */
if (area == nullptr || area->spacetype != SPACE_NODE) {
if (area == NULL || area->spacetype != SPACE_NODE) {
return false;
}
@@ -1841,8 +1787,8 @@ static bool ed_node_link_conditions(ScrArea *area,
}
bNode *node;
bNode *select = nullptr;
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
bNode *select = NULL;
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (node->flag & SELECT) {
if (select) {
break;
@@ -1851,7 +1797,7 @@ static bool ed_node_link_conditions(ScrArea *area,
}
}
/* only one selected */
if (node || select == nullptr) {
if (node || select == NULL) {
return false;
}
@@ -1894,7 +1840,7 @@ void ED_node_link_intersect_test(ScrArea *area, int test)
}
/* find link to select/highlight */
bNodeLink *selink = nullptr;
bNodeLink *selink = NULL;
float dist_best = FLT_MAX;
LISTBASE_FOREACH (bNodeLink *, link, &snode->edittree->links) {
float coord_array[NODE_LINK_RESOL + 1][2];
@@ -1903,7 +1849,7 @@ void ED_node_link_intersect_test(ScrArea *area, int test)
continue;
}
if (node_link_bezier_points(nullptr, nullptr, link, coord_array, NODE_LINK_RESOL)) {
if (node_link_bezier_points(NULL, NULL, link, coord_array, NODE_LINK_RESOL)) {
float dist = FLT_MAX;
/* loop over link coords to find shortest dist to
@@ -1935,12 +1881,6 @@ void ED_node_link_intersect_test(ScrArea *area, int test)
}
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Node Insert Offset Operator
* \{ */
static int get_main_socket_priority(const bNodeSocket *socket)
{
switch ((eNodeSocketDatatype)socket->type) {
@@ -2004,7 +1944,7 @@ static bNodeSocket *get_main_socket(ListBase *sockets)
}
}
return nullptr;
return NULL;
}
static bool node_parents_offset_flag_enable_cb(bNode *parent, void *UNUSED(userdata))
@@ -2042,7 +1982,7 @@ static void node_parent_offset_apply(NodeInsertOfsData *data, bNode *parent, con
#define NODE_INSOFS_ANIM_DURATION 0.25f
/**
* Callback that applies #NodeInsertOfsData.offset_x to a node or its parent, similar
* Callback that applies NodeInsertOfsData.offset_x to a node or its parent, similar
* to node_link_insert_offset_output_chain_cb below, but with slightly different logic
*/
static bool node_link_insert_offset_frame_chain_cb(bNode *fromnode,
@@ -2050,7 +1990,7 @@ static bool node_link_insert_offset_frame_chain_cb(bNode *fromnode,
void *userdata,
const bool reversed)
{
NodeInsertOfsData *data = (NodeInsertOfsData *)userdata;
NodeInsertOfsData *data = userdata;
bNode *ofs_node = reversed ? fromnode : tonode;
if (ofs_node->parent && ofs_node->parent != data->insert_parent) {
@@ -2087,7 +2027,7 @@ static bool node_link_insert_offset_chain_cb(bNode *fromnode,
void *userdata,
const bool reversed)
{
NodeInsertOfsData *data = (NodeInsertOfsData *)userdata;
NodeInsertOfsData *data = userdata;
bNode *ofs_node = reversed ? fromnode : tonode;
if (data->insert_parent) {
@@ -2100,7 +2040,7 @@ static bool node_link_insert_offset_chain_cb(bNode *fromnode,
}
if (nodeIsChildOf(data->insert_parent, ofs_node) == false) {
data->insert_parent = nullptr;
data->insert_parent = NULL;
}
}
else if (ofs_node->parent) {
@@ -2151,7 +2091,7 @@ static void node_link_insert_offset_ntree(NodeInsertOfsData *iofsd,
rctf totr_frame;
/* check nodes front to back */
for (frame = (bNode *)ntree->nodes.last; frame; frame = frame->prev) {
for (frame = ntree->nodes.last; frame; frame = frame->prev) {
/* skip selected, those are the nodes we want to attach */
if ((frame->type != NODE_FRAME) || (frame->flag & NODE_SELECT)) {
continue;
@@ -2217,7 +2157,7 @@ static void node_link_insert_offset_ntree(NodeInsertOfsData *iofsd,
iofsd->offset_x = margin;
/* flag all parents of insert as offset to prevent them from being offset */
nodeParentsIter(insert, node_parents_offset_flag_enable_cb, nullptr);
nodeParentsIter(insert, node_parents_offset_flag_enable_cb, NULL);
/* iterate over entire chain and apply offsets */
nodeChainIter(ntree,
right_alignment ? next : prev,
@@ -2238,8 +2178,7 @@ static int node_insert_offset_modal(bContext *C, wmOperator *UNUSED(op), const w
NodeInsertOfsData *iofsd = snode->runtime->iofsd;
bool redraw = false;
if (!snode || event->type != TIMER || iofsd == nullptr ||
iofsd->anim_timer != event->customdata) {
if (!snode || event->type != TIMER || iofsd == NULL || iofsd->anim_timer != event->customdata) {
return OPERATOR_PASS_THROUGH;
}
@@ -2269,13 +2208,13 @@ static int node_insert_offset_modal(bContext *C, wmOperator *UNUSED(op), const w
/* end timer + free insert offset data */
if (duration > NODE_INSOFS_ANIM_DURATION) {
WM_event_remove_timer(CTX_wm_manager(C), nullptr, iofsd->anim_timer);
WM_event_remove_timer(CTX_wm_manager(C), NULL, iofsd->anim_timer);
LISTBASE_FOREACH (bNode *, node, &snode->edittree->nodes) {
node->anim_init_locx = node->anim_ofsx = 0.0f;
}
snode->runtime->iofsd = nullptr;
snode->runtime->iofsd = NULL;
MEM_freeN(iofsd);
return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH);
@@ -2325,12 +2264,6 @@ void NODE_OT_insert_offset(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Note Link Insert
* \{ */
/* assumes link with NODE_LINKFLAG_HILITE set */
void ED_node_link_insert(Main *bmain, ScrArea *area)
{
@@ -2342,7 +2275,7 @@ void ED_node_link_insert(Main *bmain, ScrArea *area)
/* get the link */
bNodeLink *link;
for (link = (bNodeLink *)snode->edittree->links.first; link; link = link->next) {
for (link = snode->edittree->links.first; link; link = link->next) {
if (link->flag & NODE_LINKFLAG_HILITE) {
break;
}
@@ -2370,8 +2303,7 @@ void ED_node_link_insert(Main *bmain, ScrArea *area)
/* set up insert offset data, it needs stuff from here */
if ((snode->flag & SNODE_SKIP_INSOFFSET) == 0) {
NodeInsertOfsData *iofsd = (NodeInsertOfsData *)MEM_callocN(sizeof(NodeInsertOfsData),
__func__);
NodeInsertOfsData *iofsd = MEM_callocN(sizeof(NodeInsertOfsData), __func__);
iofsd->insert = select;
iofsd->prev = link->fromnode;
@@ -2387,5 +2319,3 @@ void ED_node_link_insert(Main *bmain, ScrArea *area)
}
}
}
/** \} */

View File

@@ -21,8 +21,7 @@
* \ingroup spnode
*/
#include <array>
#include <cstdlib>
#include <stdlib.h>
#include "DNA_node_types.h"
#include "DNA_windowmanager_types.h"
@@ -82,7 +81,7 @@ static bool has_workbench_in_texture_color(const wmWindowManager *wm,
const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
if (area->spacetype == SPACE_VIEW3D) {
const View3D *v3d = (const View3D *)area->spacedata.first;
const View3D *v3d = area->spacedata.first;
if (ED_view3d_has_workbench_in_texture_color(scene, ob, v3d)) {
return true;
@@ -101,28 +100,28 @@ static bNode *node_under_mouse_select(bNodeTree *ntree, int mx, int my)
{
bNode *node;
for (node = (bNode *)ntree->nodes.last; node; node = node->prev) {
for (node = ntree->nodes.last; node; node = node->prev) {
if (node->typeinfo->select_area_func) {
if (node->typeinfo->select_area_func(node, mx, my)) {
return node;
}
}
}
return nullptr;
return NULL;
}
static bNode *node_under_mouse_tweak(bNodeTree *ntree, int mx, int my)
{
bNode *node;
for (node = (bNode *)ntree->nodes.last; node; node = node->prev) {
for (node = ntree->nodes.last; node; node = node->prev) {
if (node->typeinfo->tweak_area_func) {
if (node->typeinfo->tweak_area_func(node, mx, my)) {
return node;
}
}
}
return nullptr;
return NULL;
}
static bool is_position_over_node_or_socket(SpaceNode *snode, float mouse[2])
@@ -169,18 +168,18 @@ void node_socket_deselect(bNode *node, bNodeSocket *sock, const bool deselect_no
sock->flag &= ~SELECT;
if (node && deselect_node) {
bool sel = false;
bool sel = 0;
/* if no selected sockets remain, also deselect the node */
for (sock = (bNodeSocket *)node->inputs.first; sock; sock = sock->next) {
for (sock = node->inputs.first; sock; sock = sock->next) {
if (sock->flag & SELECT) {
sel = true;
sel = 1;
break;
}
}
for (sock = (bNodeSocket *)node->outputs.first; sock; sock = sock->next) {
for (sock = node->outputs.first; sock; sock = sock->next) {
if (sock->flag & SELECT) {
sel = true;
sel = 1;
break;
}
}
@@ -206,7 +205,7 @@ void node_deselect_all(SpaceNode *snode)
{
bNode *node;
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
for (node = snode->edittree->nodes.first; node; node = node->next) {
nodeSetSelected(node, false);
}
}
@@ -221,16 +220,16 @@ void node_deselect_all_input_sockets(SpaceNode *snode, const bool deselect_nodes
* We can do that more efficiently here.
*/
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
for (node = snode->edittree->nodes.first; node; node = node->next) {
int sel = 0;
for (sock = (bNodeSocket *)node->inputs.first; sock; sock = sock->next) {
for (sock = node->inputs.first; sock; sock = sock->next) {
sock->flag &= ~SELECT;
}
/* if no selected sockets remain, also deselect the node */
if (deselect_nodes) {
for (sock = (bNodeSocket *)node->outputs.first; sock; sock = sock->next) {
for (sock = node->outputs.first; sock; sock = sock->next) {
if (sock->flag & SELECT) {
sel = 1;
break;
@@ -254,18 +253,18 @@ void node_deselect_all_output_sockets(SpaceNode *snode, const bool deselect_node
* We can do that more efficiently here.
*/
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
for (node = snode->edittree->nodes.first; node; node = node->next) {
bool sel = false;
for (sock = (bNodeSocket *)node->outputs.first; sock; sock = sock->next) {
for (sock = node->outputs.first; sock; sock = sock->next) {
sock->flag &= ~SELECT;
}
/* if no selected sockets remain, also deselect the node */
if (deselect_nodes) {
for (sock = (bNodeSocket *)node->inputs.first; sock; sock = sock->next) {
for (sock = node->inputs.first; sock; sock = sock->next) {
if (sock->flag & SELECT) {
sel = true;
sel = 1;
break;
}
}
@@ -290,7 +289,7 @@ static bool node_select_grouped_type(SpaceNode *snode, bNode *node_act)
bNode *node;
bool changed = false;
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
for (node = snode->edittree->nodes.first; node; node = node->next) {
if ((node->flag & SELECT) == 0) {
if (node->type == node_act->type) {
nodeSetSelected(node, true);
@@ -307,7 +306,7 @@ static bool node_select_grouped_color(SpaceNode *snode, bNode *node_act)
bNode *node;
bool changed = false;
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
for (node = snode->edittree->nodes.first; node; node = node->next) {
if ((node->flag & SELECT) == 0) {
if (compare_v3v3(node->color, node_act->color, 0.005f)) {
nodeSetSelected(node, true);
@@ -328,7 +327,7 @@ static bool node_select_grouped_name(SpaceNode *snode, bNode *node_act, const bo
const char *sep, *suf_act, *suf_curr;
pref_len_act = BLI_str_partition_ex_utf8(
node_act->name, nullptr, delims, &sep, &suf_act, from_right);
node_act->name, NULL, delims, &sep, &suf_act, from_right);
/* Note: in case we are searching for suffix, and found none, use whole name as suffix. */
if (from_right && !(sep && suf_act)) {
@@ -336,12 +335,12 @@ static bool node_select_grouped_name(SpaceNode *snode, bNode *node_act, const bo
suf_act = node_act->name;
}
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (node->flag & SELECT) {
continue;
}
pref_len_curr = BLI_str_partition_ex_utf8(
node->name, nullptr, delims, &sep, &suf_curr, from_right);
node->name, NULL, delims, &sep, &suf_curr, from_right);
/* Same as with active node name! */
if (from_right && !(sep && suf_curr)) {
@@ -372,7 +371,7 @@ static int node_select_grouped_exec(bContext *C, wmOperator *op)
SpaceNode *snode = CTX_wm_space_node(C);
bNode *node_act = nodeGetActive(snode->edittree);
if (node_act == nullptr) {
if (node_act == NULL) {
return OPERATOR_CANCELLED;
}
@@ -382,7 +381,7 @@ static int node_select_grouped_exec(bContext *C, wmOperator *op)
const int type = RNA_enum_get(op->ptr, "type");
if (!extend) {
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
for (node = snode->edittree->nodes.first; node; node = node->next) {
nodeSetSelected(node, false);
}
}
@@ -407,7 +406,7 @@ static int node_select_grouped_exec(bContext *C, wmOperator *op)
if (changed) {
ED_node_sort(snode->edittree);
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
@@ -421,7 +420,7 @@ void NODE_OT_select_grouped(wmOperatorType *ot)
{NODE_SELECT_GROUPED_COLOR, "COLOR", 0, "Color", ""},
{NODE_SELECT_GROUPED_PREFIX, "PREFIX", 0, "Prefix", ""},
{NODE_SELECT_GROUPED_SUFIX, "SUFFIX", 0, "Suffix", ""},
{0, nullptr, 0, nullptr, nullptr},
{0, NULL, 0, NULL, NULL},
};
/* identifiers */
@@ -462,14 +461,14 @@ void node_select_single(bContext *C, bNode *node)
bool active_texture_changed = false;
bNode *tnode;
for (tnode = (bNode *)snode->edittree->nodes.first; tnode; tnode = tnode->next) {
for (tnode = snode->edittree->nodes.first; tnode; tnode = tnode->next) {
if (tnode != node) {
nodeSetSelected(tnode, false);
}
}
nodeSetSelected(node, true);
ED_node_set_active(bmain, snode->edittree, node, &active_texture_changed);
ED_node_set_active(bmain, snode, snode->edittree, node, &active_texture_changed);
ED_node_set_active_viewer_key(snode);
ED_node_sort(snode->edittree);
@@ -477,7 +476,7 @@ void node_select_single(bContext *C, bNode *node)
DEG_id_tag_update(&snode->edittree->id, ID_RECALC_COPY_ON_WRITE);
}
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
}
static int node_mouse_select(bContext *C,
@@ -492,7 +491,7 @@ static int node_mouse_select(bContext *C,
const Scene *scene = CTX_data_scene(C);
const wmWindowManager *wm = CTX_wm_manager(C);
bNode *node, *tnode;
bNodeSocket *sock = nullptr;
bNodeSocket *sock = NULL;
bNodeSocket *tsock;
float cursor[2];
int ret_value = OPERATOR_CANCELLED;
@@ -531,7 +530,7 @@ static int node_mouse_select(bContext *C,
/* Only allow one selected output per node, for sensible linking.
* Allow selecting outputs from different nodes though, if extend is true. */
if (node) {
for (tsock = (bNodeSocket *)node->outputs.first; tsock; tsock = tsock->next) {
for (tsock = node->outputs.first; tsock; tsock = tsock->next) {
if (tsock == sock) {
continue;
}
@@ -539,11 +538,11 @@ static int node_mouse_select(bContext *C,
}
}
if (!extend) {
for (tnode = (bNode *)snode->edittree->nodes.first; tnode; tnode = tnode->next) {
for (tnode = snode->edittree->nodes.first; tnode; tnode = tnode->next) {
if (tnode == node) {
continue;
}
for (tsock = (bNodeSocket *)tnode->outputs.first; tsock; tsock = tsock->next) {
for (tsock = tnode->outputs.first; tsock; tsock = tsock->next) {
node_socket_deselect(tnode, tsock, true);
}
}
@@ -559,7 +558,7 @@ static int node_mouse_select(bContext *C,
node = node_under_mouse_select(snode->edittree, (int)cursor[0], (int)cursor[1]);
if (extend) {
if (node != nullptr) {
if (node != NULL) {
/* If node is selected but not active, we want to make it active,
* but not toggle (deselect) it. */
if (!((node->flag & SELECT) && (node->flag & NODE_ACTIVE) == 0)) {
@@ -568,7 +567,7 @@ static int node_mouse_select(bContext *C,
ret_value = OPERATOR_FINISHED;
}
}
else if (deselect_all && node == nullptr) {
else if (deselect_all && node == NULL) {
/* Rather than deselecting others, users may want to drag to box-select (drag from empty
* space) or tweak-translate an already selected item. If these cases may apply, delay
* deselection. */
@@ -577,13 +576,13 @@ static int node_mouse_select(bContext *C,
}
else {
/* Deselect in empty space. */
for (tnode = (bNode *)snode->edittree->nodes.first; tnode; tnode = tnode->next) {
for (tnode = snode->edittree->nodes.first; tnode; tnode = tnode->next) {
nodeSetSelected(tnode, false);
}
ret_value = OPERATOR_FINISHED;
}
}
else if (node != nullptr) {
else if (node != NULL) {
/* When clicking on an already selected node, we want to wait to deselect
* others and allow the user to start moving the node without that. */
if (wait_to_deselect_others && (node->flag & SELECT)) {
@@ -592,7 +591,7 @@ static int node_mouse_select(bContext *C,
else {
nodeSetSelected(node, true);
for (tnode = (bNode *)snode->edittree->nodes.first; tnode; tnode = tnode->next) {
for (tnode = snode->edittree->nodes.first; tnode; tnode = tnode->next) {
if (tnode != node) {
nodeSetSelected(tnode, false);
}
@@ -606,16 +605,19 @@ static int node_mouse_select(bContext *C,
/* update node order */
if (ret_value != OPERATOR_CANCELLED) {
bool active_texture_changed = false;
if (node != nullptr && ret_value != OPERATOR_RUNNING_MODAL) {
ED_node_set_active(bmain, snode->edittree, node, &active_texture_changed);
bool viewer_node_changed = false;
if (node != NULL && ret_value != OPERATOR_RUNNING_MODAL) {
ED_node_set_active(bmain, snode, snode->edittree, node, &active_texture_changed);
viewer_node_changed = node->type == GEO_NODE_VIEWER;
}
ED_node_set_active_viewer_key(snode);
ED_node_sort(snode->edittree);
if (active_texture_changed && has_workbench_in_texture_color(wm, scene, ob)) {
if ((active_texture_changed && has_workbench_in_texture_color(wm, scene, ob)) ||
viewer_node_changed) {
DEG_id_tag_update(&snode->edittree->id, ID_RECALC_COPY_ON_WRITE);
}
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
}
return ret_value;
@@ -682,7 +684,7 @@ static int node_box_select_exec(bContext *C, wmOperator *op)
WM_operator_properties_border_to_rctf(op, &rectf);
UI_view2d_region_to_view_rctf(&region->v2d, &rectf, &rectf);
const eSelectOp sel_op = (eSelectOp)RNA_enum_get(op->ptr, "mode");
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const bool select = (sel_op != SEL_OP_SUB);
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
ED_node_select_all(&snode->edittree->nodes, SEL_DESELECT);
@@ -694,7 +696,7 @@ static int node_box_select_exec(bContext *C, wmOperator *op)
is_inside = BLI_rctf_inside_rctf(&rectf, &node->totr);
}
else {
is_inside = BLI_rctf_isect(&rectf, &node->totr, nullptr);
is_inside = BLI_rctf_isect(&rectf, &node->totr, NULL);
}
if (is_inside) {
@@ -704,7 +706,7 @@ static int node_box_select_exec(bContext *C, wmOperator *op)
ED_node_sort(snode->edittree);
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
@@ -741,7 +743,7 @@ void NODE_OT_select_box(wmOperatorType *ot)
/* properties */
RNA_def_boolean(ot->srna,
"tweak",
false,
0,
"Tweak",
"Only activate when mouse is not over a node (useful for tweak gesture)");
@@ -767,9 +769,8 @@ static int node_circleselect_exec(bContext *C, wmOperator *op)
float zoom = (float)(BLI_rcti_size_x(&region->winrct)) /
(float)(BLI_rctf_size_x(&region->v2d.cur));
const eSelectOp sel_op = ED_select_op_modal(
(eSelectOp)RNA_enum_get(op->ptr, "mode"),
WM_gesture_is_modal_first((const wmGesture *)op->customdata));
const eSelectOp sel_op = ED_select_op_modal(RNA_enum_get(op->ptr, "mode"),
WM_gesture_is_modal_first(op->customdata));
const bool select = (sel_op != SEL_OP_SUB);
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
ED_node_select_all(&snode->edittree->nodes, SEL_DESELECT);
@@ -782,13 +783,13 @@ static int node_circleselect_exec(bContext *C, wmOperator *op)
UI_view2d_region_to_view(&region->v2d, x, y, &offset[0], &offset[1]);
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (BLI_rctf_isect_circle(&node->totr, offset, radius / zoom)) {
nodeSetSelected(node, select);
}
}
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
@@ -855,7 +856,7 @@ static bool do_lasso_select_node(bContext *C,
BLI_lasso_boundbox(&rect, mcoords, mcoords_len);
/* do actual selection */
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (select && (node->flag & NODE_SELECT)) {
continue;
@@ -875,7 +876,7 @@ static bool do_lasso_select_node(bContext *C,
}
if (changed) {
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
}
return changed;
@@ -887,7 +888,7 @@ static int node_lasso_select_exec(bContext *C, wmOperator *op)
const int(*mcoords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcoords_len);
if (mcoords) {
const eSelectOp sel_op = (eSelectOp)RNA_enum_get(op->ptr, "mode");
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
do_lasso_select_node(C, mcoords, mcoords_len, sel_op);
@@ -918,7 +919,7 @@ void NODE_OT_select_lasso(wmOperatorType *ot)
/* properties */
RNA_def_boolean(ot->srna,
"tweak",
false,
0,
"Tweak",
"Only activate when mouse is not over a node (useful for tweak gesture)");
@@ -942,7 +943,7 @@ static int node_select_all_exec(bContext *C, wmOperator *op)
ED_node_sort(snode->edittree);
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
@@ -975,11 +976,11 @@ static int node_select_linked_to_exec(bContext *C, wmOperator *UNUSED(op))
bNodeLink *link;
bNode *node;
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
for (node = snode->edittree->nodes.first; node; node = node->next) {
node->flag &= ~NODE_TEST;
}
for (link = (bNodeLink *)snode->edittree->links.first; link; link = link->next) {
for (link = snode->edittree->links.first; link; link = link->next) {
if (nodeLinkIsHidden(link)) {
continue;
}
@@ -988,7 +989,7 @@ static int node_select_linked_to_exec(bContext *C, wmOperator *UNUSED(op))
}
}
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (node->flag & NODE_TEST) {
nodeSetSelected(node, true);
}
@@ -996,7 +997,7 @@ static int node_select_linked_to_exec(bContext *C, wmOperator *UNUSED(op))
ED_node_sort(snode->edittree);
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
@@ -1027,11 +1028,11 @@ static int node_select_linked_from_exec(bContext *C, wmOperator *UNUSED(op))
bNodeLink *link;
bNode *node;
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
for (node = snode->edittree->nodes.first; node; node = node->next) {
node->flag &= ~NODE_TEST;
}
for (link = (bNodeLink *)snode->edittree->links.first; link; link = link->next) {
for (link = snode->edittree->links.first; link; link = link->next) {
if (nodeLinkIsHidden(link)) {
continue;
}
@@ -1040,7 +1041,7 @@ static int node_select_linked_from_exec(bContext *C, wmOperator *UNUSED(op))
}
}
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (node->flag & NODE_TEST) {
nodeSetSelected(node, true);
}
@@ -1048,7 +1049,7 @@ static int node_select_linked_from_exec(bContext *C, wmOperator *UNUSED(op))
ED_node_sort(snode->edittree);
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
@@ -1081,7 +1082,7 @@ static int node_select_same_type_step_exec(bContext *C, wmOperator *op)
bNode *active = nodeGetActive(snode->edittree);
int totnodes;
const bool revert = RNA_boolean_get(op->ptr, "prev");
const bool same_type = true;
const bool same_type = 1;
ntreeGetDependencyList(snode->edittree, &node_array, &totnodes);
@@ -1095,9 +1096,9 @@ static int node_select_same_type_step_exec(bContext *C, wmOperator *op)
}
if (same_type) {
bNode *node = nullptr;
bNode *node = NULL;
while (node == nullptr) {
while (node == NULL) {
if (revert) {
a--;
}
@@ -1114,7 +1115,7 @@ static int node_select_same_type_step_exec(bContext *C, wmOperator *op)
if (node->type == active->type) {
break;
}
node = nullptr;
node = NULL;
}
if (node) {
active = node;
@@ -1170,7 +1171,7 @@ void NODE_OT_select_same_type_step(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "prev", false, "Previous", "");
RNA_def_boolean(ot->srna, "prev", 0, "Previous", "");
}
/** \} */
@@ -1225,7 +1226,7 @@ static void node_find_update_fn(const struct bContext *C,
static void node_find_exec_fn(struct bContext *C, void *UNUSED(arg1), void *arg2)
{
SpaceNode *snode = CTX_wm_space_node(C);
bNode *active = (bNode *)arg2;
bNode *active = arg2;
if (active) {
ARegion *region = CTX_wm_region(C);
@@ -1263,7 +1264,7 @@ static uiBlock *node_find_menu(bContext *C, ARegion *region, void *arg_op)
0,
"");
UI_but_func_search_set(
but, nullptr, node_find_update_fn, op->type, false, nullptr, node_find_exec_fn, nullptr);
but, NULL, node_find_update_fn, op->type, false, NULL, node_find_exec_fn, NULL);
UI_but_flag_enable(but, UI_BUT_ACTIVATE_ON_INIT);
/* fake button, it holds space for search items */
@@ -1275,23 +1276,22 @@ static uiBlock *node_find_menu(bContext *C, ARegion *region, void *arg_op)
10 - UI_searchbox_size_y(),
UI_searchbox_size_x(),
UI_searchbox_size_y(),
nullptr,
NULL,
0,
0,
0,
0,
nullptr);
NULL);
/* Move it downwards, mouse over button. */
std::array<int, 2> bounds_offset = {0, -UI_UNIT_Y};
UI_block_bounds_set_popup(block, 0.3f * U.widget_unit, bounds_offset.data());
UI_block_bounds_set_popup(block, 0.3f * U.widget_unit, (const int[2]){0, -UI_UNIT_Y});
return block;
}
static int node_find_node_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
UI_popup_block_invoke(C, node_find_menu, op, nullptr);
UI_popup_block_invoke(C, node_find_menu, op, NULL);
return OPERATOR_CANCELLED;
}
@@ -1309,7 +1309,7 @@ void NODE_OT_find_node(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "prev", false, "Previous", "");
RNA_def_boolean(ot->srna, "prev", 0, "Previous", "");
}
/** \} */

View File

@@ -18,8 +18,8 @@
* \ingroup edinterface
*/
#include <cstdlib>
#include <cstring>
#include <stdlib.h>
#include <string.h>
#include "MEM_guardedalloc.h"
@@ -29,7 +29,6 @@
#include "BLI_array.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_vector.hh"
#include "BLT_translation.h"
@@ -52,7 +51,7 @@
/************************* Node Socket Manipulation **************************/
/* describes an instance of a node type and a specific socket to link */
struct NodeLinkItem {
typedef struct NodeLinkItem {
int socket_index; /* index for linking */
int socket_type; /* socket type for compatibility check */
const char *socket_name; /* ui label of the socket */
@@ -60,7 +59,7 @@ struct NodeLinkItem {
/* extra settings */
bNodeTree *ngroup; /* group node tree */
};
} NodeLinkItem;
/* Compare an existing node to a link item to see if it can be reused.
* item must be for the same node type!
@@ -99,7 +98,7 @@ static void node_tag_recursive(bNode *node)
node->flag |= NODE_TEST;
for (input = (bNodeSocket *)node->inputs.first; input; input = input->next) {
for (input = node->inputs.first; input; input = input->next) {
if (input->link) {
node_tag_recursive(input->link->fromnode);
}
@@ -116,7 +115,7 @@ static void node_clear_recursive(bNode *node)
node->flag &= ~NODE_TEST;
for (input = (bNodeSocket *)node->inputs.first; input; input = input->next) {
for (input = node->inputs.first; input; input = input->next) {
if (input->link) {
node_clear_recursive(input->link->fromnode);
}
@@ -133,16 +132,16 @@ static void node_remove_linked(Main *bmain, bNodeTree *ntree, bNode *rem_node)
}
/* tag linked nodes to be removed */
for (node = (bNode *)ntree->nodes.first; node; node = node->next) {
for (node = ntree->nodes.first; node; node = node->next) {
node->flag &= ~NODE_TEST;
}
node_tag_recursive(rem_node);
/* clear tags on nodes that are still used by other nodes */
for (node = (bNode *)ntree->nodes.first; node; node = node->next) {
for (node = ntree->nodes.first; node; node = node->next) {
if (!(node->flag & NODE_TEST)) {
for (sock = (bNodeSocket *)node->inputs.first; sock; sock = sock->next) {
for (sock = node->inputs.first; sock; sock = sock->next) {
if (sock->link && sock->link->fromnode != rem_node) {
node_clear_recursive(sock->link->fromnode);
}
@@ -151,7 +150,7 @@ static void node_remove_linked(Main *bmain, bNodeTree *ntree, bNode *rem_node)
}
/* remove nodes */
for (node = (bNode *)ntree->nodes.first; node; node = next) {
for (node = ntree->nodes.first; node; node = next) {
next = node->next;
if (node->flag & NODE_TEST) {
@@ -206,7 +205,7 @@ static void node_socket_add_replace(const bContext *C,
Main *bmain = CTX_data_main(C);
bNode *node_from;
bNodeSocket *sock_from_tmp;
bNode *node_prev = nullptr;
bNode *node_prev = NULL;
/* unlink existing node */
if (sock_to->link) {
@@ -215,7 +214,7 @@ static void node_socket_add_replace(const bContext *C,
}
/* find existing node that we can use */
for (node_from = (bNode *)ntree->nodes.first; node_from; node_from = node_from->next) {
for (node_from = ntree->nodes.first; node_from; node_from = node_from->next) {
if (node_from->type == type) {
break;
}
@@ -224,7 +223,7 @@ static void node_socket_add_replace(const bContext *C,
if (node_from) {
if (node_from->inputs.first || node_from->typeinfo->draw_buttons ||
node_from->typeinfo->draw_buttons_ex) {
node_from = nullptr;
node_from = NULL;
}
}
@@ -234,7 +233,7 @@ static void node_socket_add_replace(const bContext *C,
}
else if (!node_from) {
node_from = nodeAddStaticNode(C, ntree, type);
if (node_prev != nullptr) {
if (node_prev != NULL) {
/* If we're replacing existing node, use its location. */
node_from->locx = node_prev->locx;
node_from->locy = node_prev->locy;
@@ -242,7 +241,7 @@ static void node_socket_add_replace(const bContext *C,
node_from->offsety = node_prev->offsety;
}
else {
sock_from_tmp = (bNodeSocket *)BLI_findlink(&node_from->outputs, item->socket_index);
sock_from_tmp = BLI_findlink(&node_from->outputs, item->socket_index);
nodePositionRelative(node_from, node_to, sock_from_tmp, sock_to);
}
@@ -252,7 +251,7 @@ static void node_socket_add_replace(const bContext *C,
nodeSetActive(ntree, node_from);
/* add link */
sock_from_tmp = (bNodeSocket *)BLI_findlink(&node_from->outputs, item->socket_index);
sock_from_tmp = BLI_findlink(&node_from->outputs, item->socket_index);
nodeAddLink(ntree, node_from, sock_from_tmp, node_to, sock_to);
sock_to->flag &= ~SOCK_COLLAPSED;
@@ -260,10 +259,8 @@ static void node_socket_add_replace(const bContext *C,
if (node_prev && node_from != node_prev) {
bNodeSocket *sock_prev, *sock_from;
for (sock_prev = (bNodeSocket *)node_prev->inputs.first; sock_prev;
sock_prev = sock_prev->next) {
for (sock_from = (bNodeSocket *)node_from->inputs.first; sock_from;
sock_from = sock_from->next) {
for (sock_prev = node_prev->inputs.first; sock_prev; sock_prev = sock_prev->next) {
for (sock_from = node_from->inputs.first; sock_from; sock_from = sock_from->next) {
if (nodeCountSocketLinks(ntree, sock_from) >= nodeSocketLinkLimit(sock_from)) {
continue;
}
@@ -285,7 +282,7 @@ static void node_socket_add_replace(const bContext *C,
if (node_from->typeinfo->nclass == NODE_CLASS_TEXTURE &&
node_prev->typeinfo->nclass == NODE_CLASS_TEXTURE &&
/* White noise texture node does not have NodeTexBase. */
node_from->storage != nullptr && node_prev->storage != nullptr) {
node_from->storage != NULL && node_prev->storage != NULL) {
memcpy(node_from->storage, node_prev->storage, sizeof(NodeTexBase));
}
@@ -306,7 +303,7 @@ static void node_socket_add_replace(const bContext *C,
#define UI_NODE_LINK_DISCONNECT -1
#define UI_NODE_LINK_REMOVE -2
struct NodeLinkArg {
typedef struct NodeLinkArg {
Main *bmain;
Scene *scene;
bNodeTree *ntree;
@@ -317,7 +314,7 @@ struct NodeLinkArg {
NodeLinkItem item;
uiLayout *layout;
};
} NodeLinkArg;
static void ui_node_link_items(NodeLinkArg *arg,
int in_out,
@@ -325,15 +322,14 @@ static void ui_node_link_items(NodeLinkArg *arg,
int *r_totitems)
{
/* XXX this should become a callback for node types! */
NodeLinkItem *items = nullptr;
NodeLinkItem *items = NULL;
int totitems = 0;
if (arg->node_type->type == NODE_GROUP) {
bNodeTree *ngroup;
int i;
for (ngroup = (bNodeTree *)arg->bmain->nodetrees.first; ngroup;
ngroup = (bNodeTree *)ngroup->id.next) {
for (ngroup = arg->bmain->nodetrees.first; ngroup; ngroup = ngroup->id.next) {
const char *disabled_hint;
if ((ngroup->type != arg->ntree->type) ||
!nodeGroupPoll(arg->ntree, ngroup, &disabled_hint)) {
@@ -345,11 +341,10 @@ static void ui_node_link_items(NodeLinkArg *arg,
}
if (totitems > 0) {
items = (NodeLinkItem *)MEM_callocN(sizeof(NodeLinkItem) * totitems, "ui node link items");
items = MEM_callocN(sizeof(NodeLinkItem) * totitems, "ui node link items");
i = 0;
for (ngroup = (bNodeTree *)arg->bmain->nodetrees.first; ngroup;
ngroup = (bNodeTree *)ngroup->id.next) {
for (ngroup = arg->bmain->nodetrees.first; ngroup; ngroup = ngroup->id.next) {
const char *disabled_hint;
if ((ngroup->type != arg->ntree->type) ||
!nodeGroupPoll(arg->ntree, ngroup, &disabled_hint)) {
@@ -359,8 +354,7 @@ static void ui_node_link_items(NodeLinkArg *arg,
ListBase *lb = (in_out == SOCK_IN ? &ngroup->inputs : &ngroup->outputs);
bNodeSocket *stemp;
int index;
for (stemp = (bNodeSocket *)lb->first, index = 0; stemp;
stemp = stemp->next, index++, i++) {
for (stemp = lb->first, index = 0; stemp; stemp = stemp->next, index++, i++) {
NodeLinkItem *item = &items[i];
item->socket_index = index;
@@ -386,7 +380,7 @@ static void ui_node_link_items(NodeLinkArg *arg,
}
if (totitems > 0) {
items = (NodeLinkItem *)MEM_callocN(sizeof(NodeLinkItem) * totitems, "ui node link items");
items = MEM_callocN(sizeof(NodeLinkItem) * totitems, "ui node link items");
i = 0;
for (stemp = socket_templates; stemp && stemp->type != -1; stemp++, i++) {
@@ -480,14 +474,15 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
bNodeTree *ntree = arg->ntree;
bNodeSocket *sock = arg->sock;
uiLayout *layout = arg->layout;
uiLayout *column = nullptr;
uiLayout *column = NULL;
uiBlock *block = uiLayoutGetBlock(layout);
uiBut *but;
NodeLinkArg *argN;
int first = 1;
/* generate array of node types sorted by UI name */
blender::Vector<bNodeType *> sorted_ntypes;
bNodeType **sorted_ntypes = NULL;
BLI_array_declare(sorted_ntypes);
NODE_TYPES_BEGIN (ntype) {
const char *disabled_hint;
@@ -503,20 +498,20 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
continue;
}
sorted_ntypes.append(ntype);
BLI_array_append(sorted_ntypes, ntype);
}
NODE_TYPES_END;
qsort(
sorted_ntypes.data(), sorted_ntypes.size(), sizeof(bNodeType *), ui_node_item_name_compare);
sorted_ntypes, BLI_array_len(sorted_ntypes), sizeof(bNodeType *), ui_node_item_name_compare);
/* generate UI */
for (int j = 0; j < sorted_ntypes.size(); j++) {
for (int j = 0; j < BLI_array_len(sorted_ntypes); j++) {
bNodeType *ntype = sorted_ntypes[j];
NodeLinkItem *items;
int totitems;
char name[UI_MAX_NAME_STR];
const char *cur_node_name = nullptr;
const char *cur_node_name = NULL;
int num = 0;
int icon = ICON_NONE;
@@ -536,11 +531,11 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
}
if (first) {
column = uiLayoutColumn(layout, false);
column = uiLayoutColumn(layout, 0);
UI_block_layout_set_current(block, column);
uiItemL(column, IFACE_(cname), ICON_NODE);
but = (uiBut *)block->buttons.last;
but = block->buttons.last;
first = 0;
}
@@ -558,7 +553,7 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
0,
UI_UNIT_X * 4,
UI_UNIT_Y,
nullptr,
NULL,
0.0,
0.0,
0.0,
@@ -583,22 +578,24 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
0,
UI_UNIT_X * 4,
UI_UNIT_Y,
nullptr,
NULL,
0.0,
0.0,
0.0,
0.0,
TIP_("Add node to input"));
argN = (NodeLinkArg *)MEM_dupallocN(arg);
argN = MEM_dupallocN(arg);
argN->item = items[i];
UI_but_funcN_set(but, ui_node_link, argN, nullptr);
UI_but_funcN_set(but, ui_node_link, argN, NULL);
}
if (items) {
MEM_freeN(items);
}
}
BLI_array_free(sorted_ntypes);
}
static void node_menu_column_foreach_cb(void *calldata, int nclass, const char *name)
@@ -638,7 +635,7 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_
if (sock->link) {
uiItemL(column, IFACE_("Link"), ICON_NONE);
but = (uiBut *)block->buttons.last;
but = block->buttons.last;
but->drawflag = UI_BUT_TEXT_LEFT;
but = uiDefBut(block,
@@ -649,7 +646,7 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_
0,
UI_UNIT_X * 4,
UI_UNIT_Y,
nullptr,
NULL,
0.0,
0.0,
0.0,
@@ -665,7 +662,7 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_
0,
UI_UNIT_X * 4,
UI_UNIT_Y,
nullptr,
NULL,
0.0,
0.0,
0.0,
@@ -686,7 +683,7 @@ void uiTemplateNodeLink(
uiBut *but;
float socket_col[4];
arg = (NodeLinkArg *)MEM_callocN(sizeof(NodeLinkArg), "NodeLinkArg");
arg = MEM_callocN(sizeof(NodeLinkArg), "NodeLinkArg");
arg->ntree = ntree;
arg->node = node;
arg->sock = input;
@@ -701,11 +698,11 @@ void uiTemplateNodeLink(
char name[UI_MAX_NAME_STR];
ui_node_sock_name(ntree, input, name);
but = uiDefMenuBut(
block, ui_template_node_link_menu, nullptr, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, "");
block, ui_template_node_link_menu, NULL, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, "");
}
else {
but = uiDefIconMenuBut(
block, ui_template_node_link_menu, nullptr, ICON_NONE, 0, 0, UI_UNIT_X, UI_UNIT_Y, "");
block, ui_template_node_link_menu, NULL, ICON_NONE, 0, 0, UI_UNIT_X, UI_UNIT_Y, "");
}
UI_but_type_set_menu_from_pulldown(but);
@@ -742,7 +739,7 @@ static void ui_node_draw_node(
}
}
for (input = (bNodeSocket *)node->inputs.first; input; input = input->next) {
for (input = node->inputs.first; input; input = input->next) {
ui_node_draw_input(layout, C, ntree, node, input, depth + 1);
}
}
@@ -752,7 +749,7 @@ static void ui_node_draw_input(
{
PointerRNA inputptr, nodeptr;
uiBlock *block = uiLayoutGetBlock(layout);
uiLayout *row = nullptr;
uiLayout *row = NULL;
bNode *lnode;
bool dependency_loop;
@@ -762,11 +759,11 @@ static void ui_node_draw_input(
/* to avoid eternal loops on cyclic dependencies */
node->flag |= NODE_TEST;
lnode = (input->link) ? input->link->fromnode : nullptr;
lnode = (input->link) ? input->link->fromnode : NULL;
dependency_loop = (lnode && (lnode->flag & NODE_TEST));
if (dependency_loop) {
lnode = nullptr;
lnode = NULL;
}
/* socket RNA pointer */
@@ -865,7 +862,7 @@ static void ui_node_draw_input(
}
if (add_dummy_decorator) {
uiItemDecoratorR(split_wrapper.decorate_column, nullptr, nullptr, 0);
uiItemDecoratorR(split_wrapper.decorate_column, NULL, NULL, 0);
}
/* clear */
@@ -882,7 +879,7 @@ void uiTemplateNodeView(
}
/* clear for cycle check */
for (tnode = (bNode *)ntree->nodes.first; tnode; tnode = tnode->next) {
for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
tnode->flag &= ~NODE_TEST;
}

View File

@@ -76,7 +76,7 @@ int space_node_view_flag(
BLI_rctf_init_minmax(&cur_new);
if (snode->edittree) {
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
for (node = snode->edittree->nodes.first; node; node = node->next) {
if ((node->flag & node_flag) == node_flag) {
BLI_rctf_union(&cur_new, &node->totr);
tot++;
@@ -191,16 +191,16 @@ void NODE_OT_view_selected(wmOperatorType *ot)
/** \name Background Image Operators
* \{ */
struct NodeViewMove {
typedef struct NodeViewMove {
int mvalo[2];
int xmin, ymin, xmax, ymax;
};
} NodeViewMove;
static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
SpaceNode *snode = CTX_wm_space_node(C);
ARegion *region = CTX_wm_region(C);
NodeViewMove *nvm = (NodeViewMove *)op->customdata;
NodeViewMove *nvm = op->customdata;
switch (event->type) {
case MOUSEMOVE:
@@ -215,8 +215,8 @@ static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, const wmEvent *e
CLAMP(snode->yof, nvm->ymin, nvm->ymax);
ED_region_tag_redraw(region);
WM_main_add_notifier(NC_NODE | ND_DISPLAY, nullptr);
WM_main_add_notifier(NC_SPACE | ND_SPACE_NODE_VIEW, nullptr);
WM_main_add_notifier(NC_NODE | ND_DISPLAY, NULL);
WM_main_add_notifier(NC_SPACE | ND_SPACE_NODE_VIEW, NULL);
break;
@@ -225,7 +225,7 @@ static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, const wmEvent *e
case RIGHTMOUSE:
if (event->val == KM_RELEASE) {
MEM_freeN(nvm);
op->customdata = nullptr;
op->customdata = NULL;
return OPERATOR_FINISHED;
}
break;
@@ -247,14 +247,14 @@ static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *
void *lock;
ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ibuf = BKE_image_acquire_ibuf(ima, nullptr, &lock);
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (ibuf == nullptr) {
if (ibuf == NULL) {
BKE_image_release_ibuf(ima, ibuf, lock);
return OPERATOR_CANCELLED;
}
nvm = (NodeViewMove *)MEM_callocN(sizeof(NodeViewMove), "NodeViewMove struct");
nvm = MEM_callocN(sizeof(NodeViewMove), "NodeViewMove struct");
op->customdata = nvm;
nvm->mvalo[0] = event->mval[0];
nvm->mvalo[1] = event->mval[1];
@@ -275,7 +275,7 @@ static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *
static void snode_bg_viewmove_cancel(bContext *UNUSED(C), wmOperator *op)
{
MEM_freeN(op->customdata);
op->customdata = nullptr;
op->customdata = NULL;
}
void NODE_OT_backimage_move(wmOperatorType *ot)
@@ -309,8 +309,8 @@ static int backimage_zoom_exec(bContext *C, wmOperator *op)
snode->zoom *= fac;
ED_region_tag_redraw(region);
WM_main_add_notifier(NC_NODE | ND_DISPLAY, nullptr);
WM_main_add_notifier(NC_SPACE | ND_SPACE_NODE_VIEW, nullptr);
WM_main_add_notifier(NC_NODE | ND_DISPLAY, NULL);
WM_main_add_notifier(NC_SPACE | ND_SPACE_NODE_VIEW, NULL);
return OPERATOR_FINISHED;
}
@@ -356,9 +356,9 @@ static int backimage_fit_exec(bContext *C, wmOperator *UNUSED(op))
float facx, facy;
ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ibuf = BKE_image_acquire_ibuf(ima, nullptr, &lock);
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if ((ibuf == nullptr) || (ibuf->x == 0) || (ibuf->y == 0)) {
if ((ibuf == NULL) || (ibuf->x == 0) || (ibuf->y == 0)) {
BKE_image_release_ibuf(ima, ibuf, lock);
return OPERATOR_CANCELLED;
}
@@ -374,8 +374,8 @@ static int backimage_fit_exec(bContext *C, wmOperator *UNUSED(op))
snode->yof = 0;
ED_region_tag_redraw(region);
WM_main_add_notifier(NC_NODE | ND_DISPLAY, nullptr);
WM_main_add_notifier(NC_SPACE | ND_SPACE_NODE_VIEW, nullptr);
WM_main_add_notifier(NC_NODE | ND_DISPLAY, NULL);
WM_main_add_notifier(NC_SPACE | ND_SPACE_NODE_VIEW, NULL);
return OPERATOR_FINISHED;
}
@@ -402,7 +402,7 @@ void NODE_OT_backimage_fit(wmOperatorType *ot)
/** \name Sample Backdrop Operator
* \{ */
struct ImageSampleInfo {
typedef struct ImageSampleInfo {
ARegionType *art;
void *draw_handle;
int x, y;
@@ -420,12 +420,12 @@ struct ImageSampleInfo {
int draw;
int color_manage;
};
} ImageSampleInfo;
static void sample_draw(const bContext *C, ARegion *region, void *arg_info)
{
Scene *scene = CTX_data_scene(C);
ImageSampleInfo *info = (ImageSampleInfo *)arg_info;
ImageSampleInfo *info = arg_info;
if (info->draw) {
ED_image_draw_info(scene,
@@ -445,7 +445,7 @@ static void sample_draw(const bContext *C, ARegion *region, void *arg_info)
/* Returns mouse position in image space. */
bool ED_space_node_get_position(
Main *bmain, SpaceNode *snode, struct ARegion *region, const int mval[2], float fpos[2])
Main *bmain, SpaceNode *snode, struct ARegion *ar, const int mval[2], float fpos[2])
{
if (!ED_node_is_compositor(snode) || (snode->flag & SNODE_BACKDRAW) == 0) {
return false;
@@ -453,7 +453,7 @@ bool ED_space_node_get_position(
void *lock;
Image *ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, nullptr, &lock);
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (!ibuf) {
BKE_image_release_ibuf(ima, ibuf, lock);
return false;
@@ -462,10 +462,8 @@ bool ED_space_node_get_position(
/* map the mouse coords to the backdrop image space */
float bufx = ibuf->x * snode->zoom;
float bufy = ibuf->y * snode->zoom;
fpos[0] = (bufx > 0.0f ? ((float)mval[0] - 0.5f * region->winx - snode->xof) / bufx + 0.5f :
0.0f);
fpos[1] = (bufy > 0.0f ? ((float)mval[1] - 0.5f * region->winy - snode->yof) / bufy + 0.5f :
0.0f);
fpos[0] = (bufx > 0.0f ? ((float)mval[0] - 0.5f * ar->winx - snode->xof) / bufx + 0.5f : 0.0f);
fpos[1] = (bufy > 0.0f ? ((float)mval[1] - 0.5f * ar->winy - snode->yof) / bufy + 0.5f : 0.0f);
BKE_image_release_ibuf(ima, ibuf, lock);
return true;
@@ -491,7 +489,7 @@ bool ED_space_node_color_sample(
}
ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ibuf = BKE_image_acquire_ibuf(ima, nullptr, &lock);
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (!ibuf) {
return false;
}
@@ -534,14 +532,14 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
ARegion *region = CTX_wm_region(C);
ImageSampleInfo *info = (ImageSampleInfo *)op->customdata;
ImageSampleInfo *info = op->customdata;
void *lock;
Image *ima;
ImBuf *ibuf;
float fx, fy, bufx, bufy;
ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ibuf = BKE_image_acquire_ibuf(ima, nullptr, &lock);
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (!ibuf) {
info->draw = 0;
return;
@@ -572,8 +570,8 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
info->draw = 1;
info->channels = ibuf->channels;
info->zp = nullptr;
info->zfp = nullptr;
info->zp = NULL;
info->zfp = NULL;
if (ibuf->rect) {
cp = (uchar *)(ibuf->rect + y * ibuf->x + x);
@@ -618,7 +616,7 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
}
else {
info->draw = 0;
ED_node_sample_set(nullptr);
ED_node_sample_set(NULL);
}
BKE_image_release_ibuf(ima, ibuf, lock);
@@ -628,9 +626,9 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
static void sample_exit(bContext *C, wmOperator *op)
{
ImageSampleInfo *info = (ImageSampleInfo *)op->customdata;
ImageSampleInfo *info = op->customdata;
ED_node_sample_set(nullptr);
ED_node_sample_set(NULL);
ED_region_draw_cb_exit(info->art, info->draw_handle);
ED_area_tag_redraw(CTX_wm_area(C));
MEM_freeN(info);
@@ -646,7 +644,7 @@ static int sample_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_CANCELLED;
}
info = (ImageSampleInfo *)MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo");
info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo");
info->art = region->type;
info->draw_handle = ED_region_draw_cb_activate(
region->type, sample_draw, info, REGION_DRAW_POST_PIXEL);

View File

@@ -1582,29 +1582,21 @@ static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
Editing *ed = SEQ_editing_get(scene, false);
ListBase nseqbase = {NULL, NULL};
if (ed == NULL) {
return OPERATOR_CANCELLED;
}
Sequence *active_seq = SEQ_select_active_get(scene);
ListBase duplicated = {NULL, NULL};
SEQ_sequence_base_dupli_recursive(scene, scene, &nseqbase, ed->seqbasep, SEQ_DUPE_CONTEXT, 0);
SEQ_sequence_base_dupli_recursive(scene, scene, &duplicated, ed->seqbasep, 0, 0);
ED_sequencer_deselect_all(scene);
if (duplicated.first) {
Sequence *seq = duplicated.first;
if (nseqbase.first) {
Sequence *seq = nseqbase.first;
/* Rely on the nseqbase list being added at the end.
* Their UUIDs has been re-generated by the SEQ_sequence_base_dupli_recursive(), */
BLI_movelisttolist(ed->seqbasep, &duplicated);
BLI_movelisttolist(ed->seqbasep, &nseqbase);
/* Handle duplicated strips: set active, select, ensure unique name and duplicate animation
* data. */
for (; seq; seq = seq->next) {
if (active_seq != NULL && STREQ(seq->name, active_seq->name)) {
SEQ_select_active_set(scene, seq);
}
seq->flag &= ~(SEQ_LEFTSEL + SEQ_RIGHTSEL + SEQ_LOCK);
SEQ_ensure_unique_name(seq, scene);
}

View File

@@ -42,7 +42,6 @@
#include "SEQ_iterator.h"
#include "SEQ_select.h"
#include "SEQ_sequencer.h"
#include "SEQ_time.h"
#include "SEQ_transform.h"
/* For menu, popup, icons, etc. */
@@ -1188,7 +1187,7 @@ static int sequencer_select_side_of_frame_exec(bContext *C, wmOperator *op)
test = (timeline_frame <= seq->startdisp);
break;
case 2:
test = SEQ_time_strip_intersects_frame(seq, timeline_frame);
test = (timeline_frame <= seq->enddisp) && (timeline_frame >= seq->startdisp);
break;
}

View File

@@ -24,6 +24,7 @@
#include "BLI_utildefines.h"
#include "BLI_vector.hh"
#include "ED_screen.h"
#include "ED_spreadsheet.h"
#include "DEG_depsgraph.h"

View File

@@ -46,7 +46,6 @@
* \{ */
struct ARegion;
struct BMesh_PartialInfo;
struct Depsgraph;
struct NumInput;
struct Object;

View File

@@ -48,62 +48,6 @@
#include "transform_convert.h"
#include "intern/bmesh_mesh_partial.h"
/* -------------------------------------------------------------------- */
/** \name Container TransCustomData Creation
* \{ */
static void tc_mesh_xxx_free_fn(struct TransInfo *t,
struct TransDataContainer *tc,
struct TransCustomData *custom_data);
struct TransCustomDataLayer;
static void tc_mesh_customdata_free(struct TransCustomDataLayer *tcld);
struct TransCustomDataMesh {
struct TransCustomDataLayer *tcld;
struct BMesh_PartialInfo *editmesh_partial_info;
float editmesh_partial_info_prop_size_stored;
float editmesh_partial_info_prop_size;
};
static struct TransCustomDataMesh *tc_mesh_xxx_ensure(TransDataContainer *tc)
{
struct TransCustomDataMesh *tcmd = tc->custom.type.data;
BLI_assert(tc->custom.type.data == NULL || tc->custom.type.free_cb == tc_mesh_xxx_free_fn);
if (tc->custom.type.data == NULL) {
tc->custom.type.data = MEM_callocN(sizeof(struct TransCustomDataMesh), __func__);
tc->custom.type.free_cb = tc_mesh_xxx_free_fn;
tcmd = tc->custom.type.data;
}
return tcmd;
}
static void tc_mesh_xxx_free(struct TransCustomDataMesh *tcmd)
{
if (tcmd->tcld != NULL) {
tc_mesh_customdata_free(tcmd->tcld);
}
if (tcmd->editmesh_partial_info != NULL) {
BM_mesh_partial_info_destroy(tcmd->editmesh_partial_info);
}
MEM_freeN(tcmd);
}
static void tc_mesh_xxx_free_fn(struct TransInfo *UNUSED(t),
struct TransDataContainer *UNUSED(tc),
struct TransCustomData *custom_data)
{
struct TransCustomDataMesh *tcmd = custom_data->data;
tc_mesh_xxx_free(tcmd);
custom_data->data = NULL;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Container TransCustomData Creation
* \{ */
@@ -139,6 +83,33 @@ struct TransCustomDataLayer {
bool use_merge_group;
};
static void tc_mesh_customdatacorrect_free_fn(struct TransInfo *UNUSED(t),
struct TransDataContainer *UNUSED(tc),
struct TransCustomData *custom_data)
{
struct TransCustomDataLayer *tcld = custom_data->data;
bmesh_edit_end(tcld->bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES);
if (tcld->bm_origfaces) {
BM_mesh_free(tcld->bm_origfaces);
}
if (tcld->origfaces) {
BLI_ghash_free(tcld->origfaces, NULL, NULL);
}
if (tcld->merge_group.origverts) {
BLI_ghash_free(tcld->merge_group.origverts, NULL, NULL);
}
if (tcld->arena) {
BLI_memarena_free(tcld->arena);
}
if (tcld->merge_group.customdatalayer_map) {
MEM_freeN(tcld->merge_group.customdatalayer_map);
}
MEM_freeN(tcld);
custom_data->data = NULL;
}
#define USE_FACE_SUBSTITUTE
#ifdef USE_FACE_SUBSTITUTE
# define FACE_SUBSTITUTE_INDEX INT_MIN
@@ -379,32 +350,9 @@ static void tc_mesh_customdata_create(TransDataContainer *tc, const bool use_mer
return;
}
struct TransCustomDataMesh *tcmd = tc_mesh_xxx_ensure(tc);
BLI_assert(tcmd->tcld == NULL);
tcmd->tcld = customdatacorrect;
}
static void tc_mesh_customdata_free(struct TransCustomDataLayer *tcld)
{
bmesh_edit_end(tcld->bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES);
if (tcld->bm_origfaces) {
BM_mesh_free(tcld->bm_origfaces);
}
if (tcld->origfaces) {
BLI_ghash_free(tcld->origfaces, NULL, NULL);
}
if (tcld->merge_group.origverts) {
BLI_ghash_free(tcld->merge_group.origverts, NULL, NULL);
}
if (tcld->arena) {
BLI_memarena_free(tcld->arena);
}
if (tcld->merge_group.customdatalayer_map) {
MEM_freeN(tcld->merge_group.customdatalayer_map);
}
MEM_freeN(tcld);
BLI_assert(tc->custom.type.data == NULL);
tc->custom.type.data = customdatacorrect;
tc->custom.type.free_cb = tc_mesh_customdatacorrect_free_fn;
}
void transform_convert_mesh_customdatacorrect_init(TransInfo *t)
@@ -442,11 +390,7 @@ void transform_convert_mesh_customdatacorrect_init(TransInfo *t)
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
if (tc->custom.type.data != NULL) {
struct TransCustomDataMesh *tcmd = tc->custom.type.data;
if (tcmd && tcmd->tcld) {
tc_mesh_customdata_free(tcmd->tcld);
tcmd->tcld = NULL;
}
tc_mesh_customdatacorrect_free_fn(t, tc, &tc->custom.type);
}
tc_mesh_customdata_create(tc, use_merge_group);
@@ -611,11 +555,10 @@ static void tc_mesh_customdatacorrect_apply_vert(struct TransCustomDataLayer *tc
static void tc_mesh_customdatacorrect_apply(TransDataContainer *tc, bool is_final)
{
struct TransCustomDataMesh *tcmd = tc->custom.type.data;
struct TransCustomDataLayer *tcld = tcmd ? tcmd->tcld : NULL;
if (tcld == NULL) {
if (!tc->custom.type.data) {
return;
}
struct TransCustomDataLayer *tcld = tc->custom.type.data;
const bool use_merge_group = tcld->use_merge_group;
struct TransCustomDataMergeGroup *merge_data = tcld->merge_group.data;
@@ -647,8 +590,7 @@ static void tc_mesh_customdatacorrect_apply(TransDataContainer *tc, bool is_fina
static void tc_mesh_customdatacorrect_restore(struct TransInfo *t)
{
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
struct TransCustomDataMesh *tcmd = tc->custom.type.data;
struct TransCustomDataLayer *tcld = tcmd ? tcmd->tcld : NULL;
struct TransCustomDataLayer *tcld = tc->custom.type.data;
if (!tcld) {
continue;
}
@@ -1675,91 +1617,6 @@ void createTransEditVerts(TransInfo *t)
/** \name Recalc Mesh Data
* \{ */
static bool bm_vert_tag_filter_fn(BMVert *v, void *UNUSED(user_data))
{
return BM_elem_flag_test(v, BM_ELEM_TAG);
}
static struct BMesh_PartialInfo *tc_mesh_ensure_partial_update(TransInfo *t,
TransDataContainer *tc)
{
struct TransCustomDataMesh *tcmd = tc_mesh_xxx_ensure(tc);
bool recalc;
if (tcmd->editmesh_partial_info) {
if (tcmd->editmesh_partial_info_prop_size < t->prop_size) {
/* Size increase, simply recalculate. */
recalc = true;
}
else if (tcmd->editmesh_partial_info_prop_size > t->prop_size) {
/* Size decreased, first use this partial data since reducing the size will transform
* geometry which needs recalculating. */
tcmd->editmesh_partial_info_prop_size_stored = tcmd->editmesh_partial_info_prop_size;
tcmd->editmesh_partial_info_prop_size = t->prop_size;
recalc = false;
}
else if (tcmd->editmesh_partial_info_prop_size_stored != t->prop_size) {
BLI_assert(tcmd->editmesh_partial_info_prop_size_stored >
tcmd->editmesh_partial_info_prop_size);
recalc = true;
}
else {
recalc = false;
}
if (!recalc) {
printf("Ruse\n");
return tcmd->editmesh_partial_info;
}
printf("REcalc\n");
BM_mesh_partial_info_destroy(tcmd->editmesh_partial_info);
tcmd->editmesh_partial_info = NULL;
}
BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
{
BMIter iter;
BMVert *v;
BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
BM_elem_flag_disable(v, BM_ELEM_TAG);
}
}
int verts_len = 0;
int i;
TransData *td;
for (i = 0, td = tc->data; i < tc->data_len; i++, td++) {
if (td->factor != 0.0f) {
BMVert *v = (BMVert *)td->extra;
BM_elem_flag_enable(v, BM_ELEM_TAG);
verts_len += 1;
}
}
TransDataMirror *td_mirror = tc->data_mirror;
for (i = 0; i < tc->data_mirror_len; i++, td_mirror++) {
BMVert *v_mirr = (BMVert *)POINTER_OFFSET(td_mirror->loc_src, -offsetof(BMVert, co));
if (BM_elem_flag_test(v_mirr, BM_ELEM_TAG)) {
BMVert *v_mirr_other = (BMVert *)td_mirror->extra;
if (!BM_elem_flag_test(v_mirr_other, BM_ELEM_TAG) ||
equals_v3v3(td_mirror->loc, td_mirror->iloc)) {
BM_elem_flag_enable(v_mirr_other, BM_ELEM_TAG);
verts_len += 1;
}
}
}
tcmd->editmesh_partial_info = BM_mesh_partial_info_create_from_verts(
em->bm, verts_len, bm_vert_tag_filter_fn, NULL);
tcmd->editmesh_partial_info_prop_size = t->prop_size;
tcmd->editmesh_partial_info_prop_size_stored = t->prop_size;
return tcmd->editmesh_partial_info;
}
static void tc_mesh_transdata_mirror_apply(TransDataContainer *tc)
{
if (tc->use_mirror_axis_any) {
@@ -1795,10 +1652,6 @@ static void tc_mesh_transdata_mirror_apply(TransDataContainer *tc)
}
}
#include "BKE_global.h"
#include "PIL_time.h"
#include "PIL_time_utildefines.h"
void recalcData_mesh(TransInfo *t)
{
bool is_canceling = t->state == TRANS_CANCEL;
@@ -1825,23 +1678,8 @@ void recalcData_mesh(TransInfo *t)
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
DEG_id_tag_update(tc->obedit->data, ID_RECALC_GEOMETRY);
BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
if (G.debug_value == 666) {
TIMEIT_START(a);
EDBM_mesh_normals_update(em);
BKE_editmesh_looptri_calc(em);
TIMEIT_END(a);
}
else {
struct BMesh_PartialInfo *editmesh_partial_info = tc_mesh_ensure_partial_update(t, tc);
TIMEIT_START(b);
/* This tags affected faces. */
BM_mesh_normals_update_with_partial(em->bm, editmesh_partial_info);
BKE_editmesh_looptri_calc_with_partial(em, editmesh_partial_info);
TIMEIT_END(b);
}
EDBM_mesh_normals_update(em);
BKE_editmesh_looptri_calc(em);
}
}
/** \} */

View File

@@ -64,8 +64,6 @@
#include "transform_orientations.h"
#include "transform_snap.h"
#include "intern/bmesh_mesh_partial.h"
/* ************************** GENERICS **************************** */
void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis, short options)

View File

@@ -2064,11 +2064,7 @@ static bool lineart_triangle_edge_image_space_occlusion(SpinLock *UNUSED(spl),
dot_r = dot_v3v3_db(Rv, tri->gn);
dot_f = dot_v3v3_db(Cv, tri->gn);
/* NOTE(Yiming): When we don't use `dot_f==0` here, it's theoretically possible that _some_
* faces in perspective mode would get erroneously caught in this condition where they really are
* legit faces that would produce occlusion, but haven't encountered those yet in my test files.
*/
if (fabs(dot_f) < FLT_EPSILON) {
if (!dot_f) {
return false;
}

View File

@@ -719,7 +719,7 @@ static int startffmpeg(struct anim *anim)
anim->x,
anim->y,
AV_PIX_FMT_RGBA,
SWS_BILINEAR | SWS_PRINT_INFO | SWS_FULL_CHR_H_INT,
SWS_FAST_BILINEAR | SWS_PRINT_INFO | SWS_FULL_CHR_H_INT,
NULL,
NULL,
NULL);

View File

@@ -526,8 +526,8 @@ static struct proxy_output_ctx *alloc_proxy_output_ffmpeg(
rv->c->time_base.num = 1;
rv->st->time_base = rv->c->time_base;
/* This range matches #eFFMpegCrf. `crf_range_min` corresponds to lowest quality,
* `crf_range_max` to highest quality. */
/* This range matches eFFMpegCrf. Crf_range_min corresponds to lowest quality, crf_range_max to
* highest quality. */
const int crf_range_min = 32;
const int crf_range_max = 17;
int crf = round_fl_to_int((quality / 100.0f) * (crf_range_max - crf_range_min) + crf_range_min);
@@ -535,11 +535,8 @@ static struct proxy_output_ctx *alloc_proxy_output_ffmpeg(
AVDictionary *codec_opts = NULL;
/* High quality preset value. */
av_dict_set_int(&codec_opts, "crf", crf, 0);
/* Prefer smaller file-size. Presets from `veryslow` to `veryfast` produce output with very
* similar file-size, but there is big difference in performance.
* In some cases `veryfast` preset will produce smallest file-size. */
av_dict_set(&codec_opts, "preset", "veryfast", 0);
av_dict_set(&codec_opts, "tune", "fastdecode", 0);
/* Prefer smaller file-size. */
av_dict_set(&codec_opts, "preset", "slow", 0);
if (rv->codec->capabilities & AV_CODEC_CAP_AUTO_THREADS) {
rv->c->thread_count = 0;

View File

@@ -320,6 +320,7 @@ typedef struct bNode {
#define NODE_HIDDEN 8
#define NODE_ACTIVE 16
#define NODE_ACTIVE_ID 32
/* Used to indicate which group output node is used and which viewer node is active. */
#define NODE_DO_OUTPUT 64
#define __NODE_GROUP_EDIT 128 /* DEPRECATED */
/* free test flag, undefined */
@@ -354,7 +355,7 @@ typedef struct bNode {
*/
#define NODE_DO_OUTPUT_RECALC (1 << 17)
/* A preview for the data in this node can be displayed in the spreadsheet editor. */
#define NODE_ACTIVE_PREVIEW (1 << 18)
#define __NODE_ACTIVE_PREVIEW (1 << 18) /* deprecated */
/* node->update */
/* XXX NODE_UPDATE is a generic update flag. More fine-grained updates

View File

@@ -11163,12 +11163,6 @@ static void rna_def_node(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Show Texture", "Display node in viewport textured shading mode");
RNA_def_property_update(prop, 0, "rna_Node_update");
prop = RNA_def_property(srna, "active_preview", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_ACTIVE_PREVIEW);
RNA_def_property_ui_text(prop, "Active Preview", "Node is previewed in other editor");
RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE);
RNA_def_property_update(prop, NC_NODE, NULL);
/* generic property update function */
func = RNA_def_function(srna, "socket_value_update", "rna_Node_socket_value_update");
RNA_def_function_ui_description(func, "Update after property changes");

View File

@@ -599,7 +599,7 @@ static void uilist_filter_items(uiList *ui_list,
items_shown = flt_data->items_shown = shown_idx;
flt_data->items_filter_neworder = MEM_mallocN(sizeof(int) * items_shown, __func__);
/* And now, bring back new indices into the [0, items_shown[ range!
* XXX This is O(N^2). :/
* XXX This is O(N²)... :/
*/
for (shown_idx = 0, prev_ni = -1; shown_idx < items_shown; shown_idx++) {
for (i = 0, t_ni = len, t_idx = -1; i < items_shown; i++) {

View File

@@ -768,22 +768,6 @@ static Vector<SpaceSpreadsheet *> find_spreadsheet_editors(Main *bmain)
using PreviewSocketMap = blender::MultiValueMap<DSocket, uint64_t>;
static DSocket try_find_preview_socket_in_node(const DNode node)
{
for (const SocketRef *socket : node->outputs()) {
if (socket->bsocket()->type == SOCK_GEOMETRY) {
return {node.context(), socket};
}
}
for (const SocketRef *socket : node->inputs()) {
if (socket->bsocket()->type == SOCK_GEOMETRY &&
(socket->bsocket()->flag & SOCK_MULTI_INPUT) == 0) {
return {node.context(), socket};
}
}
return {};
}
static DSocket try_get_socket_to_preview_for_spreadsheet(SpaceSpreadsheet *sspreadsheet,
NodesModifierData *nmd,
const ModifierEvalContext *ctx,
@@ -839,7 +823,17 @@ static DSocket try_get_socket_to_preview_for_spreadsheet(SpaceSpreadsheet *sspre
const NodeTreeRef &tree_ref = context->tree();
for (const NodeRef *node_ref : tree_ref.nodes()) {
if (node_ref->name() == last_context->node_name) {
return try_find_preview_socket_in_node({context, node_ref});
const DNode viewer_node{context, node_ref};
DSocket socket_to_view;
viewer_node.input(0).foreach_origin_socket(
[&](const DSocket socket) { socket_to_view = socket; });
if (!socket_to_view) {
return {};
}
bNodeSocket *bsocket = socket_to_view->bsocket();
if (bsocket->type == SOCK_GEOMETRY && bsocket->flag != SOCK_MULTI_INPUT) {
return socket_to_view;
}
}
}
return {};
@@ -975,6 +969,8 @@ static GeometrySet compute_geometry(const DerivedNodeTree &tree,
blender::modifiers::geometry_nodes::GeometryNodesEvaluationParams eval_params;
eval_params.input_values = group_inputs;
eval_params.output_sockets = group_outputs;
eval_params.force_compute_sockets.extend(preview_sockets.keys().begin(),
preview_sockets.keys().end());
eval_params.mf_by_node = &mf_by_node;
eval_params.modifier_ = nmd;
eval_params.depsgraph = ctx->depsgraph;

View File

@@ -404,6 +404,9 @@ class GeometryNodesEvaluator {
for (const DInputSocket &socket : params_.output_sockets) {
nodes_to_check.push(socket.node());
}
for (const DSocket &socket : params_.force_compute_sockets) {
nodes_to_check.push(socket.node());
}
/* Use the local allocator because the states do not need to outlive the evaluator. */
LinearAllocator<> &allocator = local_allocators_.local();
while (!nodes_to_check.is_empty()) {
@@ -500,7 +503,8 @@ class GeometryNodesEvaluator {
},
{});
if (output_state.potential_users == 0) {
/* If it does not have any potential users, it is unused. */
/* If it does not have any potential users, it is unused. It might become required again if
* the output itself is needed. */
output_state.output_usage = ValueUsage::Unused;
}
}
@@ -573,6 +577,21 @@ class GeometryNodesEvaluator {
/* Setting an input as required will schedule any linked node. */
this->set_input_required(locked_node, socket);
}
for (const DSocket socket : params_.force_compute_sockets) {
const DNode node = socket.node();
NodeState &node_state = this->get_node_state(node);
LockedNode locked_node{*this, node, node_state};
if (socket->is_input()) {
this->set_input_required(locked_node, DInputSocket(socket));
}
else {
OutputState &output_state = node_state.outputs[socket->index()];
output_state.output_usage = ValueUsage::Required;
/* Add a fake user for this output. */
output_state.potential_users += 1;
this->schedule_node(locked_node);
}
}
}
void schedule_node(LockedNode &locked_node)

View File

@@ -38,6 +38,7 @@ struct GeometryNodesEvaluationParams {
Map<DOutputSocket, GMutablePointer> input_values;
Vector<DInputSocket> output_sockets;
Vector<DSocket> force_compute_sockets;
nodes::MultiFunctionByNode *mf_by_node;
const NodesModifierData *modifier_;
Depsgraph *depsgraph;

View File

@@ -193,6 +193,7 @@ set(SRC
geometry/nodes/node_geo_switch.cc
geometry/nodes/node_geo_transform.cc
geometry/nodes/node_geo_triangulate.cc
geometry/nodes/node_geo_viewer.cc
geometry/nodes/node_geo_volume_to_mesh.cc
geometry/node_geometry_exec.cc
geometry/node_geometry_tree.cc

View File

@@ -82,6 +82,7 @@ void register_node_type_geo_subdivision_surface(void);
void register_node_type_geo_switch(void);
void register_node_type_geo_transform(void);
void register_node_type_geo_triangulate(void);
void register_node_type_geo_viewer(void);
void register_node_type_geo_volume_to_mesh(void);
#ifdef __cplusplus

View File

@@ -320,6 +320,7 @@ DefNode(GeometryNode, GEO_NODE_SUBDIVISION_SURFACE, 0, "SUBDIVISION_SURFACE", Su
DefNode(GeometryNode, GEO_NODE_SWITCH, def_geo_switch, "SWITCH", Switch, "Switch", "")
DefNode(GeometryNode, GEO_NODE_TRANSFORM, 0, "TRANSFORM", Transform, "Transform", "")
DefNode(GeometryNode, GEO_NODE_TRIANGULATE, def_geo_triangulate, "TRIANGULATE", Triangulate, "Triangulate", "")
DefNode(GeometryNode, GEO_NODE_VIEWER, 0, "VIEWER", Viewer, "Viewer", "")
DefNode(GeometryNode, GEO_NODE_VOLUME_TO_MESH, def_geo_volume_to_mesh, "VOLUME_TO_MESH", VolumeToMesh, "Volume to Mesh", "")
/* undefine macros */

View File

@@ -237,7 +237,6 @@ static Mesh *curve_to_mesh_calculate(const CurveEval &curve, const CurveEval &pr
}
Mesh *mesh = BKE_mesh_new_nomain(vert_total, edge_total, 0, corner_total, poly_total);
BKE_id_material_eval_ensure_default_slot(&mesh->id);
MutableSpan<MVert> verts{mesh->mvert, mesh->totvert};
MutableSpan<MEdge> edges{mesh->medge, mesh->totedge};
MutableSpan<MLoop> loops{mesh->mloop, mesh->totloop};
@@ -298,6 +297,7 @@ static void geo_node_curve_to_mesh_exec(GeoNodeExecParams params)
Mesh *mesh = curve_to_mesh_calculate(*curve_set.get_curve_for_read(),
(profile_curve == nullptr) ? vert_curve : *profile_curve);
BKE_id_material_eval_ensure_default_slot(&mesh->id);
params.set_output("Mesh", GeometrySet::create_with_mesh(mesh));
}

View File

@@ -291,12 +291,14 @@ static void geo_node_mesh_to_curve_exec(GeoNodeExecParams params)
const MeshComponent &component = *geometry_set.get_component_for_read<MeshComponent>();
const Mesh &mesh = *component.get_for_read();
Span<MVert> verts = Span{mesh.mvert, mesh.totvert};
Vector<std::pair<int, int>> selected_edges = get_selected_edges(params, component);
if (selected_edges.size() == 0) {
Span<MEdge> edges = Span{mesh.medge, mesh.totedge};
if (edges.size() == 0) {
params.set_output("Curve", GeometrySet());
return;
}
Vector<std::pair<int, int>> selected_edges = get_selected_edges(params, component);
CurveFromEdgesOutput output = mesh_to_curve(verts, selected_edges);
copy_attributes_to_points(*output.curve, component, output.point_to_vert_maps);

View File

@@ -14,29 +14,18 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#pragma once
#include "node_geometry_util.hh"
/** \file
* \ingroup bmesh
*/
#include "bmesh.h"
struct BMesh_PartialInfo {
BMVert **verts;
BMEdge **edges;
BMFace **faces;
int verts_len, verts_len_alloc;
int edges_len, edges_len_alloc;
int faces_len, faces_len_alloc;
/* Only for building. */
uint *verts_tag;
uint *edges_tag;
uint *faces_tag;
static bNodeSocketTemplate geo_node_viewer_in[] = {
{SOCK_GEOMETRY, N_("Geometry")},
{-1, ""},
};
struct BMesh_PartialInfo *BM_mesh_partial_info_create_from_verts(
BMesh *bm, const int verts_len, bool (*filter_fn)(BMVert *, void *user_data), void *user_data);
void register_node_type_geo_viewer()
{
static bNodeType ntype;
void BM_mesh_partial_info_destroy(struct BMesh_PartialInfo *bmpinfo);
geo_node_type_base(&ntype, GEO_NODE_VIEWER, "Viewer", NODE_CLASS_OUTPUT, 0);
node_type_socket_templates(&ntype, geo_node_viewer_in, nullptr);
nodeRegisterType(&ntype);
}

View File

@@ -43,9 +43,8 @@ static int node_shader_gpu_output_aov(GPUMaterial *mat,
{
GPUNodeLink *outlink;
NodeShaderOutputAOV *aov = (NodeShaderOutputAOV *)node->storage;
/* Keep in sync with `renderpass_lib.glsl#render_pass_aov_hash` and
* `EEVEE_renderpasses_aov_hash`. */
unsigned int hash = BLI_hash_string(aov->name) << 1;
/* Keep in sync with `renderpass_lib.glsl#render_pass_aov_hash`. */
unsigned int hash = BLI_hash_string(aov->name) & ~1;
GPU_stack_link(mat, node, "node_output_aov", in, out, &outlink);
GPU_material_add_output_link_aov(mat, outlink, hash);

View File

@@ -46,6 +46,8 @@ enum {
/* seq_dupli' flags */
#define SEQ_DUPE_UNIQUE_NAME (1 << 0)
#define SEQ_DUPE_CONTEXT (1 << 1)
#define SEQ_DUPE_ANIM (1 << 2)
#define SEQ_DUPE_ALL (1 << 3) /* otherwise only selected are copied */
#define SEQ_DUPE_IS_RECURSIVE_CALL (1 << 4)

View File

@@ -45,7 +45,6 @@ int SEQ_time_find_next_prev_edit(struct Scene *scene,
void SEQ_time_update_sequence(struct Scene *scene, struct Sequence *seq);
void SEQ_time_update_sequence_bounds(struct Scene *scene, struct Sequence *seq);
int SEQ_time_cmp_time_startdisp(const void *a, const void *b);
bool SEQ_time_strip_intersects_frame(const struct Sequence *seq, const int timeline_frame);
#ifdef __cplusplus
}

View File

@@ -61,7 +61,6 @@ int SEQ_recursive_apply(struct Sequence *seq,
int (*apply_fn)(struct Sequence *, void *),
void *arg);
void SEQ_ensure_unique_name(struct Sequence *seq, struct Scene *scene);
#ifdef __cplusplus
}
#endif

View File

@@ -70,7 +70,6 @@
#include "SEQ_proxy.h"
#include "SEQ_render.h"
#include "SEQ_sequencer.h"
#include "SEQ_time.h"
#include "SEQ_utils.h"
#include "effects.h"
@@ -310,7 +309,7 @@ static SeqCollection *query_strips_at_frame(ListBase *seqbase, const int timelin
SeqCollection *collection = SEQ_collection_create();
LISTBASE_FOREACH (Sequence *, seq, seqbase) {
if (SEQ_time_strip_intersects_frame(seq, timeline_frame)) {
if ((seq->startdisp <= timeline_frame) && (seq->enddisp > timeline_frame)) {
SEQ_collection_append_strip(seq, collection);
}
}

View File

@@ -516,6 +516,10 @@ static Sequence *seq_dupli(const Scene *scene_src,
if (dupe_flag & SEQ_DUPE_UNIQUE_NAME) {
SEQ_sequence_base_unique_name_recursive(&scene_dst->ed->seqbase, seqn);
}
if (dupe_flag & SEQ_DUPE_ANIM) {
SEQ_dupe_animdata(scene_dst, seq->name + 2, seqn->name + 2);
}
}
return seqn;
@@ -561,21 +565,30 @@ void SEQ_sequence_base_dupli_recursive(const Scene *scene_src,
{
Sequence *seq;
Sequence *seqn = NULL;
Sequence *last_seq = SEQ_select_active_get((Scene *)scene_src);
/* always include meta's strips */
int dupe_flag_recursive = dupe_flag | SEQ_DUPE_ALL | SEQ_DUPE_IS_RECURSIVE_CALL;
for (seq = seqbase->first; seq; seq = seq->next) {
seq->tmp = NULL;
if ((seq->flag & SELECT) || (dupe_flag & SEQ_DUPE_ALL)) {
seqn = seq_dupli(scene_src, scene_dst, nseqbase, seq, dupe_flag, flag);
if (seqn) { /*should never fail */
if (dupe_flag & SEQ_DUPE_CONTEXT) {
seq->flag &= ~SEQ_ALLSEL;
seqn->flag &= ~(SEQ_LEFTSEL + SEQ_RIGHTSEL + SEQ_LOCK);
}
if (seqn == NULL) {
continue; /* Should never fail. */
}
if (seq->type == SEQ_TYPE_META) {
SEQ_sequence_base_dupli_recursive(
scene_src, scene_dst, &seqn->seqbase, &seq->seqbase, dupe_flag_recursive, flag);
}
if (seq->type == SEQ_TYPE_META) {
/* Always include meta all strip children. */
int dupe_flag_recursive = dupe_flag | SEQ_DUPE_ALL | SEQ_DUPE_IS_RECURSIVE_CALL;
SEQ_sequence_base_dupli_recursive(
scene_src, scene_dst, &seqn->seqbase, &seq->seqbase, dupe_flag_recursive, flag);
if (dupe_flag & SEQ_DUPE_CONTEXT) {
if (seq == last_seq) {
SEQ_select_active_set(scene_dst, seqn);
}
}
}
}
}

View File

@@ -259,7 +259,7 @@ void SEQ_relations_free_imbuf(Scene *scene, ListBase *seqbase, bool for_render)
SEQ_prefetch_stop(scene);
for (seq = seqbase->first; seq; seq = seq->next) {
if (for_render && SEQ_time_strip_intersects_frame(seq, CFRA)) {
if (for_render && CFRA >= seq->startdisp && CFRA <= seq->enddisp) {
continue;
}
@@ -358,7 +358,7 @@ void SEQ_relations_update_changed_seq_and_deps(Scene *scene,
static void sequencer_all_free_anim_ibufs(ListBase *seqbase, int timeline_frame)
{
for (Sequence *seq = seqbase->first; seq != NULL; seq = seq->next) {
if (!SEQ_time_strip_intersects_frame(seq, timeline_frame)) {
if (seq->enddisp < timeline_frame || seq->startdisp > timeline_frame) {
SEQ_relations_sequence_free_anim(seq);
}
if (seq->type == SEQ_TYPE_META) {

View File

@@ -409,7 +409,7 @@ static bool strip_exists_at_frame(SeqCollection *all_strips, const int timeline_
{
Sequence *seq;
SEQ_ITERATOR_FOREACH (seq, all_strips) {
if (SEQ_time_strip_intersects_frame(seq, timeline_frame)) {
if ((seq->startdisp <= timeline_frame) && (seq->enddisp > timeline_frame)) {
return true;
}
}
@@ -468,17 +468,3 @@ void seq_time_gap_info_get(const Scene *scene,
}
}
}
/**
* Test if strip intersects with timeline frame.
* Note: This checks if strip would be rendered at this frame. For rendering it is assumed, that
* timeline frame has width of 1 frame and therefore ends at timeline_frame + 1
*
* \param seq: Sequence to be checked
* \param timeline_frame: absolute frame position
* \return true if strip intersects with timeline frame.
*/
bool SEQ_time_strip_intersects_frame(const Sequence *seq, const int timeline_frame)
{
return (seq->startdisp <= timeline_frame) && (seq->enddisp > timeline_frame);
}

View File

@@ -43,7 +43,6 @@
#include "SEQ_relations.h"
#include "SEQ_select.h"
#include "SEQ_sequencer.h"
#include "SEQ_time.h"
#include "SEQ_utils.h"
#include "IMB_imbuf.h"
@@ -407,7 +406,7 @@ const Sequence *SEQ_get_topmost_sequence(const Scene *scene, int frame)
}
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if (seq->flag & SEQ_MUTE || !SEQ_time_strip_intersects_frame(seq, frame)) {
if (seq->flag & SEQ_MUTE || seq->startdisp > frame || seq->enddisp <= frame) {
continue;
}
/* Only use strips that generate an image, not ones that combine

View File

@@ -31,7 +31,7 @@ Possible use cases for this script include:
- Creating reproducible user interactions for the purpose of benchmarking and profiling.
Note that cursor-motion actions report the update time between events
Note that curse-motion actions report the update time between events
which can be helpful when measuring optimizations.
- As a convenient way to replay interactive actions that reproduce a bug.
@@ -86,7 +86,7 @@ Sculpt stroke:
'event(type="WHEELDOWNMOUSE", value="TAP", repeat=2)' \
'event(type="LEFTMOUSE", value="PRESS")' \
'cursor_motion(path="CIRCLE", radius=300, steps=100, repeat=5)' \
'event(type="LEFTMOUSE", value="RELEASE")'
'event(type="LEFTMOUSE", value="RELEASE")' \
Implementation
@@ -245,8 +245,8 @@ class action_handlers:
if area is None:
raise ArgumentTypeError("Area with ui_type=%r not found" % ui_type)
x = area.x + (area.width // 2)
y = area.y + (area.height // 2)
x = area.y + (area.width // 2)
y = area.x + (area.height // 2)
yield dict(type='MOUSEMOVE', value='NOTHING', x=x, y=y)
yield dict(type='SPACE', value='TAP', ctrl=True, alt=True)
@@ -549,8 +549,8 @@ def main_event_iter(*, action_list):
"""
area = find_main_area()
x_init = area.x + (area.width // 2)
y_init = area.y + (area.height // 2)
x_init = area.y + (area.width // 2)
y_init = area.x + (area.height // 2)
yield dict(type='MOUSEMOVE', value='NOTHING', x=x_init, y=y_init)