Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2021-02-03 07:16:42 +0300
committerHans Goudey <h.goudey@me.com>2021-02-03 07:16:42 +0300
commit89d5710830d41f8bac9925c2cdc482ec9f8d7c3b (patch)
tree55685441bc2e4bbe8166c8ca66f202f68668f76a
parent7746c562a4543ee34cca7ec78302317231741d82 (diff)
parentb3f9895ab0fd92c4f8b4d37a93822e06b5c8353b (diff)
Merge branch 'master' into temp-geometry-nodes-instances-api
-rw-r--r--GNUmakefile11
-rw-r--r--build_files/build_environment/cmake/sqlite.cmake2
-rw-r--r--build_files/cmake/platform/platform_apple.cmake6
-rwxr-xr-xbuild_files/utils/make_update.py8
-rw-r--r--extern/mantaflow/preprocessed/fileio/iogrids.cpp23
-rw-r--r--extern/mantaflow/preprocessed/fileio/ioparticles.cpp26
-rw-r--r--extern/mantaflow/preprocessed/fileio/ioutil.cpp7
-rw-r--r--extern/mantaflow/preprocessed/fileio/iovdb.cpp153
-rw-r--r--extern/mantaflow/preprocessed/fileio/mantaio.cpp9
-rw-r--r--extern/mantaflow/preprocessed/fileio/mantaio.h3
-rw-r--r--extern/mantaflow/preprocessed/gitinfo.h2
-rw-r--r--extern/mantaflow/preprocessed/grid.cpp6
-rw-r--r--extern/mantaflow/preprocessed/grid.h1
-rw-r--r--extern/mantaflow/preprocessed/grid4d.cpp4
-rw-r--r--intern/cycles/blender/addon/__init__.py1
-rw-r--r--intern/mantaflow/intern/MANTA_main.cpp4
-rw-r--r--intern/mantaflow/intern/strings/fluid_script.h2
-rw-r--r--source/blender/blenkernel/BKE_geometry_set.hh2
-rw-r--r--source/blender/blenkernel/BKE_main.h3
-rw-r--r--source/blender/blenkernel/BKE_node.h7
-rw-r--r--source/blender/blenkernel/BKE_volume.h2
-rw-r--r--source/blender/blenkernel/CMakeLists.txt2
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.cc35
-rw-r--r--source/blender/blenkernel/intern/fluid.c7
-rw-r--r--source/blender/blenkernel/intern/geometry_set.cc17
-rw-r--r--source/blender/blenkernel/intern/lib_override.c80
-rw-r--r--source/blender/blenkernel/intern/main.c21
-rw-r--r--source/blender/blenkernel/intern/node.cc (renamed from source/blender/blenkernel/intern/node.c)667
-rw-r--r--source/blender/blenkernel/intern/scene.c4
-rw-r--r--source/blender/blenkernel/intern/studiolight.c2
-rw-r--r--source/blender/blenkernel/intern/volume.cc28
-rw-r--r--source/blender/blenlib/BLI_args.h2
-rw-r--r--source/blender/blenlib/intern/BLI_args.c10
-rw-r--r--source/blender/compositor/COM_compositor.h2
-rw-r--r--source/blender/draw/engines/overlay/overlay_wireframe.c8
-rw-r--r--source/blender/draw/intern/draw_hair.c8
-rw-r--r--source/blender/editors/interface/interface_region_search.c7
-rw-r--r--source/blender/editors/physics/dynamicpaint_ops.c2
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c3
-rw-r--r--source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp7
-rw-r--r--source/blender/gpu/GPU_platform.h1
-rw-r--r--source/blender/gpu/opengl/gl_backend.cc5
-rw-r--r--source/blender/makesrna/intern/rna_render.c8
-rw-r--r--source/blender/nodes/texture/node_texture_util.c2
-rw-r--r--source/blender/render/RE_engine.h1
-rw-r--r--source/blender/render/intern/pipeline.c25
-rw-r--r--source/creator/creator_args.c23
47 files changed, 815 insertions, 444 deletions
diff --git a/GNUmakefile b/GNUmakefile
index 532f9cb9bde..98463891407 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -183,8 +183,13 @@ endif
ifndef DEPS_INSTALL_DIR
DEPS_INSTALL_DIR:=$(shell dirname "$(BLENDER_DIR)")/lib/$(OS_NCASE)
- ifneq ($(OS_NCASE),darwin)
- # Add processor type to directory name
+ # Add processor type to directory name, except for darwin x86_64
+ # which by convention does not have it.
+ ifeq ($(OS_NCASE),darwin)
+ ifneq ($(CPU),x86_64)
+ DEPS_INSTALL_DIR:=$(DEPS_INSTALL_DIR)_$(CPU)
+ endif
+ else
DEPS_INSTALL_DIR:=$(DEPS_INSTALL_DIR)_$(CPU)
endif
endif
@@ -198,7 +203,7 @@ endif
# in libraries, or python 2 for running make update to get it.
ifeq ($(OS_NCASE),darwin)
ifeq (, $(shell command -v $(PYTHON)))
- PYTHON:=../lib/darwin/python/bin/python3.7m
+ PYTHON:=$(DEPS_INSTALL_DIR)/python/bin/python3.7m
ifeq (, $(shell command -v $(PYTHON)))
PYTHON:=python
endif
diff --git a/build_files/build_environment/cmake/sqlite.cmake b/build_files/build_environment/cmake/sqlite.cmake
index 90330c68811..002be924a50 100644
--- a/build_files/build_environment/cmake/sqlite.cmake
+++ b/build_files/build_environment/cmake/sqlite.cmake
@@ -42,7 +42,7 @@ if(UNIX)
-DSQLITE_MAX_VARIABLE_NUMBER=250000 \
-fPIC")
set(SQLITE_CONFIGURE_ENV ${SQLITE_CONFIGURE_ENV} && export LDFLAGS=${SQLITE_LDFLAGS} && export CFLAGS=${SQLITE_CFLAGS})
- set(SQLITE_CONFIGURATION_ARGS ${SQLITE_CONFIGURATION_ARGS} --enable-threadsafe --enable-load-extension --enable-json1 --enable-fts4 --enable-fts5
+ set(SQLITE_CONFIGURATION_ARGS ${SQLITE_CONFIGURATION_ARGS} --enable-threadsafe --enable-load-extension --enable-json1 --enable-fts4 --enable-fts5 --disable-tcl
--enable-shared=no)
endif()
diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake
index 09a9a6052d2..8a7792bd886 100644
--- a/build_files/cmake/platform/platform_apple.cmake
+++ b/build_files/cmake/platform/platform_apple.cmake
@@ -72,7 +72,11 @@ if(WITH_JACK)
endif()
if(NOT DEFINED LIBDIR)
- set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin)
+ if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "x86_64")
+ set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin)
+ else()
+ set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin_${CMAKE_OSX_ARCHITECTURES})
+ endif()
else()
message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}")
endif()
diff --git a/build_files/utils/make_update.py b/build_files/utils/make_update.py
index 53f6b3d447f..2b8c7af98fb 100755
--- a/build_files/utils/make_update.py
+++ b/build_files/utils/make_update.py
@@ -8,6 +8,7 @@
import argparse
import os
+import platform
import shutil
import sys
@@ -49,7 +50,12 @@ def svn_update(args, release_version):
# Checkout precompiled libraries
if sys.platform == 'darwin':
- lib_platform = "darwin"
+ if platform.machine() == 'x86_64':
+ lib_platform = "darwin"
+ elif platform.machine() == 'arm64':
+ lib_platform = "darwin_arm64"
+ else:
+ lib_platform = None
elif sys.platform == 'win32':
# Windows checkout is usually handled by bat scripts since python3 to run
# this script is bundled as part of the precompiled libraries. However it
diff --git a/extern/mantaflow/preprocessed/fileio/iogrids.cpp b/extern/mantaflow/preprocessed/fileio/iogrids.cpp
index 7cedbb484ba..d138cd2925f 100644
--- a/extern/mantaflow/preprocessed/fileio/iogrids.cpp
+++ b/extern/mantaflow/preprocessed/fileio/iogrids.cpp
@@ -628,13 +628,24 @@ template<class T> int readGridUni(const string &name, Grid<T> *grid)
// current file format
UniHeader head;
assertMsg(gzread(gzf, &head, sizeof(UniHeader)) == sizeof(UniHeader),
- "can't read file, no header present");
- assertMsg(head.dimX == grid->getSizeX() && head.dimY == grid->getSizeY() &&
- head.dimZ == grid->getSizeZ(),
- "grid dim doesn't match, " << Vec3(head.dimX, head.dimY, head.dimZ) << " vs "
- << grid->getSize());
+ "readGridUni: Can't read file, no header present");
assertMsg(unifyGridType(head.gridType) == unifyGridType(grid->getType()),
- "grid type doesn't match " << head.gridType << " vs " << grid->getType());
+ "readGridUni: Grid type doesn't match " << head.gridType << " vs "
+ << grid->getType());
+
+ const Vec3i curGridSize = grid->getParent()->getGridSize();
+ const Vec3i headGridSize(head.dimX, head.dimY, head.dimZ);
+# if BLENDER
+ // Correct grid size is only a soft requirement in Blender
+ if (headGridSize != curGridSize) {
+ debMsg("readGridUni: Grid dim doesn't match, " << headGridSize << " vs " << curGridSize, 1);
+ return 0;
+ }
+# else
+ assertMsg(headGridSize == curGridSize,
+ "readGridUni: Grid dim doesn't match, " << headGridSize << " vs " << curGridSize);
+# endif
+
# if FLOATINGPOINT_PRECISION != 1
// convert float to double
Grid<T> temp(grid->getParent());
diff --git a/extern/mantaflow/preprocessed/fileio/ioparticles.cpp b/extern/mantaflow/preprocessed/fileio/ioparticles.cpp
index 36e10aa1644..538d42f3d87 100644
--- a/extern/mantaflow/preprocessed/fileio/ioparticles.cpp
+++ b/extern/mantaflow/preprocessed/fileio/ioparticles.cpp
@@ -230,6 +230,19 @@ int readParticlesUni(const std::string &name, BasicParticleSystem *parts)
assertMsg(((head.bytesPerElement == PartSysSize) && (head.elementType == 0)),
"particle type doesn't match");
+ const Vec3i curGridSize = parts->getParent()->getGridSize();
+ const Vec3i headGridSize(head.dimX, head.dimY, head.dimZ);
+# if BLENDER
+ // Correct grid size is only a soft requirement in Blender
+ if (headGridSize != curGridSize) {
+ debMsg("readPdataUni: Grid dim doesn't match, " << headGridSize << " vs " << curGridSize, 1);
+ return 0;
+ }
+# else
+ assertMsg(headGridSize == curGridSize,
+ "readPdataUni: Grid dim doesn't match, " << headGridSize << " vs " << curGridSize);
+# endif
+
// re-allocate all data
parts->resizeAll(head.dim);
@@ -325,6 +338,19 @@ template<class T> int readPdataUni(const std::string &name, ParticleDataImpl<T>
pdata->getParticleSys()->resize(head.dim); // ensure that parent particle system has same size
pdata->resize(head.dim);
+ const Vec3i curGridSize = pdata->getParent()->getGridSize();
+ const Vec3i headGridSize(head.dimX, head.dimY, head.dimZ);
+# if BLENDER
+ // Correct grid size is only a soft requirement in Blender
+ if (headGridSize != curGridSize) {
+ debMsg("readPdataUni: Grid dim doesn't match, " << headGridSize << " vs " << curGridSize, 1);
+ return 0;
+ }
+# else
+ assertMsg(headGridSize == curGridSize,
+ "readPdataUni: Grid dim doesn't match, " << headGridSize << " vs " << curGridSize);
+# endif
+
assertMsg(head.dim == pdata->size(), "pdata size doesn't match");
# if FLOATINGPOINT_PRECISION != 1
ParticleDataImpl<T> temp(pdata->getParent());
diff --git a/extern/mantaflow/preprocessed/fileio/ioutil.cpp b/extern/mantaflow/preprocessed/fileio/ioutil.cpp
index 2c7ac7be00e..2bac34c2a65 100644
--- a/extern/mantaflow/preprocessed/fileio/ioutil.cpp
+++ b/extern/mantaflow/preprocessed/fileio/ioutil.cpp
@@ -90,6 +90,13 @@ template<> void convertFrom(openvdb::Vec3s &in, Vec3 *out)
(*out).z = in.z();
}
+template<> void convertFrom(openvdb::Vec3i &in, Vec3i *out)
+{
+ (*out).x = in.x();
+ (*out).y = in.y();
+ (*out).z = in.z();
+}
+
// Convert to OpenVDB value from Manta value.
template<class S, class T> void convertTo(S *out, T &in)
{
diff --git a/extern/mantaflow/preprocessed/fileio/iovdb.cpp b/extern/mantaflow/preprocessed/fileio/iovdb.cpp
index 3641577beca..cc2d0aa508d 100644
--- a/extern/mantaflow/preprocessed/fileio/iovdb.cpp
+++ b/extern/mantaflow/preprocessed/fileio/iovdb.cpp
@@ -38,6 +38,11 @@
#define POSITION_NAME "P"
#define FLAG_NAME "U"
+#define META_BASE_RES "file_base_resolution"
+#define META_VOXEL_SIZE "file_voxel_size"
+#define META_BBOX_MAX "file_bbox_max"
+#define META_BBOX_MIN "file_bbox_min"
+
using namespace std;
namespace Manta {
@@ -388,7 +393,8 @@ int writeObjectsVDB(const string &filename,
int compression,
int precision,
float clip,
- const Grid<Real> *clipGrid)
+ const Grid<Real> *clipGrid,
+ const bool meta)
{
openvdb::initialize();
openvdb::io::File file(filename);
@@ -489,6 +495,16 @@ int writeObjectsVDB(const string &filename,
// Set additional grid attributes, e.g. name, grid class, compression level, etc.
if (vdbGrid) {
setGridOptions<openvdb::GridBase>(vdbGrid, objectName, gClass, voxelSize, precision);
+
+ // Optional metadata: Save additional simulation information per vdb object
+ if (meta) {
+ const Vec3i size = object->getParent()->getGridSize();
+ // The (dense) resolution of this grid
+ vdbGrid->insertMeta(META_BASE_RES,
+ openvdb::Vec3IMetadata(openvdb::Vec3i(size.x, size.y, size.z)));
+ // Length of one voxel side
+ vdbGrid->insertMeta(META_VOXEL_SIZE, openvdb::FloatMetadata(voxelSize));
+ }
}
}
@@ -533,6 +549,44 @@ int writeObjectsVDB(const string &filename,
return 1;
}
+static void clearAll(std::vector<PbClass *> *objects, std::vector<ParticleDataBase *> pdbBuffer)
+{
+ // Clear all data loaded into manta objects (e.g. during IO error)
+ for (std::vector<PbClass *>::iterator iter = objects->begin(); iter != objects->end(); ++iter) {
+ if (GridBase *mantaGrid = dynamic_cast<GridBase *>(*iter)) {
+ if (mantaGrid->getType() & GridBase::TypeInt) {
+ Grid<int> *mantaIntGrid = (Grid<int> *)mantaGrid;
+ mantaIntGrid->clear();
+ }
+ else if (mantaGrid->getType() & GridBase::TypeReal) {
+ Grid<Real> *mantaRealGrid = (Grid<Real> *)mantaGrid;
+ mantaRealGrid->clear();
+ }
+ else if (mantaGrid->getType() & GridBase::TypeVec3) {
+ Grid<Vec3> *mantaVec3Grid = (Grid<Vec3> *)mantaGrid;
+ mantaVec3Grid->clear();
+ }
+ }
+ else if (BasicParticleSystem *mantaPP = dynamic_cast<BasicParticleSystem *>(*iter)) {
+ mantaPP->clear();
+ }
+ }
+ for (ParticleDataBase *pdb : pdbBuffer) {
+ if (pdb->getType() == ParticleDataBase::TypeInt) {
+ ParticleDataImpl<int> *mantaPDataInt = (ParticleDataImpl<int> *)pdb;
+ mantaPDataInt->clear();
+ }
+ else if (pdb->getType() == ParticleDataBase::TypeReal) {
+ ParticleDataImpl<Real> *mantaPDataReal = (ParticleDataImpl<Real> *)pdb;
+ mantaPDataReal->clear();
+ }
+ else if (pdb->getType() == ParticleDataBase::TypeVec3) {
+ ParticleDataImpl<Vec3> *mantaPDataVec3 = (ParticleDataImpl<Vec3> *)pdb;
+ mantaPDataVec3->clear();
+ }
+ }
+}
+
int readObjectsVDB(const string &filename, std::vector<PbClass *> *objects, float worldSize)
{
@@ -561,6 +615,9 @@ int readObjectsVDB(const string &filename, std::vector<PbClass *> *objects, floa
// A buffer to store a handle to pData objects. These will be read alongside a particle system.
std::vector<ParticleDataBase *> pdbBuffer;
+ // Count how many objects could not be read correctly
+ int readFailure = 0;
+
for (std::vector<PbClass *>::iterator iter = objects->begin(); iter != objects->end(); ++iter) {
if (gridsVDB.empty()) {
@@ -568,11 +625,12 @@ int readObjectsVDB(const string &filename, std::vector<PbClass *> *objects, floa
}
// If there is just one grid in this file, load it regardless of name match (to vdb caches per
// grid).
- bool onlyGrid = (gridsVDB.size() == 1);
+ const bool onlyGrid = (gridsVDB.size() == 1);
PbClass *object = dynamic_cast<PbClass *>(*iter);
const Real dx = object->getParent()->getDx();
- const Real voxelSize = worldSize * dx;
+ const Vec3i origRes = object->getParent()->getGridSize();
+ Real voxelSize = worldSize * dx;
// Particle data objects are treated separately - buffered and inserted when reading the
// particle system
@@ -596,6 +654,81 @@ int readObjectsVDB(const string &filename, std::vector<PbClass *> *objects, floa
if (!nameMatch && !onlyGrid) {
continue;
}
+
+ // Metadata: If present in the file, meta data will be parsed into these fields
+ Real metaVoxelSize(0);
+ Vec3i metaRes(0), metaBBoxMax(0), metaBBoxMin(0);
+
+ // Loop to load all meta data that we care about
+ for (openvdb::MetaMap::MetaIterator iter = vdbGrid->beginMeta(); iter != vdbGrid->endMeta();
+ ++iter) {
+ const std::string &name = iter->first;
+ const openvdb::Metadata::Ptr value = iter->second;
+ if (name.compare(META_BASE_RES) == 0) {
+ openvdb::Vec3i tmp = static_cast<openvdb::Vec3IMetadata &>(*value).value();
+ convertFrom(tmp, &metaRes);
+ }
+ else if (name.compare(META_VOXEL_SIZE) == 0) {
+ float tmp = static_cast<openvdb::FloatMetadata &>(*value).value();
+ convertFrom(tmp, &metaVoxelSize);
+
+ voxelSize = metaVoxelSize; // Make sure to update voxel size variable (used in
+ // pointgrid's importVDB())
+ if (worldSize != 1.0)
+ debMsg(
+ "readObjectsVDB: Found voxel size in meta data. worldSize parameter will be "
+ "ignored!",
+ 1);
+ }
+ else if (name.compare(META_BBOX_MAX) == 0) {
+ openvdb::Vec3i tmp = static_cast<openvdb::Vec3IMetadata &>(*value).value();
+ convertFrom(tmp, &metaBBoxMax);
+ }
+ else if (name.compare(META_BBOX_MIN) == 0) {
+ openvdb::Vec3i tmp = static_cast<openvdb::Vec3IMetadata &>(*value).value();
+ convertFrom(tmp, &metaBBoxMin);
+ }
+ else {
+ debMsg("readObjectsVDB: Skipping unknown meta information '" << name << "'", 1);
+ }
+ }
+
+ // Compare metadata with allocated grid setup. This prevents invalid index access.
+ if (notZero(metaRes) && metaRes != origRes) {
+ debMsg("readObjectsVDB Warning: Grid '" << vdbGrid->getName()
+ << "' has not been read. Meta grid res " << metaRes
+ << " vs " << origRes << " current grid size",
+ 1);
+ readFailure++;
+ break;
+ }
+ if (notZero(metaVoxelSize) && metaVoxelSize != voxelSize) {
+ debMsg("readObjectsVDB Warning: Grid '"
+ << vdbGrid->getName() << "' has not been read. Meta voxel size "
+ << metaVoxelSize << " vs " << voxelSize << " current voxel size",
+ 1);
+ readFailure++;
+ break;
+ }
+ if (metaBBoxMax.x > origRes.x || metaBBoxMax.y > origRes.y || metaBBoxMax.z > origRes.z) {
+ debMsg("readObjectsVDB Warning: Grid '"
+ << vdbGrid->getName() << "' has not been read. Vdb bbox max " << metaBBoxMax
+ << " vs " << origRes << " current grid size",
+ 1);
+ readFailure++;
+ break;
+ }
+ const Vec3i origOrigin(0);
+ if (metaBBoxMin.x < origOrigin.x || metaBBoxMin.y < origOrigin.y ||
+ metaBBoxMin.z < origOrigin.z) {
+ debMsg("readObjectsVDB Warning: Grid '"
+ << vdbGrid->getName() << "' has not been read. Vdb bbox min " << metaBBoxMin
+ << " vs " << origOrigin << " current grid origin",
+ 1);
+ readFailure++;
+ break;
+ }
+
if (GridBase *mantaGrid = dynamic_cast<GridBase *>(*iter)) {
if (mantaGrid->getType() & GridBase::TypeInt) {
@@ -655,6 +788,17 @@ int readObjectsVDB(const string &filename, std::vector<PbClass *> *objects, floa
return 0;
}
}
+ // Do not continue loading objects in this loop if there was a read error
+ if (readFailure > 0) {
+ break;
+ }
+ }
+
+ if (readFailure > 0) {
+ // Clear all data that has already been loaded into simulation objects
+ clearAll(objects, pdbBuffer);
+ pdbBuffer.clear();
+ return 0;
}
// Give out a warning if pData items were present but could not be read due to missing particle
@@ -729,7 +873,8 @@ int writeObjectsVDB(const string &filename,
int compression,
int precision,
float clip,
- const Grid<Real> *clipGrid)
+ const Grid<Real> *clipGrid,
+ const bool meta)
{
errMsg("Cannot save to .vdb file. Mantaflow has not been built with OpenVDB support.");
return 0;
diff --git a/extern/mantaflow/preprocessed/fileio/mantaio.cpp b/extern/mantaflow/preprocessed/fileio/mantaio.cpp
index fe29890ec11..ff57ab532e6 100644
--- a/extern/mantaflow/preprocessed/fileio/mantaio.cpp
+++ b/extern/mantaflow/preprocessed/fileio/mantaio.cpp
@@ -85,7 +85,8 @@ int save(const string &name,
bool precisionHalf = true,
int precision = PRECISION_HALF,
float clip = 1e-4,
- const Grid<Real> *clipGrid = nullptr)
+ const Grid<Real> *clipGrid = nullptr,
+ const bool meta = false)
{
if (!precisionHalf) {
@@ -105,7 +106,7 @@ int save(const string &name,
return writeGridsVol(name, &objects);
if (ext == ".vdb")
return writeObjectsVDB(
- name, &objects, worldSize, skipDeletedParts, compression, precision, clip, clipGrid);
+ name, &objects, worldSize, skipDeletedParts, compression, precision, clip, clipGrid, meta);
else if (ext == ".npz")
return writeGridsNumpy(name, &objects);
else if (ext == ".txt")
@@ -134,6 +135,7 @@ static PyObject *_W_1(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
int precision = _args.getOpt<int>("precision", 6, PRECISION_HALF, &_lock);
float clip = _args.getOpt<float>("clip", 7, 1e-4, &_lock);
const Grid<Real> *clipGrid = _args.getPtrOpt<Grid<Real>>("clipGrid", 8, nullptr, &_lock);
+ const bool meta = _args.getOpt<bool>("meta", 9, false, &_lock);
_retval = toPy(save(name,
objects,
worldSize,
@@ -142,7 +144,8 @@ static PyObject *_W_1(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
precisionHalf,
precision,
clip,
- clipGrid));
+ clipGrid,
+ meta));
_args.check();
}
pbFinalizePlugin(parent, "save", !noTiming);
diff --git a/extern/mantaflow/preprocessed/fileio/mantaio.h b/extern/mantaflow/preprocessed/fileio/mantaio.h
index 088d43556e1..26e9319e5e9 100644
--- a/extern/mantaflow/preprocessed/fileio/mantaio.h
+++ b/extern/mantaflow/preprocessed/fileio/mantaio.h
@@ -77,7 +77,8 @@ int writeObjectsVDB(const std::string &filename,
int compression = COMPRESSION_ZIP,
int precision = PRECISION_HALF,
float clip = 1e-4,
- const Grid<Real> *clipGrid = nullptr);
+ const Grid<Real> *clipGrid = nullptr,
+ const bool meta = false);
int readObjectsVDB(const std::string &filename,
std::vector<PbClass *> *objects,
float scale = 1.0);
diff --git a/extern/mantaflow/preprocessed/gitinfo.h b/extern/mantaflow/preprocessed/gitinfo.h
index afc34a00d3d..ddc644db724 100644
--- a/extern/mantaflow/preprocessed/gitinfo.h
+++ b/extern/mantaflow/preprocessed/gitinfo.h
@@ -1,3 +1,3 @@
-#define MANTA_GIT_VERSION "commit e2285cb9bc492987f728123be6cfc1fe11fe73d6"
+#define MANTA_GIT_VERSION "commit 1c86d86496e7f7473c36248d12ef07bf4d9d2840"
diff --git a/extern/mantaflow/preprocessed/grid.cpp b/extern/mantaflow/preprocessed/grid.cpp
index 61672129f37..e0ea3830fae 100644
--- a/extern/mantaflow/preprocessed/grid.cpp
+++ b/extern/mantaflow/preprocessed/grid.cpp
@@ -508,8 +508,7 @@ struct CompMaxVec : public KernelBase {
template<class T> Grid<T> &Grid<T>::copyFrom(const Grid<T> &a, bool copyType)
{
- assertMsg(a.mSize.x == mSize.x && a.mSize.y == mSize.y && a.mSize.z == mSize.z,
- "different grid resolutions " << a.mSize << " vs " << this->mSize);
+ assertMsg(a.mSize == mSize, "different grid resolutions " << a.mSize << " vs " << this->mSize);
memcpy(mData, a.mData, sizeof(T) * mSize.x * mSize.y * mSize.z);
if (copyType)
mType = a.mType; // copy type marker
@@ -3402,8 +3401,7 @@ void PbRegister_markIsolatedFluidCell()
void copyMACData(
const MACGrid &source, MACGrid &target, const FlagGrid &flags, const int flag, const int bnd)
{
- assertMsg(source.getSize().x == target.getSize().x && source.getSize().y == target.getSize().y &&
- source.getSize().z == target.getSize().z,
+ assertMsg(source.getSize() == target.getSize(),
"different grid resolutions " << source.getSize() << " vs " << target.getSize());
// Grid<Real> divGrid(target.getParent());
diff --git a/extern/mantaflow/preprocessed/grid.h b/extern/mantaflow/preprocessed/grid.h
index cf942a19e9a..3d6f8558b8f 100644
--- a/extern/mantaflow/preprocessed/grid.h
+++ b/extern/mantaflow/preprocessed/grid.h
@@ -596,6 +596,7 @@ template<class T> class Grid : public GridBase {
//! set data
inline void set(int i, int j, int k, T &val)
{
+ DEBUG_ONLY(checkIndex(i, j, k));
mData[index(i, j, k)] = val;
}
diff --git a/extern/mantaflow/preprocessed/grid4d.cpp b/extern/mantaflow/preprocessed/grid4d.cpp
index 1a79a835854..72bd3a6fe50 100644
--- a/extern/mantaflow/preprocessed/grid4d.cpp
+++ b/extern/mantaflow/preprocessed/grid4d.cpp
@@ -491,9 +491,7 @@ template<class T> Grid4d<T> &Grid4d<T>::safeDivide(const Grid4d<T> &a)
}
template<class T> Grid4d<T> &Grid4d<T>::copyFrom(const Grid4d<T> &a, bool copyType)
{
- assertMsg(a.mSize.x == mSize.x && a.mSize.y == mSize.y && a.mSize.z == mSize.z &&
- a.mSize.t == mSize.t,
- "different Grid4d resolutions " << a.mSize << " vs " << this->mSize);
+ assertMsg(a.mSize == mSize, "different Grid4d resolutions " << a.mSize << " vs " << this->mSize);
memcpy(mData, a.mData, sizeof(T) * mSize.x * mSize.y * mSize.z * mSize.t);
if (copyType)
mType = a.mType; // copy type marker
diff --git a/intern/cycles/blender/addon/__init__.py b/intern/cycles/blender/addon/__init__.py
index 3ab352e52a2..b1deb5cb64e 100644
--- a/intern/cycles/blender/addon/__init__.py
+++ b/intern/cycles/blender/addon/__init__.py
@@ -59,6 +59,7 @@ class CyclesRender(bpy.types.RenderEngine):
bl_use_exclude_layers = True
bl_use_save_buffers = True
bl_use_spherical_stereo = True
+ bl_use_custom_freestyle = True
def __init__(self):
self.session = None
diff --git a/intern/mantaflow/intern/MANTA_main.cpp b/intern/mantaflow/intern/MANTA_main.cpp
index 1ed2b558938..6c8e45ceeb4 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -1984,7 +1984,9 @@ float MANTA::getTimestep()
bool MANTA::needsRealloc(FluidModifierData *fmd)
{
FluidDomainSettings *fds = fmd->domain;
- return (fds->res[0] != mResX || fds->res[1] != mResY || fds->res[2] != mResZ);
+ return ((fds->res_max[0] - fds->res_min[0]) != mResX ||
+ (fds->res_max[1] - fds->res_min[1]) != mResY ||
+ (fds->res_max[2] - fds->res_min[2]) != mResZ);
}
void MANTA::adaptTimestep()
diff --git a/intern/mantaflow/intern/strings/fluid_script.h b/intern/mantaflow/intern/strings/fluid_script.h
index e65310c4bfd..3bf8e66c110 100644
--- a/intern/mantaflow/intern/strings/fluid_script.h
+++ b/intern/mantaflow/intern/strings/fluid_script.h
@@ -711,7 +711,7 @@ def fluid_file_export_s$ID$(framenr, file_format, path, dict, file_name=None, mo
file = os.path.join(path, file_name + '_' + framenr + file_format)\n\
if not os.path.isfile(file) or mode_override:\n\
if file_format == '.vdb':\n\
- saveCombined = save(name=file, objects=list(dict.values()), worldSize=domainSize_s$ID$, skipDeletedParts=True, compression=vdbCompression_s$ID$, precision=vdbPrecision_s$ID$, clip=vdbClip_s$ID$, clipGrid=clipGrid)\n\
+ saveCombined = save(name=file, objects=list(dict.values()), worldSize=domainSize_s$ID$, skipDeletedParts=True, compression=vdbCompression_s$ID$, precision=vdbPrecision_s$ID$, clip=vdbClip_s$ID$, clipGrid=clipGrid, meta=True)\n\
elif file_format == '.bobj.gz' or file_format == '.obj':\n\
for name, object in dict.items():\n\
if not os.path.isfile(file) or mode_override:\n\
diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh
index 5d21eff43b9..bad38bce89b 100644
--- a/source/blender/blenkernel/BKE_geometry_set.hh
+++ b/source/blender/blenkernel/BKE_geometry_set.hh
@@ -354,6 +354,8 @@ class MeshComponent : public GeometryComponent {
void clear();
bool has_mesh() const;
void replace(Mesh *mesh, GeometryOwnershipType ownership = GeometryOwnershipType::Owned);
+ void replace_mesh_but_keep_vertex_group_names(
+ Mesh *mesh, GeometryOwnershipType ownership = GeometryOwnershipType::Owned);
Mesh *release();
void copy_vertex_group_names_from_object(const struct Object &object);
diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h
index 0768423fc5f..b6116b32ca5 100644
--- a/source/blender/blenkernel/BKE_main.h
+++ b/source/blender/blenkernel/BKE_main.h
@@ -202,6 +202,9 @@ void BKE_main_unlock(struct Main *bmain);
void BKE_main_relations_create(struct Main *bmain, const short flag);
void BKE_main_relations_free(struct Main *bmain);
+void BKE_main_relations_tag_set(struct Main *bmain,
+ const MainIDRelationsEntryTags tag,
+ const bool value);
struct GSet *BKE_main_gset_create(struct Main *bmain, struct GSet *gset);
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 4912d634471..bfcfe84cbe7 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -419,7 +419,7 @@ struct GHashIterator *ntreeTypeGetIterator(void);
GHashIterator *__node_tree_type_iter__ = ntreeTypeGetIterator(); \
for (; !BLI_ghashIterator_done(__node_tree_type_iter__); \
BLI_ghashIterator_step(__node_tree_type_iter__)) { \
- bNodeTreeType *ntype = BLI_ghashIterator_getValue(__node_tree_type_iter__);
+ bNodeTreeType *ntype = (bNodeTreeType *)BLI_ghashIterator_getValue(__node_tree_type_iter__);
#define NODE_TREE_TYPES_END \
} \
@@ -523,7 +523,7 @@ struct GHashIterator *nodeTypeGetIterator(void);
GHashIterator *__node_type_iter__ = nodeTypeGetIterator(); \
for (; !BLI_ghashIterator_done(__node_type_iter__); \
BLI_ghashIterator_step(__node_type_iter__)) { \
- bNodeType *ntype = BLI_ghashIterator_getValue(__node_type_iter__);
+ bNodeType *ntype = (bNodeType *)BLI_ghashIterator_getValue(__node_type_iter__);
#define NODE_TYPES_END \
} \
@@ -545,7 +545,8 @@ const char *nodeStaticSocketInterfaceType(int type, int subtype);
GHashIterator *__node_socket_type_iter__ = nodeSocketTypeGetIterator(); \
for (; !BLI_ghashIterator_done(__node_socket_type_iter__); \
BLI_ghashIterator_step(__node_socket_type_iter__)) { \
- bNodeSocketType *stype = BLI_ghashIterator_getValue(__node_socket_type_iter__);
+ bNodeSocketType *stype = (bNodeSocketType *)BLI_ghashIterator_getValue( \
+ __node_socket_type_iter__);
#define NODE_SOCKET_TYPES_END \
} \
diff --git a/source/blender/blenkernel/BKE_volume.h b/source/blender/blenkernel/BKE_volume.h
index 12c37ec56e0..53626dbeb1b 100644
--- a/source/blender/blenkernel/BKE_volume.h
+++ b/source/blender/blenkernel/BKE_volume.h
@@ -170,7 +170,7 @@ openvdb::GridBase::Ptr BKE_volume_grid_openvdb_for_write(const struct Volume *vo
struct VolumeGrid *grid,
const bool clear);
-VolumeGridType BKE_volume_grid_type_openvdb(const openvdb::GridBase::Ptr &grid);
+VolumeGridType BKE_volume_grid_type_openvdb(const openvdb::GridBase &grid);
template<typename OpType>
auto BKE_volume_grid_type_operation(const VolumeGridType grid_type, OpType &&op)
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 20c57f4e15a..0853ab9d82b 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -197,7 +197,7 @@ set(SRC
intern/multires_unsubdivide.c
intern/multires_versioning.c
intern/nla.c
- intern/node.c
+ intern/node.cc
intern/object.c
intern/object_deform.c
intern/object_dupli.c
diff --git a/source/blender/blenkernel/intern/DerivedMesh.cc b/source/blender/blenkernel/intern/DerivedMesh.cc
index d79413cfaa0..ecc41e3f0df 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.cc
+++ b/source/blender/blenkernel/intern/DerivedMesh.cc
@@ -883,16 +883,15 @@ void BKE_mesh_wrapper_deferred_finalize(Mesh *me_eval,
}
/**
- * Modifies the given mesh and geometry set. The geometry set is expect to have NO mesh component.
- * After this function ends, the geometry set will still have NO mesh component. Instead, an input
- * mesh is passed separately and is returned separately.
+ * Modifies the given mesh and geometry set. The mesh is not passed as part of the mesh component
+ * in the \a geometry_set input, it is only passed in \a input_mesh and returned in the return
+ * value.
*
- * The purpose of the geometry set is to store all non-mesh geometry components that are generated
- * by modifiers.
+ * The purpose of the geometry set is to store all geometry components that are generated
+ * by modifiers to allow outputting non-mesh data from modifiers.
*/
static Mesh *modifier_modify_mesh_and_geometry_set(ModifierData *md,
const ModifierEvalContext &mectx,
- Object *ob,
Mesh *input_mesh,
GeometrySet &geometry_set)
{
@@ -907,10 +906,12 @@ static Mesh *modifier_modify_mesh_and_geometry_set(ModifierData *md,
BKE_mesh_wrapper_ensure_mdata(input_mesh);
/* Adds a new mesh component to the geometry set based on the #input_mesh. */
- BLI_assert(!geometry_set.has<MeshComponent>());
MeshComponent &mesh_component = geometry_set.get_component_for_write<MeshComponent>();
- mesh_component.replace(input_mesh, GeometryOwnershipType::Editable);
- mesh_component.copy_vertex_group_names_from_object(*ob);
+ /* Replace only the mesh rather than the whole component, because the entire #MeshComponent
+ * might have been replaced by data from a different object in the node tree, which means the
+ * component contains vertex group name data for that object that should not be removed. */
+ mesh_component.replace_mesh_but_keep_vertex_group_names(input_mesh,
+ GeometryOwnershipType::Editable);
/* Let the modifier change the geometry set. */
mti->modifyGeometrySet(md, &mectx, &geometry_set);
@@ -919,7 +920,6 @@ static Mesh *modifier_modify_mesh_and_geometry_set(ModifierData *md,
if (geometry_set.has<MeshComponent>()) {
MeshComponent &mesh_component = geometry_set.get_component_for_write<MeshComponent>();
mesh_output = mesh_component.release();
- geometry_set.remove<MeshComponent>();
}
/* Return an empty mesh instead of null. */
@@ -954,6 +954,13 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
Mesh *mesh_deform = nullptr;
/* This geometry set contains the non-mesh data that might be generated by modifiers. */
GeometrySet geometry_set_final;
+
+ /* Add the initial mesh component, with a copy of the vertex group names from the object,
+ * since they need to be stored in the geometry set for evaluation. */
+ MeshComponent &initial_mesh_component =
+ geometry_set_final.get_component_for_write<MeshComponent>();
+ initial_mesh_component.copy_vertex_group_names_from_object(*ob);
+
BLI_assert((mesh_input->id.tag & LIB_TAG_COPIED_ON_WRITE_EVAL_RESULT) == 0);
/* Deformed vertex locations array. Deform only modifier need this type of
@@ -1252,7 +1259,7 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
}
Mesh *mesh_next = modifier_modify_mesh_and_geometry_set(
- md, mectx, ob, mesh_final, geometry_set_final);
+ md, mectx, mesh_final, geometry_set_final);
ASSERT_IS_VALID_MESH(mesh_next);
if (mesh_next) {
@@ -1717,7 +1724,7 @@ static void editbmesh_calc_modifiers(struct Depsgraph *depsgraph,
}
Mesh *mesh_next = modifier_modify_mesh_and_geometry_set(
- md, mectx, ob, mesh_final, geometry_set_final);
+ md, mectx, mesh_final, geometry_set_final);
ASSERT_IS_VALID_MESH(mesh_next);
if (mesh_next) {
@@ -1893,9 +1900,9 @@ static void mesh_build_data(struct Depsgraph *depsgraph,
BKE_object_eval_assign_data(ob, &mesh_eval->id, is_mesh_eval_owned);
/* Add the final mesh as read-only non-owning component to the geometry set. */
- BLI_assert(!geometry_set_eval->has<MeshComponent>());
MeshComponent &mesh_component = geometry_set_eval->get_component_for_write<MeshComponent>();
- mesh_component.replace(mesh_eval, GeometryOwnershipType::ReadOnly);
+ mesh_component.replace_mesh_but_keep_vertex_group_names(mesh_eval,
+ GeometryOwnershipType::ReadOnly);
ob->runtime.geometry_set_eval = geometry_set_eval;
ob->runtime.mesh_deform_eval = mesh_deform_eval;
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index 0f8a11a40b2..59248e5f9f8 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -4001,8 +4001,11 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *fmd,
has_config = manta_read_config(fds->fluid, fmd, mesh_frame);
}
- /* Update mesh data from file is faster than via Python (manta_read_mesh()). */
- has_mesh = manta_read_mesh(fds->fluid, fmd, mesh_frame);
+ /* Only load the mesh at the resolution it ways originally simulated at.
+ * The mesh files don't have a header, i.e. the don't store the grid resolution. */
+ if (!manta_needs_realloc(fds->fluid, fmd)) {
+ has_mesh = manta_read_mesh(fds->fluid, fmd, mesh_frame);
+ }
}
/* Read particles cache. */
diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc
index 6c4de64861d..005d07688d7 100644
--- a/source/blender/blenkernel/intern/geometry_set.cc
+++ b/source/blender/blenkernel/intern/geometry_set.cc
@@ -344,6 +344,23 @@ void MeshComponent::replace(Mesh *mesh, GeometryOwnershipType ownership)
ownership_ = ownership;
}
+/* This function exists for the same reason as #vertex_group_names_. Non-nodes modifiers need to
+ * be able to replace the mesh data without losing the vertex group names, which may have come
+ * from another object. */
+void MeshComponent::replace_mesh_but_keep_vertex_group_names(Mesh *mesh,
+ GeometryOwnershipType ownership)
+{
+ BLI_assert(this->is_mutable());
+ if (mesh_ != nullptr) {
+ if (ownership_ == GeometryOwnershipType::Owned) {
+ BKE_id_free(nullptr, mesh_);
+ }
+ mesh_ = nullptr;
+ }
+ mesh_ = mesh;
+ ownership_ = ownership;
+}
+
/* Return the mesh and clear the component. The caller takes over responsibility for freeing the
* mesh (if the component was responsible before). */
Mesh *MeshComponent::release()
diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index 7ccf53546b8..9e8e515e1a3 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -368,6 +368,46 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain)
return success;
}
+/* Tag all IDs in dependency relationships within an override hierarchy/group.
+ *
+ * Note: this is typically called to complete `lib_override_linked_group_tag()`.
+ * Note: BMain's relations mapping won't be valid anymore after that call.
+ */
+static bool lib_override_hierarchy_dependencies_recursive_tag(Main *bmain,
+ ID *id,
+ const uint tag,
+ const uint missing_tag)
+{
+ MainIDRelationsEntry *entry = BLI_ghash_lookup(bmain->relations->relations_from_pointers, id);
+ BLI_assert(entry != NULL);
+
+ if (entry->tags & MAINIDRELATIONS_ENTRY_TAGS_PROCESSED) {
+ /* This ID has already been processed. */
+ return (*(uint *)&id->tag & tag) != 0;
+ }
+ /* This way we won't process again that ID, should we encounter it again through another
+ * relationship hierarchy. */
+ entry->tags |= MAINIDRELATIONS_ENTRY_TAGS_PROCESSED;
+
+ for (MainIDRelationsEntryItem *to_id_entry = entry->to_ids; to_id_entry != NULL;
+ to_id_entry = to_id_entry->next) {
+ if ((to_id_entry->usage_flag & IDWALK_CB_LOOPBACK) != 0) {
+ /* Never consider 'loop back' relationships ('from', 'parents', 'owner' etc. pointers) as
+ * actual dependencies. */
+ continue;
+ }
+ /* We only consider IDs from the same library. */
+ ID *to_id = *to_id_entry->id_pointer.to;
+ if (to_id != NULL && to_id->lib == id->lib) {
+ if (lib_override_hierarchy_dependencies_recursive_tag(bmain, to_id, tag, missing_tag)) {
+ id->tag |= tag;
+ }
+ }
+ }
+
+ return (*(uint *)&id->tag & tag) != 0;
+}
+
typedef struct LibOverrideGroupTagData {
ID *id_root;
uint tag;
@@ -422,46 +462,6 @@ static int lib_override_linked_group_tag_cb(LibraryIDLinkCallbackData *cb_data)
return IDWALK_RET_NOP;
}
-/* Tag all IDs in dependency relationships within an override hierarchy/group.
- *
- * Note: this is typically called to complete `lib_override_linked_group_tag()`.
- * Note: BMain's relations mapping won't be valid anymore after that call.
- */
-static bool lib_override_hierarchy_dependencies_recursive_tag(Main *bmain,
- ID *id,
- const uint tag,
- const uint missing_tag)
-{
- MainIDRelationsEntry *entry = BLI_ghash_lookup(bmain->relations->relations_from_pointers, id);
- BLI_assert(entry != NULL);
-
- if (entry->tags & MAINIDRELATIONS_ENTRY_TAGS_PROCESSED) {
- /* This ID has already been processed. */
- return (*(uint *)&id->tag & tag) != 0;
- }
- /* This way we won't process again that ID, should we encounter it again through another
- * relationship hierarchy. */
- entry->tags |= MAINIDRELATIONS_ENTRY_TAGS_PROCESSED;
-
- for (MainIDRelationsEntryItem *to_id_entry = entry->to_ids; to_id_entry != NULL;
- to_id_entry = to_id_entry->next) {
- if ((to_id_entry->usage_flag & IDWALK_CB_LOOPBACK) != 0) {
- /* Never consider 'loop back' relationships ('from', 'parents', 'owner' etc. pointers) as
- * actual dependencies. */
- continue;
- }
- /* We only consider IDs from the same library. */
- ID *to_id = *to_id_entry->id_pointer.to;
- if (to_id != NULL && to_id->lib == id->lib) {
- if (lib_override_hierarchy_dependencies_recursive_tag(bmain, to_id, tag, missing_tag)) {
- id->tag |= tag;
- }
- }
- }
-
- return (*(uint *)&id->tag & tag) != 0;
-}
-
/* This will tag at least all 'boundary' linked IDs for a potential override group.
*
* Note that you will then need to call #lib_override_hierarchy_dependencies_recursive_tag to
diff --git a/source/blender/blenkernel/intern/main.c b/source/blender/blenkernel/intern/main.c
index 4a7636926e6..d5cbcb62af2 100644
--- a/source/blender/blenkernel/intern/main.c
+++ b/source/blender/blenkernel/intern/main.c
@@ -309,6 +309,27 @@ void BKE_main_relations_free(Main *bmain)
}
}
+/** Set or clear given `tag` in all relation entries of given `bmain`. */
+void BKE_main_relations_tag_set(struct Main *bmain,
+ const MainIDRelationsEntryTags tag,
+ const bool value)
+{
+ if (bmain->relations == NULL) {
+ return;
+ }
+ for (GHashIterator *gh_iter = BLI_ghashIterator_new(bmain->relations->relations_from_pointers);
+ !BLI_ghashIterator_done(gh_iter);
+ BLI_ghashIterator_step(gh_iter)) {
+ MainIDRelationsEntry *entry = BLI_ghashIterator_getValue(gh_iter);
+ if (value) {
+ entry->tags |= tag;
+ }
+ else {
+ entry->tags &= ~tag;
+ }
+ }
+}
+
/**
* Create a GSet storing all IDs present in given \a bmain, by their pointers.
*
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.cc
index 247bfafc099..39e23e34341 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.cc
@@ -25,10 +25,10 @@
#include "MEM_guardedalloc.h"
-#include <limits.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
+#include <climits>
+#include <cstddef>
+#include <cstdlib>
+#include <cstring>
/* Allow using deprecated functionality for .blend file I/O. */
#define DNA_DEPRECATED_ALLOW
@@ -109,7 +109,7 @@ static void node_socket_interface_free(bNodeTree *UNUSED(ntree),
static void ntree_init_data(ID *id)
{
bNodeTree *ntree = (bNodeTree *)id;
- ntree_set_typeinfo(ntree, NULL);
+ ntree_set_typeinfo(ntree, nullptr);
}
static void ntree_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, const int flag)
@@ -121,7 +121,7 @@ static void ntree_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, c
const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT;
/* in case a running nodetree is copied */
- ntree_dst->execdata = NULL;
+ ntree_dst->execdata = nullptr;
BLI_listbase_clear(&ntree_dst->nodes);
BLI_listbase_clear(&ntree_dst->links);
@@ -133,17 +133,17 @@ static void ntree_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, c
bNode *new_node = BKE_node_copy_ex(ntree_dst, node_src, flag_subdata, true);
BLI_ghash_insert(new_pointers, (void *)node_src, new_node);
/* Store mapping to inputs. */
- bNodeSocket *new_input_sock = new_node->inputs.first;
- const bNodeSocket *input_sock_src = node_src->inputs.first;
- while (new_input_sock != NULL) {
+ bNodeSocket *new_input_sock = (bNodeSocket *)new_node->inputs.first;
+ const bNodeSocket *input_sock_src = (const bNodeSocket *)node_src->inputs.first;
+ while (new_input_sock != nullptr) {
BLI_ghash_insert(new_pointers, (void *)input_sock_src, new_input_sock);
new_input_sock = new_input_sock->next;
input_sock_src = input_sock_src->next;
}
/* Store mapping to outputs. */
- bNodeSocket *new_output_sock = new_node->outputs.first;
- const bNodeSocket *output_sock_src = node_src->outputs.first;
- while (new_output_sock != NULL) {
+ bNodeSocket *new_output_sock = (bNodeSocket *)new_node->outputs.first;
+ const bNodeSocket *output_sock_src = (const bNodeSocket *)node_src->outputs.first;
+ while (new_output_sock != nullptr) {
BLI_ghash_insert(new_pointers, (void *)output_sock_src, new_output_sock);
new_output_sock = new_output_sock->next;
output_sock_src = output_sock_src->next;
@@ -153,10 +153,13 @@ static void ntree_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, c
/* copy links */
BLI_duplicatelist(&ntree_dst->links, &ntree_src->links);
LISTBASE_FOREACH (bNodeLink *, link_dst, &ntree_dst->links) {
- link_dst->fromnode = BLI_ghash_lookup_default(new_pointers, link_dst->fromnode, NULL);
- link_dst->fromsock = BLI_ghash_lookup_default(new_pointers, link_dst->fromsock, NULL);
- link_dst->tonode = BLI_ghash_lookup_default(new_pointers, link_dst->tonode, NULL);
- link_dst->tosock = BLI_ghash_lookup_default(new_pointers, link_dst->tosock, NULL);
+ link_dst->fromnode = (bNode *)BLI_ghash_lookup_default(
+ new_pointers, link_dst->fromnode, nullptr);
+ link_dst->fromsock = (bNodeSocket *)BLI_ghash_lookup_default(
+ new_pointers, link_dst->fromsock, nullptr);
+ link_dst->tonode = (bNode *)BLI_ghash_lookup_default(new_pointers, link_dst->tonode, nullptr);
+ link_dst->tosock = (bNodeSocket *)BLI_ghash_lookup_default(
+ new_pointers, link_dst->tosock, nullptr);
/* update the link socket's pointer */
if (link_dst->tosock) {
link_dst->tosock->link = link_dst;
@@ -166,14 +169,18 @@ static void ntree_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, c
/* copy interface sockets */
BLI_duplicatelist(&ntree_dst->inputs, &ntree_src->inputs);
bNodeSocket *sock_dst, *sock_src;
- for (sock_dst = ntree_dst->inputs.first, sock_src = ntree_src->inputs.first; sock_dst != NULL;
- sock_dst = sock_dst->next, sock_src = sock_src->next) {
+ for (sock_dst = (bNodeSocket *)ntree_dst->inputs.first,
+ sock_src = (bNodeSocket *)ntree_src->inputs.first;
+ sock_dst != nullptr;
+ sock_dst = (bNodeSocket *)sock_dst->next, sock_src = (bNodeSocket *)sock_src->next) {
node_socket_copy(sock_dst, sock_src, flag_subdata);
}
BLI_duplicatelist(&ntree_dst->outputs, &ntree_src->outputs);
- for (sock_dst = ntree_dst->outputs.first, sock_src = ntree_src->outputs.first; sock_dst != NULL;
- sock_dst = sock_dst->next, sock_src = sock_src->next) {
+ for (sock_dst = (bNodeSocket *)ntree_dst->outputs.first,
+ sock_src = (bNodeSocket *)ntree_src->outputs.first;
+ sock_dst != nullptr;
+ sock_dst = (bNodeSocket *)sock_dst->next, sock_src = (bNodeSocket *)sock_src->next) {
node_socket_copy(sock_dst, sock_src, flag_subdata);
}
@@ -185,26 +192,29 @@ static void ntree_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, c
NODE_INSTANCE_HASH_ITER (iter, ntree_src->previews) {
bNodeInstanceKey key = BKE_node_instance_hash_iterator_get_key(&iter);
- bNodePreview *preview = BKE_node_instance_hash_iterator_get_value(&iter);
+ bNodePreview *preview = (bNodePreview *)BKE_node_instance_hash_iterator_get_value(&iter);
BKE_node_instance_hash_insert(ntree_dst->previews, key, BKE_node_preview_copy(preview));
}
}
else {
- ntree_dst->previews = NULL;
+ ntree_dst->previews = nullptr;
}
/* update node->parent pointers */
- for (bNode *node_dst = ntree_dst->nodes.first, *node_src = ntree_src->nodes.first; node_dst;
- node_dst = node_dst->next, node_src = node_src->next) {
+ for (bNode *node_dst = (bNode *)ntree_dst->nodes.first,
+ *node_src = (bNode *)ntree_src->nodes.first;
+ node_dst;
+ node_dst = (bNode *)node_dst->next, node_src = (bNode *)node_src->next) {
if (node_dst->parent) {
- node_dst->parent = BLI_ghash_lookup_default(new_pointers, node_dst->parent, NULL);
+ node_dst->parent = (bNode *)BLI_ghash_lookup_default(
+ new_pointers, node_dst->parent, nullptr);
}
}
- BLI_ghash_free(new_pointers, NULL, NULL);
+ BLI_ghash_free(new_pointers, nullptr, nullptr);
/* node tree will generate its own interface type */
- ntree_dst->interface_type = NULL;
+ ntree_dst->interface_type = nullptr;
}
static void ntree_free_data(ID *id)
@@ -223,7 +233,7 @@ static void ntree_free_data(ID *id)
break;
case NTREE_TEXTURE:
ntreeTexEndExecTree(ntree->execdata);
- ntree->execdata = NULL;
+ ntree->execdata = nullptr;
break;
}
}
@@ -267,17 +277,18 @@ static void library_foreach_node_socket(LibraryForeachIDData *data, bNodeSocket
switch ((eNodeSocketDatatype)sock->type) {
case SOCK_OBJECT: {
- bNodeSocketValueObject *default_value = sock->default_value;
+ bNodeSocketValueObject *default_value = (bNodeSocketValueObject *)sock->default_value;
BKE_LIB_FOREACHID_PROCESS(data, default_value->value, IDWALK_CB_USER);
break;
}
case SOCK_IMAGE: {
- bNodeSocketValueImage *default_value = sock->default_value;
+ bNodeSocketValueImage *default_value = (bNodeSocketValueImage *)sock->default_value;
BKE_LIB_FOREACHID_PROCESS(data, default_value->value, IDWALK_CB_USER);
break;
}
case SOCK_COLLECTION: {
- bNodeSocketValueCollection *default_value = sock->default_value;
+ bNodeSocketValueCollection *default_value = (bNodeSocketValueCollection *)
+ sock->default_value;
BKE_LIB_FOREACHID_PROCESS(data, default_value->value, IDWALK_CB_USER);
break;
}
@@ -327,11 +338,10 @@ static void node_foreach_cache(ID *id,
void *user_data)
{
bNodeTree *nodetree = (bNodeTree *)id;
- IDCacheKey key = {
- .id_session_uuid = id->session_uuid,
- .offset_in_ID = offsetof(bNodeTree, previews),
- .cache_v = nodetree->previews,
- };
+ IDCacheKey key = {0};
+ key.id_session_uuid = id->session_uuid;
+ key.offset_in_ID = offsetof(bNodeTree, previews);
+ key.cache_v = nodetree->previews;
/* TODO, see also `direct_link_nodetree()` in readfile.c. */
#if 0
@@ -351,7 +361,7 @@ static void node_foreach_cache(ID *id,
static void write_node_socket_default_value(BlendWriter *writer, bNodeSocket *sock)
{
- if (sock->default_value == NULL) {
+ if (sock->default_value == nullptr) {
return;
}
@@ -448,7 +458,7 @@ void ntreeBlendWrite(BlendWriter *writer, bNodeTree *ntree)
/* could be handlerized at some point, now only 1 exception still */
if ((ntree->type == NTREE_SHADER) &&
ELEM(node->type, SH_NODE_CURVE_VEC, SH_NODE_CURVE_RGB)) {
- BKE_curvemapping_blend_write(writer, node->storage);
+ BKE_curvemapping_blend_write(writer, (const CurveMapping *)node->storage);
}
else if (ntree->type == NTREE_SHADER && (node->type == SH_NODE_SCRIPT)) {
NodeShaderScript *nss = (NodeShaderScript *)node->storage;
@@ -462,11 +472,11 @@ void ntreeBlendWrite(BlendWriter *writer, bNodeTree *ntree)
CMP_NODE_CURVE_VEC,
CMP_NODE_CURVE_RGB,
CMP_NODE_HUECORRECT)) {
- BKE_curvemapping_blend_write(writer, node->storage);
+ BKE_curvemapping_blend_write(writer, (const CurveMapping *)node->storage);
}
else if ((ntree->type == NTREE_TEXTURE) &&
(node->type == TEX_NODE_CURVE_RGB || node->type == TEX_NODE_CURVE_TIME)) {
- BKE_curvemapping_blend_write(writer, node->storage);
+ BKE_curvemapping_blend_write(writer, (const CurveMapping *)node->storage);
}
else if ((ntree->type == NTREE_COMPOSIT) && (node->type == CMP_NODE_MOVIEDISTORTION)) {
/* pass */
@@ -474,7 +484,7 @@ void ntreeBlendWrite(BlendWriter *writer, bNodeTree *ntree)
else if ((ntree->type == NTREE_COMPOSIT) && (node->type == CMP_NODE_GLARE)) {
/* Simple forward compatibility for fix for T50736.
* Not ideal (there is no ideal solution here), but should do for now. */
- NodeGlare *ndg = node->storage;
+ NodeGlare *ndg = (NodeGlare *)node->storage;
/* Not in undo case. */
if (!BLO_write_is_undo(writer)) {
switch (ndg->type) {
@@ -543,10 +553,10 @@ static void ntree_blend_write(BlendWriter *writer, ID *id, const void *id_addres
/* Clean up, important in undo case to reduce false detection of changed datablocks. */
ntree->init = 0; /* to set callbacks and force setting types */
ntree->is_updating = false;
- ntree->typeinfo = NULL;
- ntree->interface_type = NULL;
- ntree->progress = NULL;
- ntree->execdata = NULL;
+ ntree->typeinfo = nullptr;
+ ntree->interface_type = nullptr;
+ ntree->progress = nullptr;
+ ntree->execdata = nullptr;
BLO_write_id_struct(writer, bNodeTree, id_address, &ntree->id);
@@ -560,10 +570,10 @@ static void direct_link_node_socket(BlendDataReader *reader, bNodeSocket *sock)
IDP_BlendDataRead(reader, &sock->prop);
BLO_read_data_address(reader, &sock->link);
- sock->typeinfo = NULL;
+ sock->typeinfo = nullptr;
BLO_read_data_address(reader, &sock->storage);
BLO_read_data_address(reader, &sock->default_value);
- sock->cache = NULL;
+ sock->cache = nullptr;
}
/* ntree itself has been read! */
@@ -572,18 +582,18 @@ void ntreeBlendReadData(BlendDataReader *reader, bNodeTree *ntree)
/* note: writing and reading goes in sync, for speed */
ntree->init = 0; /* to set callbacks and force setting types */
ntree->is_updating = false;
- ntree->typeinfo = NULL;
- ntree->interface_type = NULL;
+ ntree->typeinfo = nullptr;
+ ntree->interface_type = nullptr;
- ntree->progress = NULL;
- ntree->execdata = NULL;
+ ntree->progress = nullptr;
+ ntree->execdata = nullptr;
BLO_read_data_address(reader, &ntree->adt);
BKE_animdata_blend_read_data(reader, ntree->adt);
BLO_read_list(reader, &ntree->nodes);
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
- node->typeinfo = NULL;
+ node->typeinfo = nullptr;
BLO_read_list(reader, &node->inputs);
BLO_read_list(reader, &node->outputs);
@@ -618,7 +628,7 @@ void ntreeBlendReadData(BlendDataReader *reader, bNodeTree *ntree)
case CMP_NODE_HUECORRECT:
case TEX_NODE_CURVE_RGB:
case TEX_NODE_CURVE_TIME: {
- BKE_curvemapping_blend_read(reader, node->storage);
+ BKE_curvemapping_blend_read(reader, (CurveMapping *)node->storage);
break;
}
case SH_NODE_SCRIPT: {
@@ -634,22 +644,22 @@ void ntreeBlendReadData(BlendDataReader *reader, bNodeTree *ntree)
case SH_NODE_TEX_IMAGE: {
NodeTexImage *tex = (NodeTexImage *)node->storage;
tex->iuser.ok = 1;
- tex->iuser.scene = NULL;
+ tex->iuser.scene = nullptr;
break;
}
case SH_NODE_TEX_ENVIRONMENT: {
NodeTexEnvironment *tex = (NodeTexEnvironment *)node->storage;
tex->iuser.ok = 1;
- tex->iuser.scene = NULL;
+ tex->iuser.scene = nullptr;
break;
}
case CMP_NODE_IMAGE:
case CMP_NODE_R_LAYERS:
case CMP_NODE_VIEWER:
case CMP_NODE_SPLITVIEWER: {
- ImageUser *iuser = node->storage;
+ ImageUser *iuser = (ImageUser *)node->storage;
iuser->ok = 1;
- iuser->scene = NULL;
+ iuser->scene = nullptr;
break;
}
case CMP_NODE_CRYPTOMATTE: {
@@ -659,9 +669,9 @@ void ntreeBlendReadData(BlendDataReader *reader, bNodeTree *ntree)
break;
}
case TEX_NODE_IMAGE: {
- ImageUser *iuser = node->storage;
+ ImageUser *iuser = (ImageUser *)node->storage;
iuser->ok = 1;
- iuser->scene = NULL;
+ iuser->scene = nullptr;
break;
}
default:
@@ -701,7 +711,7 @@ void ntreeBlendReadData(BlendDataReader *reader, bNodeTree *ntree)
}
/* TODO, should be dealt by new generic cache handling of IDs... */
- ntree->previews = NULL;
+ ntree->previews = nullptr;
/* type verification is in lib-link */
}
@@ -718,17 +728,18 @@ static void lib_link_node_socket(BlendLibReader *reader, Library *lib, bNodeSock
switch ((eNodeSocketDatatype)sock->type) {
case SOCK_OBJECT: {
- bNodeSocketValueObject *default_value = sock->default_value;
+ bNodeSocketValueObject *default_value = (bNodeSocketValueObject *)sock->default_value;
BLO_read_id_address(reader, lib, &default_value->value);
break;
}
case SOCK_IMAGE: {
- bNodeSocketValueImage *default_value = sock->default_value;
+ bNodeSocketValueImage *default_value = (bNodeSocketValueImage *)sock->default_value;
BLO_read_id_address(reader, lib, &default_value->value);
break;
}
case SOCK_COLLECTION: {
- bNodeSocketValueImage *default_value = sock->default_value;
+ bNodeSocketValueCollection *default_value = (bNodeSocketValueCollection *)
+ sock->default_value;
BLO_read_id_address(reader, lib, &default_value->value);
break;
}
@@ -777,7 +788,7 @@ void ntreeBlendReadLib(struct BlendLibReader *reader, struct bNodeTree *ntree)
* first versioning that can change types still without functions that
* update the typeinfo pointers. Versioning after lib linking needs
* these top be valid. */
- ntreeSetTypes(NULL, ntree);
+ ntreeSetTypes(nullptr, ntree);
/* For nodes with static socket layout, add/remove sockets as needed
* to match the static layout. */
@@ -798,21 +809,22 @@ static void expand_node_socket(BlendExpander *expander, bNodeSocket *sock)
{
IDP_BlendReadExpand(expander, sock->prop);
- if (sock->default_value != NULL) {
+ if (sock->default_value != nullptr) {
switch ((eNodeSocketDatatype)sock->type) {
case SOCK_OBJECT: {
- bNodeSocketValueObject *default_value = sock->default_value;
+ bNodeSocketValueObject *default_value = (bNodeSocketValueObject *)sock->default_value;
BLO_expand(expander, default_value->value);
break;
}
case SOCK_IMAGE: {
- bNodeSocketValueImage *default_value = sock->default_value;
+ bNodeSocketValueImage *default_value = (bNodeSocketValueImage *)sock->default_value;
BLO_expand(expander, default_value->value);
break;
}
case SOCK_COLLECTION: {
- bNodeSocketValueCollection *default_value = sock->default_value;
+ bNodeSocketValueCollection *default_value = (bNodeSocketValueCollection *)
+ sock->default_value;
BLO_expand(expander, default_value->value);
break;
}
@@ -866,30 +878,30 @@ static void ntree_blend_read_expand(BlendExpander *expander, ID *id)
}
IDTypeInfo IDType_ID_NT = {
- .id_code = ID_NT,
- .id_filter = FILTER_ID_NT,
- .main_listbase_index = INDEX_ID_NT,
- .struct_size = sizeof(bNodeTree),
- .name = "NodeTree",
- .name_plural = "node_groups",
- .translation_context = BLT_I18NCONTEXT_ID_NODETREE,
- .flags = 0,
-
- .init_data = ntree_init_data,
- .copy_data = ntree_copy_data,
- .free_data = ntree_free_data,
- .make_local = NULL,
- .foreach_id = node_foreach_id,
- .foreach_cache = node_foreach_cache,
-
- .blend_write = ntree_blend_write,
- .blend_read_data = ntree_blend_read_data,
- .blend_read_lib = ntree_blend_read_lib,
- .blend_read_expand = ntree_blend_read_expand,
-
- .blend_read_undo_preserve = NULL,
-
- .lib_override_apply_post = NULL,
+ /* id_code */ ID_NT,
+ /* id_filter */ FILTER_ID_NT,
+ /* main_listbase_index */ INDEX_ID_NT,
+ /* struct_size */ sizeof(bNodeTree),
+ /* name */ "NodeTree",
+ /* name_plural */ "node_groups",
+ /* translation_context */ BLT_I18NCONTEXT_ID_NODETREE,
+ /* flags */ 0,
+
+ /* init_data */ ntree_init_data,
+ /* copy_data */ ntree_copy_data,
+ /* free_data */ ntree_free_data,
+ /* make_local */ nullptr,
+ /* foreach_id */ node_foreach_id,
+ /* foreach_cache */ node_foreach_cache,
+
+ /* blend_write */ ntree_blend_write,
+ /* blend_read_data */ ntree_blend_read_data,
+ /* blend_read_lib */ ntree_blend_read_lib,
+ /* blend_read_expand */ ntree_blend_read_expand,
+
+ /* blend_read_undo_preserve */ nullptr,
+
+ /* lib_override_apply_post */ nullptr,
};
static void node_add_sockets_from_type(bNodeTree *ntree, bNode *node, bNodeType *ntype)
@@ -949,11 +961,11 @@ static void node_init(const struct bContext *C, bNodeTree *ntree, bNode *node)
node_add_sockets_from_type(ntree, node, ntype);
- if (ntype->initfunc != NULL) {
+ if (ntype->initfunc != nullptr) {
ntype->initfunc(ntree, node);
}
- if (ntree->typeinfo->node_add_init != NULL) {
+ if (ntree->typeinfo->node_add_init != nullptr) {
ntree->typeinfo->node_add_init(ntree, node);
}
@@ -966,10 +978,10 @@ static void node_init(const struct bContext *C, bNodeTree *ntree, bNode *node)
PointerRNA ptr;
RNA_pointer_create((ID *)ntree, &RNA_Node, node, &ptr);
- /* XXX Warning: context can be NULL in case nodes are added in do_versions.
+ /* XXX Warning: context can be nullptr in case nodes are added in do_versions.
* Delayed init is not supported for nodes with context-based initfunc_api atm.
*/
- BLI_assert(C != NULL);
+ BLI_assert(C != nullptr);
ntype->initfunc_api(C, &ptr);
}
@@ -999,7 +1011,7 @@ static void node_set_typeinfo(const struct bContext *C,
/* for nodes saved in older versions storage can get lost, make undefined then */
if (node->flag & NODE_INIT) {
if (typeinfo && typeinfo->storagename[0] && !node->storage) {
- typeinfo = NULL;
+ typeinfo = nullptr;
}
}
@@ -1029,7 +1041,7 @@ static void node_socket_set_typeinfo(bNodeTree *ntree,
/* deprecated integer type */
sock->type = typeinfo->type;
- if (sock->default_value == NULL) {
+ if (sock->default_value == nullptr) {
/* initialize the default_value pointer used by standard socket types */
node_socket_init_default_value(sock);
}
@@ -1057,24 +1069,24 @@ static void update_typeinfo(Main *bmain,
ntree->init |= NTREE_TYPE_INIT;
if (treetype && STREQ(ntree->idname, treetype->idname)) {
- ntree_set_typeinfo(ntree, unregister ? NULL : treetype);
+ ntree_set_typeinfo(ntree, unregister ? nullptr : treetype);
}
/* initialize nodes */
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (nodetype && STREQ(node->idname, nodetype->idname)) {
- node_set_typeinfo(C, ntree, node, unregister ? NULL : nodetype);
+ node_set_typeinfo(C, ntree, node, unregister ? nullptr : nodetype);
}
/* initialize node sockets */
LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
if (socktype && STREQ(sock->idname, socktype->idname)) {
- node_socket_set_typeinfo(ntree, sock, unregister ? NULL : socktype);
+ node_socket_set_typeinfo(ntree, sock, unregister ? nullptr : socktype);
}
}
LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
if (socktype && STREQ(sock->idname, socktype->idname)) {
- node_socket_set_typeinfo(ntree, sock, unregister ? NULL : socktype);
+ node_socket_set_typeinfo(ntree, sock, unregister ? nullptr : socktype);
}
}
}
@@ -1082,12 +1094,12 @@ static void update_typeinfo(Main *bmain,
/* initialize tree sockets */
LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->inputs) {
if (socktype && STREQ(sock->idname, socktype->idname)) {
- node_socket_set_typeinfo(ntree, sock, unregister ? NULL : socktype);
+ node_socket_set_typeinfo(ntree, sock, unregister ? nullptr : socktype);
}
}
LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->outputs) {
if (socktype && STREQ(sock->idname, socktype->idname)) {
- node_socket_set_typeinfo(ntree, sock, unregister ? NULL : socktype);
+ node_socket_set_typeinfo(ntree, sock, unregister ? nullptr : socktype);
}
}
}
@@ -1125,22 +1137,20 @@ void ntreeSetTypes(const struct bContext *C, bNodeTree *ntree)
}
}
-static GHash *nodetreetypes_hash = NULL;
-static GHash *nodetypes_hash = NULL;
-static GHash *nodesockettypes_hash = NULL;
+static GHash *nodetreetypes_hash = nullptr;
+static GHash *nodetypes_hash = nullptr;
+static GHash *nodesockettypes_hash = nullptr;
bNodeTreeType *ntreeTypeFind(const char *idname)
{
- bNodeTreeType *nt;
-
if (idname[0]) {
- nt = BLI_ghash_lookup(nodetreetypes_hash, idname);
+ bNodeTreeType *nt = (bNodeTreeType *)BLI_ghash_lookup(nodetreetypes_hash, idname);
if (nt) {
return nt;
}
}
- return NULL;
+ return nullptr;
}
void ntreeTypeAdd(bNodeTreeType *nt)
@@ -1149,23 +1159,23 @@ void ntreeTypeAdd(bNodeTreeType *nt)
/* XXX pass Main to register function? */
/* Probably not. It is pretty much expected we want to update G_MAIN here I think -
* or we'd want to update *all* active Mains, which we cannot do anyway currently. */
- update_typeinfo(G_MAIN, NULL, nt, NULL, NULL, false);
+ update_typeinfo(G_MAIN, nullptr, nt, nullptr, nullptr, false);
}
/* callback for hash value free function */
static void ntree_free_type(void *treetype_v)
{
- bNodeTreeType *treetype = treetype_v;
+ bNodeTreeType *treetype = (bNodeTreeType *)treetype_v;
/* XXX pass Main to unregister function? */
/* Probably not. It is pretty much expected we want to update G_MAIN here I think -
* or we'd want to update *all* active Mains, which we cannot do anyway currently. */
- update_typeinfo(G_MAIN, NULL, treetype, NULL, NULL, true);
+ update_typeinfo(G_MAIN, nullptr, treetype, nullptr, nullptr, true);
MEM_freeN(treetype);
}
void ntreeTypeFreeLink(const bNodeTreeType *nt)
{
- BLI_ghash_remove(nodetreetypes_hash, nt->idname, NULL, ntree_free_type);
+ BLI_ghash_remove(nodetreetypes_hash, nt->idname, nullptr, ntree_free_type);
}
bool ntreeIsRegistered(bNodeTree *ntree)
@@ -1181,13 +1191,13 @@ GHashIterator *ntreeTypeGetIterator(void)
bNodeType *nodeTypeFind(const char *idname)
{
if (idname[0]) {
- bNodeType *nt = BLI_ghash_lookup(nodetypes_hash, idname);
+ bNodeType *nt = (bNodeType *)BLI_ghash_lookup(nodetypes_hash, idname);
if (nt) {
return nt;
}
}
- return NULL;
+ return nullptr;
}
static void free_dynamic_typeinfo(bNodeType *ntype)
@@ -1205,18 +1215,18 @@ static void free_dynamic_typeinfo(bNodeType *ntype)
/* callback for hash value free function */
static void node_free_type(void *nodetype_v)
{
- bNodeType *nodetype = nodetype_v;
+ bNodeType *nodetype = (bNodeType *)nodetype_v;
/* XXX pass Main to unregister function? */
/* Probably not. It is pretty much expected we want to update G_MAIN here I think -
* or we'd want to update *all* active Mains, which we cannot do anyway currently. */
- update_typeinfo(G_MAIN, NULL, NULL, nodetype, NULL, true);
+ update_typeinfo(G_MAIN, nullptr, nullptr, nodetype, nullptr, true);
/* XXX deprecated */
if (nodetype->type == NODE_DYNAMIC) {
free_dynamic_typeinfo(nodetype);
}
- /* Can be NULL when the type is not dynamically allocated. */
+ /* Can be null when the type is not dynamically allocated. */
if (nodetype->free_self) {
nodetype->free_self(nodetype);
}
@@ -1226,18 +1236,18 @@ void nodeRegisterType(bNodeType *nt)
{
/* debug only: basic verification of registered types */
BLI_assert(nt->idname[0] != '\0');
- BLI_assert(nt->poll != NULL);
+ BLI_assert(nt->poll != nullptr);
BLI_ghash_insert(nodetypes_hash, nt->idname, nt);
/* XXX pass Main to register function? */
/* Probably not. It is pretty much expected we want to update G_MAIN here I think -
* or we'd want to update *all* active Mains, which we cannot do anyway currently. */
- update_typeinfo(G_MAIN, NULL, NULL, nt, NULL, false);
+ update_typeinfo(G_MAIN, nullptr, nullptr, nt, nullptr, false);
}
void nodeUnregisterType(bNodeType *nt)
{
- BLI_ghash_remove(nodetypes_hash, nt->idname, NULL, node_free_type);
+ BLI_ghash_remove(nodetypes_hash, nt->idname, nullptr, node_free_type);
}
bool nodeTypeUndefined(bNode *node)
@@ -1255,23 +1265,23 @@ GHashIterator *nodeTypeGetIterator(void)
bNodeSocketType *nodeSocketTypeFind(const char *idname)
{
if (idname[0]) {
- bNodeSocketType *st = BLI_ghash_lookup(nodesockettypes_hash, idname);
+ bNodeSocketType *st = (bNodeSocketType *)BLI_ghash_lookup(nodesockettypes_hash, idname);
if (st) {
return st;
}
}
- return NULL;
+ return nullptr;
}
/* callback for hash value free function */
static void node_free_socket_type(void *socktype_v)
{
- bNodeSocketType *socktype = socktype_v;
+ bNodeSocketType *socktype = (bNodeSocketType *)socktype_v;
/* XXX pass Main to unregister function? */
/* Probably not. It is pretty much expected we want to update G_MAIN here I think -
* or we'd want to update *all* active Mains, which we cannot do anyway currently. */
- update_typeinfo(G_MAIN, NULL, NULL, NULL, socktype, true);
+ update_typeinfo(G_MAIN, nullptr, nullptr, nullptr, socktype, true);
socktype->free_self(socktype);
}
@@ -1282,12 +1292,12 @@ void nodeRegisterSocketType(bNodeSocketType *st)
/* XXX pass Main to register function? */
/* Probably not. It is pretty much expected we want to update G_MAIN here I think -
* or we'd want to update *all* active Mains, which we cannot do anyway currently. */
- update_typeinfo(G_MAIN, NULL, NULL, NULL, st, false);
+ update_typeinfo(G_MAIN, nullptr, nullptr, nullptr, st, false);
}
void nodeUnregisterSocketType(bNodeSocketType *st)
{
- BLI_ghash_remove(nodesockettypes_hash, st->idname, NULL, node_free_socket_type);
+ BLI_ghash_remove(nodesockettypes_hash, st->idname, nullptr, node_free_socket_type);
}
bool nodeSocketIsRegistered(bNodeSocket *sock)
@@ -1308,13 +1318,13 @@ struct bNodeSocket *nodeFindSocket(const bNode *node, int in_out, const char *id
return sock;
}
}
- return NULL;
+ return nullptr;
}
/* find unique socket identifier */
static bool unique_identifier_check(void *arg, const char *identifier)
{
- struct ListBase *lb = arg;
+ const ListBase *lb = (const ListBase *)arg;
LISTBASE_FOREACH (bNodeSocket *, sock, lb) {
if (STREQ(sock->identifier, identifier)) {
return true;
@@ -1345,14 +1355,14 @@ static bNodeSocket *make_socket(bNodeTree *ntree,
BLI_uniquename_cb(
unique_identifier_check, lb, "socket", '.', auto_identifier, sizeof(auto_identifier));
- bNodeSocket *sock = MEM_callocN(sizeof(bNodeSocket), "sock");
+ bNodeSocket *sock = (bNodeSocket *)MEM_callocN(sizeof(bNodeSocket), "sock");
sock->in_out = in_out;
BLI_strncpy(sock->identifier, auto_identifier, NODE_MAXSTR);
sock->limit = (in_out == SOCK_IN ? 1 : 0xFFF);
BLI_strncpy(sock->name, name, NODE_MAXSTR);
- sock->storage = NULL;
+ sock->storage = nullptr;
sock->flag |= SOCK_COLLAPSED;
sock->type = SOCK_CUSTOM; /* int type undefined by default */
@@ -1366,17 +1376,18 @@ static void socket_id_user_increment(bNodeSocket *sock)
{
switch ((eNodeSocketDatatype)sock->type) {
case SOCK_OBJECT: {
- bNodeSocketValueObject *default_value = sock->default_value;
+ bNodeSocketValueObject *default_value = (bNodeSocketValueObject *)sock->default_value;
id_us_plus((ID *)default_value->value);
break;
}
case SOCK_IMAGE: {
- bNodeSocketValueImage *default_value = sock->default_value;
+ bNodeSocketValueImage *default_value = (bNodeSocketValueImage *)sock->default_value;
id_us_plus((ID *)default_value->value);
break;
}
case SOCK_COLLECTION: {
- bNodeSocketValueCollection *default_value = sock->default_value;
+ bNodeSocketValueCollection *default_value = (bNodeSocketValueCollection *)
+ sock->default_value;
id_us_plus((ID *)default_value->value);
break;
}
@@ -1398,17 +1409,18 @@ static void socket_id_user_decrement(bNodeSocket *sock)
{
switch ((eNodeSocketDatatype)sock->type) {
case SOCK_OBJECT: {
- bNodeSocketValueObject *default_value = sock->default_value;
+ bNodeSocketValueObject *default_value = (bNodeSocketValueObject *)sock->default_value;
id_us_min(&default_value->value->id);
break;
}
case SOCK_IMAGE: {
- bNodeSocketValueImage *default_value = sock->default_value;
+ bNodeSocketValueImage *default_value = (bNodeSocketValueImage *)sock->default_value;
id_us_min(&default_value->value->id);
break;
}
case SOCK_COLLECTION: {
- bNodeSocketValueCollection *default_value = sock->default_value;
+ bNodeSocketValueCollection *default_value = (bNodeSocketValueCollection *)
+ sock->default_value;
id_us_min(&default_value->value->id);
break;
}
@@ -1439,7 +1451,7 @@ void nodeModifySocketType(
if (sock->default_value) {
socket_id_user_decrement(sock);
MEM_freeN(sock->default_value);
- sock->default_value = NULL;
+ sock->default_value = nullptr;
}
sock->type = type;
@@ -1554,7 +1566,7 @@ const char *nodeStaticSocketType(int type, int subtype)
case SOCK_COLLECTION:
return "NodeSocketCollection";
}
- return NULL;
+ return nullptr;
}
const char *nodeStaticSocketInterfaceType(int type, int subtype)
@@ -1623,7 +1635,7 @@ const char *nodeStaticSocketInterfaceType(int type, int subtype)
case SOCK_COLLECTION:
return "NodeSocketInterfaceCollection";
}
- return NULL;
+ return nullptr;
}
bNodeSocket *nodeAddStaticSocket(bNodeTree *ntree,
@@ -1638,7 +1650,7 @@ bNodeSocket *nodeAddStaticSocket(bNodeTree *ntree,
if (!idname) {
CLOG_ERROR(&LOG, "static node socket type %d undefined", type);
- return NULL;
+ return nullptr;
}
bNodeSocket *sock = nodeAddSocket(ntree, node, in_out, idname, identifier, name);
@@ -1659,7 +1671,7 @@ bNodeSocket *nodeInsertStaticSocket(bNodeTree *ntree,
if (!idname) {
CLOG_ERROR(&LOG, "static node socket type %d undefined", type);
- return NULL;
+ return nullptr;
}
bNodeSocket *sock = nodeInsertSocket(ntree, node, in_out, idname, next_sock, identifier, name);
@@ -1729,23 +1741,23 @@ void nodeRemoveAllSockets(bNodeTree *ntree, bNode *node)
/* finds a node based on its name */
bNode *nodeFindNodebyName(bNodeTree *ntree, const char *name)
{
- return BLI_findstring(&ntree->nodes, name, offsetof(bNode, name));
+ return (bNode *)BLI_findstring(&ntree->nodes, name, offsetof(bNode, name));
}
/* Finds a node based on given socket and returns true on success. */
bool nodeFindNode(bNodeTree *ntree, bNodeSocket *sock, bNode **r_node, int *r_sockindex)
{
- *r_node = NULL;
+ *r_node = nullptr;
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
ListBase *sockets = (sock->in_out == SOCK_IN) ? &node->inputs : &node->outputs;
int index = 0;
LISTBASE_FOREACH (bNodeSocket *, tsock, sockets) {
if (sock == tsock) {
- if (r_node != NULL) {
+ if (r_node != nullptr) {
*r_node = node;
}
- if (r_sockindex != NULL) {
+ if (r_sockindex != nullptr) {
*r_sockindex = index;
}
return true;
@@ -1764,7 +1776,7 @@ bNode *nodeFindRootParent(bNode *node)
if (node->parent) {
return nodeFindRootParent(node->parent);
}
- return node->type == NODE_FRAME ? node : NULL;
+ return node->type == NODE_FRAME ? node : nullptr;
}
/**
@@ -1823,7 +1835,7 @@ static void iter_backwards_ex(const bNodeTree *ntree,
{
LISTBASE_FOREACH (bNodeSocket *, sock, &node_start->inputs) {
bNodeLink *link = sock->link;
- if (link == NULL) {
+ if (link == nullptr) {
continue;
}
if ((link->flag & NODE_LINK_VALID) == 0) {
@@ -1903,7 +1915,7 @@ void nodeUniqueName(bNodeTree *ntree, bNode *node)
bNode *nodeAddNode(const struct bContext *C, bNodeTree *ntree, const char *idname)
{
- bNode *node = MEM_callocN(sizeof(bNode), "new node");
+ bNode *node = (bNode *)MEM_callocN(sizeof(bNode), "new node");
BLI_addtail(&ntree->nodes, node);
BLI_strncpy(node->idname, idname, sizeof(node->idname));
@@ -1916,7 +1928,7 @@ bNode *nodeAddNode(const struct bContext *C, bNodeTree *ntree, const char *idnam
bNode *nodeAddStaticNode(const struct bContext *C, bNodeTree *ntree, int type)
{
- const char *idname = NULL;
+ const char *idname = nullptr;
NODE_TYPES_BEGIN (ntype) {
/* do an extra poll here, because some int types are used
@@ -1930,7 +1942,7 @@ bNode *nodeAddStaticNode(const struct bContext *C, bNodeTree *ntree, int type)
NODE_TYPES_END;
if (!idname) {
CLOG_ERROR(&LOG, "static node type %d undefined", type);
- return NULL;
+ return nullptr;
}
return nodeAddNode(C, ntree, idname);
}
@@ -1953,7 +1965,7 @@ static void node_socket_copy(bNodeSocket *sock_dst, const bNodeSocket *sock_src,
/* XXX some compositor node (e.g. image, render layers) still store
* some persistent buffer data here, need to clear this to avoid dangling pointers.
*/
- sock_dst->cache = NULL;
+ sock_dst->cache = nullptr;
}
/* keep socket listorder identical, for copying links */
@@ -1964,7 +1976,7 @@ bNode *BKE_node_copy_ex(bNodeTree *ntree,
const int flag,
const bool unique_name)
{
- bNode *node_dst = MEM_callocN(sizeof(bNode), "dupli node");
+ bNode *node_dst = (bNode *)MEM_callocN(sizeof(bNode), "dupli node");
bNodeSocket *sock_dst, *sock_src;
bNodeLink *link_dst, *link_src;
@@ -1979,14 +1991,18 @@ bNode *BKE_node_copy_ex(bNodeTree *ntree,
}
BLI_duplicatelist(&node_dst->inputs, &node_src->inputs);
- for (sock_dst = node_dst->inputs.first, sock_src = node_src->inputs.first; sock_dst != NULL;
- sock_dst = sock_dst->next, sock_src = sock_src->next) {
+ for (sock_dst = (bNodeSocket *)node_dst->inputs.first,
+ sock_src = (bNodeSocket *)node_src->inputs.first;
+ sock_dst != nullptr;
+ sock_dst = (bNodeSocket *)sock_dst->next, sock_src = (bNodeSocket *)sock_src->next) {
node_socket_copy(sock_dst, sock_src, flag);
}
BLI_duplicatelist(&node_dst->outputs, &node_src->outputs);
- for (sock_dst = node_dst->outputs.first, sock_src = node_src->outputs.first; sock_dst != NULL;
- sock_dst = sock_dst->next, sock_src = sock_src->next) {
+ for (sock_dst = (bNodeSocket *)node_dst->outputs.first,
+ sock_src = (bNodeSocket *)node_src->outputs.first;
+ sock_dst != nullptr;
+ sock_dst = (bNodeSocket *)sock_dst->next, sock_src = (bNodeSocket *)sock_src->next) {
node_socket_copy(sock_dst, sock_src, flag);
}
@@ -1995,9 +2011,10 @@ bNode *BKE_node_copy_ex(bNodeTree *ntree,
}
BLI_duplicatelist(&node_dst->internal_links, &node_src->internal_links);
- for (link_dst = node_dst->internal_links.first, link_src = node_src->internal_links.first;
- link_dst != NULL;
- link_dst = link_dst->next, link_src = link_src->next) {
+ for (link_dst = (bNodeLink *)node_dst->internal_links.first,
+ link_src = (bNodeLink *)node_src->internal_links.first;
+ link_dst != nullptr;
+ link_dst = (bNodeLink *)link_dst->next, link_src = (bNodeLink *)link_src->next) {
/* This is a bit annoying to do index lookups in a list, but is likely to be faster than
* trying to create a hash-map. At least for usual nodes, which only have so much sockets
* and internal links. */
@@ -2007,8 +2024,8 @@ bNode *BKE_node_copy_ex(bNodeTree *ntree,
BLI_assert(to_sock_index != -1);
link_dst->fromnode = node_dst;
link_dst->tonode = node_dst;
- link_dst->fromsock = BLI_findlink(&node_dst->inputs, from_sock_index);
- link_dst->tosock = BLI_findlink(&node_dst->outputs, to_sock_index);
+ link_dst->fromsock = (bNodeSocket *)BLI_findlink(&node_dst->inputs, from_sock_index);
+ link_dst->tosock = (bNodeSocket *)BLI_findlink(&node_dst->outputs, to_sock_index);
}
if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
@@ -2019,7 +2036,7 @@ bNode *BKE_node_copy_ex(bNodeTree *ntree,
node_src->typeinfo->copyfunc(ntree, node_dst, node_src);
}
- node_dst->new_node = NULL;
+ node_dst->new_node = nullptr;
/* Only call copy function when a copy is made for the main database, not
* for cases like the dependency graph and localization. */
@@ -2042,17 +2059,17 @@ static void node_set_new_pointers(bNode *node_src, bNode *new_node)
/* Store mapping to the node itself. */
node_src->new_node = new_node;
/* Store mapping to inputs. */
- bNodeSocket *new_input_sock = new_node->inputs.first;
- bNodeSocket *input_sock_src = node_src->inputs.first;
- while (new_input_sock != NULL) {
+ bNodeSocket *new_input_sock = (bNodeSocket *)new_node->inputs.first;
+ bNodeSocket *input_sock_src = (bNodeSocket *)node_src->inputs.first;
+ while (new_input_sock != nullptr) {
input_sock_src->new_sock = new_input_sock;
new_input_sock = new_input_sock->next;
input_sock_src = input_sock_src->next;
}
/* Store mapping to outputs. */
- bNodeSocket *new_output_sock = new_node->outputs.first;
- bNodeSocket *output_sock_src = node_src->outputs.first;
- while (new_output_sock != NULL) {
+ bNodeSocket *new_output_sock = (bNodeSocket *)new_node->outputs.first;
+ bNodeSocket *output_sock_src = (bNodeSocket *)node_src->outputs.first;
+ while (new_output_sock != nullptr) {
output_sock_src->new_sock = new_output_sock;
new_output_sock = new_output_sock->next;
output_sock_src = output_sock_src->next;
@@ -2071,9 +2088,9 @@ bNodeTree *ntreeCopyTree_ex_new_pointers(const bNodeTree *ntree,
const bool do_id_user)
{
bNodeTree *new_ntree = ntreeCopyTree_ex(ntree, bmain, do_id_user);
- bNode *new_node = new_ntree->nodes.first;
- bNode *node_src = ntree->nodes.first;
- while (new_node != NULL) {
+ bNode *new_node = (bNode *)new_ntree->nodes.first;
+ bNode *node_src = (bNode *)ntree->nodes.first;
+ while (new_node != nullptr) {
node_set_new_pointers(node_src, new_node);
new_node = new_node->next;
node_src = node_src->next;
@@ -2085,14 +2102,14 @@ bNodeTree *ntreeCopyTree_ex_new_pointers(const bNodeTree *ntree,
bNodeLink *nodeAddLink(
bNodeTree *ntree, bNode *fromnode, bNodeSocket *fromsock, bNode *tonode, bNodeSocket *tosock)
{
- bNodeLink *link = NULL;
+ bNodeLink *link = nullptr;
/* test valid input */
BLI_assert(fromnode);
BLI_assert(tonode);
if (fromsock->in_out == SOCK_OUT && tosock->in_out == SOCK_IN) {
- link = MEM_callocN(sizeof(bNodeLink), "link");
+ link = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "link");
if (ntree) {
BLI_addtail(&ntree->links, link);
}
@@ -2103,7 +2120,7 @@ bNodeLink *nodeAddLink(
}
else if (fromsock->in_out == SOCK_IN && tosock->in_out == SOCK_OUT) {
/* OK but flip */
- link = MEM_callocN(sizeof(bNodeLink), "link");
+ link = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "link");
if (ntree) {
BLI_addtail(&ntree->links, link);
}
@@ -2128,7 +2145,7 @@ void nodeRemLink(bNodeTree *ntree, bNodeLink *link)
}
if (link->tosock) {
- link->tosock->link = NULL;
+ link->tosock->link = nullptr;
}
MEM_freeN(link);
@@ -2139,10 +2156,7 @@ void nodeRemLink(bNodeTree *ntree, bNodeLink *link)
void nodeRemSocketLinks(bNodeTree *ntree, bNodeSocket *sock)
{
- bNodeLink *link, *next;
-
- for (link = ntree->links.first; link; link = next) {
- next = link->next;
+ LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) {
if (link->fromsock == sock || link->tosock == sock) {
nodeRemLink(ntree, link);
}
@@ -2260,7 +2274,7 @@ void nodeDetachNode(struct bNode *node)
nodeToView(node, 0.0f, 0.0f, &locx, &locy);
node->locx = locx;
node->locy = locy;
- node->parent = NULL;
+ node->parent = nullptr;
}
}
@@ -2309,7 +2323,7 @@ void nodePositionRelative(bNode *from_node,
void nodePositionPropagate(bNode *node)
{
LISTBASE_FOREACH (bNodeSocket *, nsock, &node->inputs) {
- if (nsock->link != NULL) {
+ if (nsock->link != nullptr) {
bNodeLink *link = nsock->link;
nodePositionRelative(link->fromnode, link->tonode, link->fromsock, link->tosock);
nodePositionPropagate(link->fromnode);
@@ -2322,12 +2336,12 @@ bNodeTree *ntreeAddTree(Main *bmain, const char *name, const char *idname)
/* trees are created as local trees for compositor, material or texture nodes,
* node groups and other tree types are created as library data.
*/
- const bool is_embedded = (bmain == NULL);
+ const bool is_embedded = (bmain == nullptr);
int flag = 0;
if (is_embedded) {
flag |= LIB_ID_CREATE_NO_MAIN;
}
- bNodeTree *ntree = BKE_libblock_alloc(bmain, ID_NT, name, flag);
+ bNodeTree *ntree = (bNodeTree *)BKE_libblock_alloc(bmain, ID_NT, name, flag);
if (is_embedded) {
ntree->id.flag |= LIB_EMBEDDED_DATA;
}
@@ -2347,7 +2361,7 @@ bNodeTree *ntreeCopyTree_ex(const bNodeTree *ntree, Main *bmain, const bool do_i
{
const int flag = do_id_user ? 0 : LIB_ID_CREATE_NO_USER_REFCOUNT | LIB_ID_CREATE_NO_MAIN;
- bNodeTree *ntree_copy = (bNodeTree *)BKE_id_copy_ex(bmain, (ID *)ntree, NULL, flag);
+ bNodeTree *ntree_copy = (bNodeTree *)BKE_id_copy_ex(bmain, (ID *)ntree, nullptr, flag);
return ntree_copy;
}
bNodeTree *ntreeCopyTree(Main *bmain, const bNodeTree *ntree)
@@ -2371,14 +2385,14 @@ bool BKE_node_preview_used(const bNode *node)
bNodePreview *BKE_node_preview_verify(
bNodeInstanceHash *previews, bNodeInstanceKey key, int xsize, int ysize, bool create)
{
- bNodePreview *preview = BKE_node_instance_hash_lookup(previews, key);
+ bNodePreview *preview = (bNodePreview *)BKE_node_instance_hash_lookup(previews, key);
if (!preview) {
if (create) {
- preview = MEM_callocN(sizeof(bNodePreview), "node preview");
+ preview = (bNodePreview *)MEM_callocN(sizeof(bNodePreview), "node preview");
BKE_node_instance_hash_insert(previews, key, preview);
}
else {
- return NULL;
+ return nullptr;
}
}
@@ -2391,12 +2405,13 @@ bNodePreview *BKE_node_preview_verify(
if (preview->rect) {
if (preview->xsize != xsize || preview->ysize != ysize) {
MEM_freeN(preview->rect);
- preview->rect = NULL;
+ preview->rect = nullptr;
}
}
- if (preview->rect == NULL) {
- preview->rect = MEM_callocN(4 * xsize + xsize * ysize * sizeof(char[4]), "node preview rect");
+ if (preview->rect == nullptr) {
+ preview->rect = (unsigned char *)MEM_callocN(4 * xsize + xsize * ysize * sizeof(char[4]),
+ "node preview rect");
preview->xsize = xsize;
preview->ysize = ysize;
}
@@ -2407,9 +2422,9 @@ bNodePreview *BKE_node_preview_verify(
bNodePreview *BKE_node_preview_copy(bNodePreview *preview)
{
- bNodePreview *new_preview = MEM_dupallocN(preview);
+ bNodePreview *new_preview = (bNodePreview *)MEM_dupallocN(preview);
if (preview->rect) {
- new_preview->rect = MEM_dupallocN(preview->rect);
+ new_preview->rect = (unsigned char *)MEM_dupallocN(preview->rect);
}
return new_preview;
}
@@ -2498,7 +2513,7 @@ void BKE_node_preview_free_tree(bNodeTree *ntree)
if (ntree->previews) {
BKE_node_instance_hash_free(ntree->previews, (bNodeInstanceValueFP)BKE_node_preview_free);
- ntree->previews = NULL;
+ ntree->previews = nullptr;
}
}
@@ -2517,7 +2532,7 @@ void BKE_node_preview_clear_tree(bNodeTree *ntree)
bNodeInstanceHashIterator iter;
NODE_INSTANCE_HASH_ITER (iter, ntree->previews) {
- bNodePreview *preview = BKE_node_instance_hash_iterator_get_value(&iter);
+ bNodePreview *preview = (bNodePreview *)BKE_node_instance_hash_iterator_get_value(&iter);
BKE_node_preview_clear(preview);
}
}
@@ -2547,8 +2562,8 @@ void BKE_node_preview_sync_tree(bNodeTree *to_ntree, bNodeTree *from_ntree)
bNodeInstanceHashIterator iter;
NODE_INSTANCE_HASH_ITER (iter, from_previews) {
bNodeInstanceKey key = BKE_node_instance_hash_iterator_get_key(&iter);
- bNodePreview *from = BKE_node_instance_hash_iterator_get_value(&iter);
- bNodePreview *to = BKE_node_instance_hash_lookup(to_previews, key);
+ bNodePreview *from = (bNodePreview *)BKE_node_instance_hash_iterator_get_value(&iter);
+ bNodePreview *to = (bNodePreview *)BKE_node_instance_hash_lookup(to_previews, key);
if (from && to) {
node_preview_sync(to, from);
@@ -2566,7 +2581,7 @@ void BKE_node_preview_merge_tree(bNodeTree *to_ntree, bNodeTree *from_ntree, boo
/* transfer previews */
to_ntree->previews = from_ntree->previews;
- from_ntree->previews = NULL;
+ from_ntree->previews = nullptr;
/* clean up, in case any to_ntree nodes have been removed */
BKE_node_preview_remove_unused(to_ntree);
@@ -2576,7 +2591,7 @@ void BKE_node_preview_merge_tree(bNodeTree *to_ntree, bNodeTree *from_ntree, boo
bNodeInstanceHashIterator iter;
NODE_INSTANCE_HASH_ITER (iter, from_ntree->previews) {
bNodeInstanceKey key = BKE_node_instance_hash_iterator_get_key(&iter);
- bNodePreview *preview = BKE_node_instance_hash_iterator_get_value(&iter);
+ bNodePreview *preview = (bNodePreview *)BKE_node_instance_hash_iterator_get_value(&iter);
/* replace existing previews */
BKE_node_instance_hash_remove(
@@ -2584,10 +2599,10 @@ void BKE_node_preview_merge_tree(bNodeTree *to_ntree, bNodeTree *from_ntree, boo
BKE_node_instance_hash_insert(to_ntree->previews, key, preview);
}
- /* Note: NULL free function here,
+ /* Note: null free function here,
* because pointers have already been moved over to to_ntree->previews! */
- BKE_node_instance_hash_free(from_ntree->previews, NULL);
- from_ntree->previews = NULL;
+ BKE_node_instance_hash_free(from_ntree->previews, nullptr);
+ from_ntree->previews = nullptr;
}
}
}
@@ -2633,7 +2648,7 @@ void nodeUnlinkNode(bNodeTree *ntree, bNode *node)
lb = &node->inputs;
}
else {
- lb = NULL;
+ lb = nullptr;
}
if (lb) {
@@ -2677,7 +2692,7 @@ static void node_free_node(bNodeTree *ntree, bNode *node)
/* texture node has bad habit of keeping exec data around */
if (ntree->type == NTREE_TEXTURE && ntree->execdata) {
ntreeTexEndExecTree(ntree->execdata);
- ntree->execdata = NULL;
+ ntree->execdata = nullptr;
}
}
@@ -2754,7 +2769,7 @@ void nodeRemoveNode(Main *bmain, bNodeTree *ntree, bNode *node, bool do_id_user)
BLI_snprintf(prefix, sizeof(prefix), "nodes[\"%s\"]", propname_esc);
if (BKE_animdata_fix_paths_remove((ID *)ntree, prefix)) {
- if (bmain != NULL) {
+ if (bmain != nullptr) {
DEG_relations_tag_update(bmain);
}
}
@@ -2826,7 +2841,7 @@ void ntreeFreeLocalTree(bNodeTree *ntree)
void ntreeFreeCache(bNodeTree *ntree)
{
- if (ntree == NULL) {
+ if (ntree == nullptr) {
return;
}
@@ -2925,7 +2940,7 @@ bNodeTree **BKE_ntree_ptr_from_id(ID *id)
case ID_SIM:
return &((Simulation *)id)->nodetree;
default:
- return NULL;
+ return nullptr;
}
}
@@ -2933,10 +2948,10 @@ bNodeTree **BKE_ntree_ptr_from_id(ID *id)
bNodeTree *ntreeFromID(ID *id)
{
bNodeTree **nodetree = BKE_ntree_ptr_from_id(id);
- return (nodetree != NULL) ? *nodetree : NULL;
+ return (nodetree != nullptr) ? *nodetree : nullptr;
}
-/* Finds and returns the datablock that privately owns the given tree, or NULL. */
+/* Finds and returns the datablock that privately owns the given tree, or null. */
ID *BKE_node_tree_find_owner_ID(Main *bmain, struct bNodeTree *ntree)
{
ListBase *lists[] = {&bmain->materials,
@@ -2946,9 +2961,9 @@ ID *BKE_node_tree_find_owner_ID(Main *bmain, struct bNodeTree *ntree)
&bmain->scenes,
&bmain->linestyles,
&bmain->simulations,
- NULL};
+ nullptr};
- for (int i = 0; lists[i] != NULL; i++) {
+ for (int i = 0; lists[i] != nullptr; i++) {
LISTBASE_FOREACH (ID *, id, lists[i]) {
if (ntreeFromID(id) == ntree) {
return id;
@@ -2956,7 +2971,7 @@ ID *BKE_node_tree_find_owner_ID(Main *bmain, struct bNodeTree *ntree)
}
}
- return NULL;
+ return nullptr;
}
bool ntreeNodeExists(const bNodeTree *ntree, const bNode *testnode)
@@ -2999,7 +3014,7 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
* Note: previews are not copied here.
*/
bNodeTree *ltree = (bNodeTree *)BKE_id_copy_ex(
- NULL, &ntree->id, NULL, (LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA));
+ nullptr, &ntree->id, nullptr, (LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA));
ltree->id.tag |= LIB_TAG_LOCALIZED;
@@ -3012,9 +3027,9 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
/* ensures only a single output node is enabled */
ntreeSetOutput(ntree);
- bNode *node_src = ntree->nodes.first;
- bNode *node_local = ltree->nodes.first;
- while (node_src != NULL) {
+ bNode *node_src = (bNode *)ntree->nodes.first;
+ bNode *node_local = (bNode *)ltree->nodes.first;
+ while (node_src != nullptr) {
node_local->original = node_src;
node_src = node_src->next;
node_local = node_local->next;
@@ -3027,7 +3042,7 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
return ltree;
}
- return NULL;
+ return nullptr;
}
/* sync local composite with real tree */
@@ -3066,11 +3081,11 @@ static bNodeSocket *make_socket_interface(bNodeTree *ntree,
bNodeSocketType *stype = nodeSocketTypeFind(idname);
int own_index = ntree->cur_index++;
- if (stype == NULL) {
- return NULL;
+ if (stype == nullptr) {
+ return nullptr;
}
- bNodeSocket *sock = MEM_callocN(sizeof(bNodeSocket), "socket template");
+ bNodeSocket *sock = (bNodeSocket *)MEM_callocN(sizeof(bNodeSocket), "socket template");
BLI_strncpy(sock->idname, stype->idname, sizeof(sock->idname));
node_socket_set_typeinfo(ntree, sock, stype);
sock->in_out = in_out;
@@ -3089,7 +3104,7 @@ static bNodeSocket *make_socket_interface(bNodeTree *ntree,
sock->limit = (in_out == SOCK_IN ? 1 : 0xFFF);
BLI_strncpy(sock->name, name, NODE_MAXSTR);
- sock->storage = NULL;
+ sock->storage = nullptr;
sock->flag |= SOCK_COLLAPSED;
return sock;
@@ -3103,7 +3118,7 @@ bNodeSocket *ntreeFindSocketInterface(bNodeTree *ntree, int in_out, const char *
return iosock;
}
}
- return NULL;
+ return nullptr;
}
bNodeSocket *ntreeAddSocketInterface(bNodeTree *ntree,
@@ -3190,7 +3205,7 @@ static void ntree_interface_identifier_base(bNodeTree *ntree, char *base)
/* check if the identifier is already in use */
static bool ntree_interface_unique_identifier_check(void *UNUSED(data), const char *identifier)
{
- return (RNA_struct_find(identifier) != NULL);
+ return (RNA_struct_find(identifier) != nullptr);
}
/* generates the actual unique identifier and ui name and description */
@@ -3206,7 +3221,8 @@ static void ntree_interface_identifier(bNodeTree *ntree,
* On top of the sanitized id string add a number suffix if necessary to avoid duplicates.
*/
identifier[0] = '\0';
- BLI_uniquename_cb(ntree_interface_unique_identifier_check, NULL, base, '_', identifier, maxlen);
+ BLI_uniquename_cb(
+ ntree_interface_unique_identifier_check, nullptr, base, '_', identifier, maxlen);
sprintf(name, "Node Tree %s Interface", ntree->id.name + 2);
sprintf(description, "Interface properties of node group %s", ntree->id.name + 2);
@@ -3284,7 +3300,7 @@ void ntreeInterfaceTypeFree(bNodeTree *ntree)
{
if (ntree->interface_type) {
RNA_struct_free(&BLENDER_RNA, ntree->interface_type);
- ntree->interface_type = NULL;
+ ntree->interface_type = nullptr;
}
}
@@ -3310,12 +3326,12 @@ bNode *ntreeFindType(const bNodeTree *ntree, int type)
}
}
}
- return NULL;
+ return nullptr;
}
bool ntreeHasType(const bNodeTree *ntree, int type)
{
- return ntreeFindType(ntree, type) != NULL;
+ return ntreeFindType(ntree, type) != nullptr;
}
bool ntreeHasTree(const bNodeTree *ntree, const bNodeTree *lookup)
@@ -3343,7 +3359,7 @@ bNodeLink *nodeFindLink(bNodeTree *ntree, const bNodeSocket *from, const bNodeSo
return link;
}
}
- return NULL;
+ return nullptr;
}
int nodeCountSocketLinks(const bNodeTree *ntree, const bNodeSocket *sock)
@@ -3359,8 +3375,8 @@ int nodeCountSocketLinks(const bNodeTree *ntree, const bNodeSocket *sock)
bNode *nodeGetActive(bNodeTree *ntree)
{
- if (ntree == NULL) {
- return NULL;
+ if (ntree == nullptr) {
+ return nullptr;
}
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
@@ -3368,7 +3384,7 @@ bNode *nodeGetActive(bNodeTree *ntree)
return node;
}
}
- return NULL;
+ return nullptr;
}
static bNode *node_get_active_id_recursive(bNodeInstanceKey active_key,
@@ -3400,7 +3416,7 @@ static bNode *node_get_active_id_recursive(bNodeInstanceKey active_key,
}
}
}
- return NULL;
+ return nullptr;
}
/* two active flags, ID nodes have special flag for buttons display */
@@ -3410,14 +3426,14 @@ bNode *nodeGetActiveID(bNodeTree *ntree, short idtype)
return node_get_active_id_recursive(
ntree->active_viewer_key, NODE_INSTANCE_KEY_BASE, ntree, idtype);
}
- return NULL;
+ return nullptr;
}
bool nodeSetActiveID(bNodeTree *ntree, short idtype, ID *id)
{
bool ok = false;
- if (ntree == NULL) {
+ if (ntree == nullptr) {
return ok;
}
@@ -3435,11 +3451,11 @@ bool nodeSetActiveID(bNodeTree *ntree, short idtype, ID *id)
/* update all groups linked from here
* if active ID node has been found already,
- * just pass NULL so other matching nodes are deactivated.
+ * just pass null so other matching nodes are deactivated.
*/
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == NODE_GROUP) {
- ok |= nodeSetActiveID((bNodeTree *)node->id, idtype, (ok == false ? id : NULL));
+ ok |= nodeSetActiveID((bNodeTree *)node->id, idtype, (ok == false ? id : nullptr));
}
}
@@ -3449,7 +3465,7 @@ bool nodeSetActiveID(bNodeTree *ntree, short idtype, ID *id)
/* two active flags, ID nodes have special flag for buttons display */
void nodeClearActiveID(bNodeTree *ntree, short idtype)
{
- if (ntree == NULL) {
+ if (ntree == nullptr) {
return;
}
@@ -3480,7 +3496,7 @@ void nodeSetSelected(bNode *node, bool select)
void nodeClearActive(bNodeTree *ntree)
{
- if (ntree == NULL) {
+ if (ntree == nullptr) {
return;
}
@@ -3533,7 +3549,7 @@ void nodeSetSocketAvailability(bNodeSocket *sock, bool is_available)
int nodeSocketLinkLimit(const bNodeSocket *sock)
{
bNodeSocketType *stype = sock->typeinfo;
- if (stype != NULL && stype->use_link_limits_of_type) {
+ if (stype != nullptr && stype->use_link_limits_of_type) {
int limit = (sock->in_out == SOCK_IN) ? stype->input_link_limit : stype->output_link_limit;
return limit;
}
@@ -3553,15 +3569,15 @@ int nodeSocketLinkLimit(const bNodeSocket *sock)
* Currently its only used for ID's, but nodes may one day
* reference other pointers which need validation.
*/
-typedef struct bNodeClipboardExtraInfo {
+struct bNodeClipboardExtraInfo {
struct bNodeClipboardExtraInfo *next, *prev;
ID *id;
char id_name[MAX_ID_NAME];
char library_name[FILE_MAX];
-} bNodeClipboardExtraInfo;
+};
#endif /* USE_NODE_CB_VALIDATE */
-typedef struct bNodeClipboard {
+struct bNodeClipboard {
ListBase nodes;
#ifdef USE_NODE_CB_VALIDATE
@@ -3570,9 +3586,9 @@ typedef struct bNodeClipboard {
ListBase links;
int type;
-} bNodeClipboard;
+};
-static bNodeClipboard node_clipboard = {{NULL}};
+static bNodeClipboard node_clipboard = {{nullptr}};
void BKE_node_clipboard_init(const struct bNodeTree *ntree)
{
@@ -3582,12 +3598,12 @@ void BKE_node_clipboard_init(const struct bNodeTree *ntree)
void BKE_node_clipboard_clear(void)
{
LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &node_clipboard.links) {
- nodeRemLink(NULL, link);
+ nodeRemLink(nullptr, link);
}
BLI_listbase_clear(&node_clipboard.links);
LISTBASE_FOREACH_MUTABLE (bNode *, node, &node_clipboard.nodes) {
- node_free_node(NULL, node);
+ node_free_node(nullptr, node);
}
BLI_listbase_clear(&node_clipboard.nodes);
@@ -3609,8 +3625,10 @@ bool BKE_node_clipboard_validate(void)
BLI_assert(BLI_listbase_count(&node_clipboard.nodes) ==
BLI_listbase_count(&node_clipboard.nodes_extra_info));
- for (node = node_clipboard.nodes.first, node_info = node_clipboard.nodes_extra_info.first; node;
- node = node->next, node_info = node_info->next) {
+ for (node = (bNode *)node_clipboard.nodes.first,
+ node_info = (bNodeClipboardExtraInfo *)node_clipboard.nodes_extra_info.first;
+ node;
+ node = (bNode *)node->next, node_info = (bNodeClipboardExtraInfo *)node_info->next) {
/* validate the node against the stored node info */
/* re-assign each loop since we may clear,
@@ -3621,13 +3639,13 @@ bool BKE_node_clipboard_validate(void)
if (node->id) {
/* We want to search into current blend file, so using G_MAIN is valid here too. */
ListBase *lb = which_libbase(G_MAIN, GS(node_info->id_name));
- BLI_assert(lb != NULL);
+ BLI_assert(lb != nullptr);
if (BLI_findindex(lb, node_info->id) == -1) {
- /* may assign NULL */
- node->id = BLI_findstring(lb, node_info->id_name + 2, offsetof(ID, name) + 2);
+ /* May assign null. */
+ node->id = (ID *)BLI_findstring(lb, node_info->id_name + 2, offsetof(ID, name) + 2);
- if (node->id == NULL) {
+ if (node->id == nullptr) {
ok = false;
}
}
@@ -3642,8 +3660,8 @@ void BKE_node_clipboard_add_node(bNode *node)
{
#ifdef USE_NODE_CB_VALIDATE
/* add extra info */
- bNodeClipboardExtraInfo *node_info = MEM_mallocN(sizeof(bNodeClipboardExtraInfo),
- "bNodeClipboardExtraInfo");
+ bNodeClipboardExtraInfo *node_info = (bNodeClipboardExtraInfo *)MEM_mallocN(
+ sizeof(bNodeClipboardExtraInfo), __func__);
node_info->id = node->id;
if (node->id) {
@@ -3746,7 +3764,7 @@ static bool node_instance_hash_key_cmp(const void *a, const void *b)
bNodeInstanceHash *BKE_node_instance_hash_new(const char *info)
{
- bNodeInstanceHash *hash = MEM_mallocN(sizeof(bNodeInstanceHash), info);
+ bNodeInstanceHash *hash = (bNodeInstanceHash *)MEM_mallocN(sizeof(bNodeInstanceHash), info);
hash->ghash = BLI_ghash_new(
node_instance_hash_key, node_instance_hash_key_cmp, "node instance hash ghash");
return hash;
@@ -3754,13 +3772,13 @@ bNodeInstanceHash *BKE_node_instance_hash_new(const char *info)
void BKE_node_instance_hash_free(bNodeInstanceHash *hash, bNodeInstanceValueFP valfreefp)
{
- BLI_ghash_free(hash->ghash, NULL, (GHashValFreeFP)valfreefp);
+ BLI_ghash_free(hash->ghash, nullptr, (GHashValFreeFP)valfreefp);
MEM_freeN(hash);
}
void BKE_node_instance_hash_insert(bNodeInstanceHash *hash, bNodeInstanceKey key, void *value)
{
- bNodeInstanceHashEntry *entry = value;
+ bNodeInstanceHashEntry *entry = (bNodeInstanceHashEntry *)value;
entry->key = key;
entry->tag = 0;
BLI_ghash_insert(hash->ghash, &entry->key, value);
@@ -3775,17 +3793,17 @@ int BKE_node_instance_hash_remove(bNodeInstanceHash *hash,
bNodeInstanceKey key,
bNodeInstanceValueFP valfreefp)
{
- return BLI_ghash_remove(hash->ghash, &key, NULL, (GHashValFreeFP)valfreefp);
+ return BLI_ghash_remove(hash->ghash, &key, nullptr, (GHashValFreeFP)valfreefp);
}
void BKE_node_instance_hash_clear(bNodeInstanceHash *hash, bNodeInstanceValueFP valfreefp)
{
- BLI_ghash_clear(hash->ghash, NULL, (GHashValFreeFP)valfreefp);
+ BLI_ghash_clear(hash->ghash, nullptr, (GHashValFreeFP)valfreefp);
}
void *BKE_node_instance_hash_pop(bNodeInstanceHash *hash, bNodeInstanceKey key)
{
- return BLI_ghash_popkey(hash->ghash, &key, NULL);
+ return BLI_ghash_popkey(hash->ghash, &key, nullptr);
}
int BKE_node_instance_hash_haskey(bNodeInstanceHash *hash, bNodeInstanceKey key)
@@ -3803,7 +3821,8 @@ void BKE_node_instance_hash_clear_tags(bNodeInstanceHash *hash)
bNodeInstanceHashIterator iter;
NODE_INSTANCE_HASH_ITER (iter, hash) {
- bNodeInstanceHashEntry *value = BKE_node_instance_hash_iterator_get_value(&iter);
+ bNodeInstanceHashEntry *value = (bNodeInstanceHashEntry *)
+ BKE_node_instance_hash_iterator_get_value(&iter);
value->tag = 0;
}
@@ -3811,13 +3830,14 @@ void BKE_node_instance_hash_clear_tags(bNodeInstanceHash *hash)
void BKE_node_instance_hash_tag(bNodeInstanceHash *UNUSED(hash), void *value)
{
- bNodeInstanceHashEntry *entry = value;
+ bNodeInstanceHashEntry *entry = (bNodeInstanceHashEntry *)value;
entry->tag = 1;
}
bool BKE_node_instance_hash_tag_key(bNodeInstanceHash *hash, bNodeInstanceKey key)
{
- bNodeInstanceHashEntry *entry = BKE_node_instance_hash_lookup(hash, key);
+ bNodeInstanceHashEntry *entry = (bNodeInstanceHashEntry *)BKE_node_instance_hash_lookup(hash,
+ key);
if (entry) {
entry->tag = 1;
@@ -3833,13 +3853,14 @@ void BKE_node_instance_hash_remove_untagged(bNodeInstanceHash *hash,
/* NOTE: Hash must not be mutated during iterating!
* Store tagged entries in a separate list and remove items afterward.
*/
- bNodeInstanceKey *untagged = MEM_mallocN(sizeof(bNodeInstanceKey) *
- BKE_node_instance_hash_size(hash),
- "temporary node instance key list");
+ bNodeInstanceKey *untagged = (bNodeInstanceKey *)MEM_mallocN(
+ sizeof(bNodeInstanceKey) * BKE_node_instance_hash_size(hash),
+ "temporary node instance key list");
bNodeInstanceHashIterator iter;
int num_untagged = 0;
NODE_INSTANCE_HASH_ITER (iter, hash) {
- bNodeInstanceHashEntry *value = BKE_node_instance_hash_iterator_get_value(&iter);
+ bNodeInstanceHashEntry *value = (bNodeInstanceHashEntry *)
+ BKE_node_instance_hash_iterator_get_value(&iter);
if (!value->tag) {
untagged[num_untagged++] = BKE_node_instance_hash_iterator_get_key(&iter);
@@ -3903,12 +3924,12 @@ void ntreeGetDependencyList(struct bNodeTree *ntree, struct bNode ***deplist, in
(*totnodes)++;
}
if (*totnodes == 0) {
- *deplist = NULL;
+ *deplist = nullptr;
return;
}
bNode **nsort;
- nsort = *deplist = MEM_callocN((*totnodes) * sizeof(bNode *), "sorted node array");
+ nsort = *deplist = (bNode **)MEM_callocN((*totnodes) * sizeof(bNode *), "sorted node array");
/* recursive check */
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
@@ -3929,7 +3950,7 @@ static void ntree_update_node_level(bNodeTree *ntree)
/* recursive check */
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->done == 0) {
- node->level = node_get_deplist_recurs(ntree, node, NULL);
+ node->level = node_get_deplist_recurs(ntree, node, nullptr);
}
}
}
@@ -3957,7 +3978,7 @@ static void ntree_update_link_pointers(bNodeTree *ntree)
/* first clear data */
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
- sock->link = NULL;
+ sock->link = nullptr;
}
}
@@ -3996,7 +4017,7 @@ void ntreeUpdateAllNew(Main *main)
}
}
- ntreeUpdateTree(NULL, ntree);
+ ntreeUpdateTree(nullptr, ntree);
}
}
FOREACH_NODETREE_END;
@@ -4004,7 +4025,7 @@ void ntreeUpdateAllNew(Main *main)
void ntreeUpdateAllUsers(Main *main, ID *id)
{
- if (id == NULL) {
+ if (id == nullptr) {
return;
}
@@ -4023,7 +4044,7 @@ void ntreeUpdateAllUsers(Main *main, ID *id)
}
if (need_update) {
- ntreeUpdateTree(NULL, ntree);
+ ntreeUpdateTree(nullptr, ntree);
}
}
FOREACH_NODETREE_END;
@@ -4133,7 +4154,7 @@ bool nodeUpdateID(bNodeTree *ntree, ID *id)
{
bool changed = false;
- if (ELEM(NULL, id, ntree)) {
+ if (ELEM(nullptr, id, ntree)) {
return changed;
}
@@ -4237,7 +4258,7 @@ void node_type_base(bNodeType *ntype, int type, const char *name, short nclass,
case ID: \
BLI_strncpy(ntype->idname, #Category #StructName, sizeof(ntype->idname)); \
ntype->rna_ext.srna = RNA_struct_find(#Category #StructName); \
- BLI_assert(ntype->rna_ext.srna != NULL); \
+ BLI_assert(ntype->rna_ext.srna != nullptr); \
RNA_struct_blender_type_set(ntype->rna_ext.srna, ntype); \
break;
@@ -4271,15 +4292,16 @@ void node_type_base_custom(
node_type_base_defaults(ntype);
}
+struct SocketTemplateIdentifierCallbackData {
+ bNodeSocketTemplate *list;
+ bNodeSocketTemplate *ntemp;
+};
+
static bool unique_socket_template_identifier_check(void *arg, const char *name)
{
- bNodeSocketTemplate *ntemp;
- struct {
- bNodeSocketTemplate *list;
- bNodeSocketTemplate *ntemp;
- } *data = arg;
+ SocketTemplateIdentifierCallbackData *data = (SocketTemplateIdentifierCallbackData *)arg;
- for (ntemp = data->list; ntemp->type >= 0; ntemp++) {
+ for (bNodeSocketTemplate *ntemp = data->list; ntemp->type >= 0; ntemp++) {
if (ntemp != data->ntemp) {
if (STREQ(ntemp->identifier, name)) {
return true;
@@ -4295,10 +4317,7 @@ static void unique_socket_template_identifier(bNodeSocketTemplate *list,
const char defname[],
char delim)
{
- struct {
- bNodeSocketTemplate *list;
- bNodeSocketTemplate *ntemp;
- } data;
+ SocketTemplateIdentifierCallbackData data;
data.list = list;
data.ntemp = ntemp;
@@ -4448,7 +4467,7 @@ static bool node_undefined_poll(bNodeType *UNUSED(ntype), bNodeTree *UNUSED(node
}
/* register fallback types used for undefined tree, nodes, sockets */
-static void register_undefined_types(void)
+static void register_undefined_types()
{
/* Note: these types are not registered in the type hashes,
* they are just used as placeholders in case the actual types are not registered.
@@ -4473,7 +4492,7 @@ static void register_undefined_types(void)
NodeSocketTypeUndefined.output_link_limit = 0xFFF;
}
-static void registerCompositNodes(void)
+static void registerCompositNodes()
{
register_node_type_cmp_group();
@@ -4577,7 +4596,7 @@ static void registerCompositNodes(void)
register_node_type_cmp_cornerpin();
}
-static void registerShaderNodes(void)
+static void registerShaderNodes()
{
register_node_type_sh_group();
@@ -4674,7 +4693,7 @@ static void registerShaderNodes(void)
register_node_type_sh_tex_white_noise();
}
-static void registerTextureNodes(void)
+static void registerTextureNodes()
{
register_node_type_tex_group();
@@ -4724,7 +4743,7 @@ static void registerTextureNodes(void)
register_node_type_tex_proc_distnoise();
}
-static void registerGeometryNodes(void)
+static void registerGeometryNodes()
{
register_node_type_geo_group();
@@ -4753,7 +4772,7 @@ static void registerGeometryNodes(void)
register_node_type_geo_points_to_volume();
}
-static void registerFunctionNodes(void)
+static void registerFunctionNodes()
{
register_node_type_fn_boolean_math();
register_node_type_fn_float_compare();
@@ -4802,8 +4821,8 @@ void BKE_node_system_exit(void)
}
NODE_TYPES_END;
- BLI_ghash_free(nodetypes_hash, NULL, node_free_type);
- nodetypes_hash = NULL;
+ BLI_ghash_free(nodetypes_hash, nullptr, node_free_type);
+ nodetypes_hash = nullptr;
}
if (nodesockettypes_hash) {
@@ -4817,8 +4836,8 @@ void BKE_node_system_exit(void)
}
NODE_SOCKET_TYPES_END;
- BLI_ghash_free(nodesockettypes_hash, NULL, node_free_socket_type);
- nodesockettypes_hash = NULL;
+ BLI_ghash_free(nodesockettypes_hash, nullptr, node_free_socket_type);
+ nodesockettypes_hash = nullptr;
}
if (nodetreetypes_hash) {
@@ -4829,8 +4848,8 @@ void BKE_node_system_exit(void)
}
NODE_TREE_TYPES_END;
- BLI_ghash_free(nodetreetypes_hash, NULL, ntree_free_type);
- nodetreetypes_hash = NULL;
+ BLI_ghash_free(nodetreetypes_hash, nullptr, ntree_free_type);
+ nodetreetypes_hash = nullptr;
}
}
@@ -4839,58 +4858,58 @@ void BKE_node_system_exit(void)
void BKE_node_tree_iter_init(struct NodeTreeIterStore *ntreeiter, struct Main *bmain)
{
- ntreeiter->ngroup = bmain->nodetrees.first;
- ntreeiter->scene = bmain->scenes.first;
- ntreeiter->mat = bmain->materials.first;
- ntreeiter->tex = bmain->textures.first;
- ntreeiter->light = bmain->lights.first;
- ntreeiter->world = bmain->worlds.first;
- ntreeiter->linestyle = bmain->linestyles.first;
- ntreeiter->simulation = bmain->simulations.first;
+ ntreeiter->ngroup = (bNodeTree *)bmain->nodetrees.first;
+ ntreeiter->scene = (Scene *)bmain->scenes.first;
+ ntreeiter->mat = (Material *)bmain->materials.first;
+ ntreeiter->tex = (Tex *)bmain->textures.first;
+ ntreeiter->light = (Light *)bmain->lights.first;
+ ntreeiter->world = (World *)bmain->worlds.first;
+ ntreeiter->linestyle = (FreestyleLineStyle *)bmain->linestyles.first;
+ ntreeiter->simulation = (Simulation *)bmain->simulations.first;
}
bool BKE_node_tree_iter_step(struct NodeTreeIterStore *ntreeiter,
bNodeTree **r_nodetree,
struct ID **r_id)
{
if (ntreeiter->ngroup) {
- *r_nodetree = ntreeiter->ngroup;
+ *r_nodetree = (bNodeTree *)ntreeiter->ngroup;
*r_id = (ID *)ntreeiter->ngroup;
- ntreeiter->ngroup = ntreeiter->ngroup->id.next;
+ ntreeiter->ngroup = (bNodeTree *)ntreeiter->ngroup->id.next;
}
else if (ntreeiter->scene) {
- *r_nodetree = ntreeiter->scene->nodetree;
+ *r_nodetree = (bNodeTree *)ntreeiter->scene->nodetree;
*r_id = (ID *)ntreeiter->scene;
- ntreeiter->scene = ntreeiter->scene->id.next;
+ ntreeiter->scene = (Scene *)ntreeiter->scene->id.next;
}
else if (ntreeiter->mat) {
- *r_nodetree = ntreeiter->mat->nodetree;
+ *r_nodetree = (bNodeTree *)ntreeiter->mat->nodetree;
*r_id = (ID *)ntreeiter->mat;
- ntreeiter->mat = ntreeiter->mat->id.next;
+ ntreeiter->mat = (Material *)ntreeiter->mat->id.next;
}
else if (ntreeiter->tex) {
- *r_nodetree = ntreeiter->tex->nodetree;
+ *r_nodetree = (bNodeTree *)ntreeiter->tex->nodetree;
*r_id = (ID *)ntreeiter->tex;
- ntreeiter->tex = ntreeiter->tex->id.next;
+ ntreeiter->tex = (Tex *)ntreeiter->tex->id.next;
}
else if (ntreeiter->light) {
- *r_nodetree = ntreeiter->light->nodetree;
+ *r_nodetree = (bNodeTree *)ntreeiter->light->nodetree;
*r_id = (ID *)ntreeiter->light;
- ntreeiter->light = ntreeiter->light->id.next;
+ ntreeiter->light = (Light *)ntreeiter->light->id.next;
}
else if (ntreeiter->world) {
- *r_nodetree = ntreeiter->world->nodetree;
+ *r_nodetree = (bNodeTree *)ntreeiter->world->nodetree;
*r_id = (ID *)ntreeiter->world;
- ntreeiter->world = ntreeiter->world->id.next;
+ ntreeiter->world = (World *)ntreeiter->world->id.next;
}
else if (ntreeiter->linestyle) {
- *r_nodetree = ntreeiter->linestyle->nodetree;
+ *r_nodetree = (bNodeTree *)ntreeiter->linestyle->nodetree;
*r_id = (ID *)ntreeiter->linestyle;
- ntreeiter->linestyle = ntreeiter->linestyle->id.next;
+ ntreeiter->linestyle = (FreestyleLineStyle *)ntreeiter->linestyle->id.next;
}
else if (ntreeiter->simulation) {
- *r_nodetree = ntreeiter->simulation->nodetree;
+ *r_nodetree = (bNodeTree *)ntreeiter->simulation->nodetree;
*r_id = (ID *)ntreeiter->simulation;
- ntreeiter->simulation = ntreeiter->simulation->id.next;
+ ntreeiter->simulation = (Simulation *)ntreeiter->simulation->id.next;
}
else {
return false;
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 122eab1c4cf..0ce5240b17d 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -3457,6 +3457,10 @@ Depsgraph *BKE_scene_get_depsgraph(const Scene *scene, const ViewLayer *view_lay
{
BLI_assert(BKE_scene_has_view_layer(scene, view_layer));
+ if (scene->depsgraph_hash == NULL) {
+ return NULL;
+ }
+
DepsgraphKey key;
key.view_layer = view_layer;
return BLI_ghash_lookup(scene->depsgraph_hash, &key);
diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c
index b7b5b6997c2..5bffcd4d9e7 100644
--- a/source/blender/blenkernel/intern/studiolight.c
+++ b/source/blender/blenkernel/intern/studiolight.c
@@ -1065,7 +1065,7 @@ static void studiolight_lights_eval(StudioLight *sl, float color[3], const float
copy_v3_v3(spec_light, sl->light_ambient);
reflect_v3_v3v3(R, I, N);
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < STUDIOLIGHT_MAX_LIGHT; i++) {
SolidLight *light = &sl->light[i];
if (light->flag) {
/* Diffuse lighting */
diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc
index d2722adc831..77cfb3ffea5 100644
--- a/source/blender/blenkernel/intern/volume.cc
+++ b/source/blender/blenkernel/intern/volume.cc
@@ -128,7 +128,7 @@ static struct VolumeFileCache {
std::lock_guard<std::mutex> lock(mutex);
return simplified_grids.lookup_or_add_cb(simplify_level, [&]() {
const float resolution_factor = 1.0f / (1 << simplify_level);
- const VolumeGridType grid_type = BKE_volume_grid_type_openvdb(grid);
+ const VolumeGridType grid_type = BKE_volume_grid_type_openvdb(*grid);
return BKE_volume_grid_create_with_changed_resolution(grid_type, *grid, resolution_factor);
});
}
@@ -1237,39 +1237,39 @@ const char *BKE_volume_grid_name(const VolumeGrid *volume_grid)
}
#ifdef WITH_OPENVDB
-VolumeGridType BKE_volume_grid_type_openvdb(const openvdb::GridBase::Ptr &grid)
+VolumeGridType BKE_volume_grid_type_openvdb(const openvdb::GridBase &grid)
{
- if (grid->isType<openvdb::FloatGrid>()) {
+ if (grid.isType<openvdb::FloatGrid>()) {
return VOLUME_GRID_FLOAT;
}
- if (grid->isType<openvdb::Vec3fGrid>()) {
+ if (grid.isType<openvdb::Vec3fGrid>()) {
return VOLUME_GRID_VECTOR_FLOAT;
}
- if (grid->isType<openvdb::BoolGrid>()) {
+ if (grid.isType<openvdb::BoolGrid>()) {
return VOLUME_GRID_BOOLEAN;
}
- if (grid->isType<openvdb::DoubleGrid>()) {
+ if (grid.isType<openvdb::DoubleGrid>()) {
return VOLUME_GRID_DOUBLE;
}
- if (grid->isType<openvdb::Int32Grid>()) {
+ if (grid.isType<openvdb::Int32Grid>()) {
return VOLUME_GRID_INT;
}
- if (grid->isType<openvdb::Int64Grid>()) {
+ if (grid.isType<openvdb::Int64Grid>()) {
return VOLUME_GRID_INT64;
}
- if (grid->isType<openvdb::Vec3IGrid>()) {
+ if (grid.isType<openvdb::Vec3IGrid>()) {
return VOLUME_GRID_VECTOR_INT;
}
- if (grid->isType<openvdb::Vec3dGrid>()) {
+ if (grid.isType<openvdb::Vec3dGrid>()) {
return VOLUME_GRID_VECTOR_DOUBLE;
}
- if (grid->isType<openvdb::StringGrid>()) {
+ if (grid.isType<openvdb::StringGrid>()) {
return VOLUME_GRID_STRING;
}
- if (grid->isType<openvdb::MaskGrid>()) {
+ if (grid.isType<openvdb::MaskGrid>()) {
return VOLUME_GRID_MASK;
}
- if (grid->isType<openvdb::points::PointDataGrid>()) {
+ if (grid.isType<openvdb::points::PointDataGrid>()) {
return VOLUME_GRID_POINTS;
}
return VOLUME_GRID_UNKNOWN;
@@ -1280,7 +1280,7 @@ VolumeGridType BKE_volume_grid_type(const VolumeGrid *volume_grid)
{
#ifdef WITH_OPENVDB
const openvdb::GridBase::Ptr grid = volume_grid->grid();
- return BKE_volume_grid_type_openvdb(grid);
+ return BKE_volume_grid_type_openvdb(*grid);
#else
UNUSED_VARS(volume_grid);
#endif
diff --git a/source/blender/blenlib/BLI_args.h b/source/blender/blenlib/BLI_args.h
index b12b7ff5d1e..5d9c168a9bd 100644
--- a/source/blender/blenlib/BLI_args.h
+++ b/source/blender/blenlib/BLI_args.h
@@ -72,6 +72,8 @@ void BLI_args_parse(struct bArgs *ba, int pass, BA_ArgCallback default_cb, void
void BLI_args_print_arg_doc(struct bArgs *ba, const char *arg);
void BLI_args_print_other_doc(struct bArgs *ba);
+bool BLI_args_has_other_doc(const struct bArgs *ba);
+
void BLI_args_print(struct bArgs *ba);
#ifdef __cplusplus
diff --git a/source/blender/blenlib/intern/BLI_args.c b/source/blender/blenlib/intern/BLI_args.c
index 3d4521a3304..07ab4f407f2 100644
--- a/source/blender/blenlib/intern/BLI_args.c
+++ b/source/blender/blenlib/intern/BLI_args.c
@@ -275,6 +275,16 @@ void BLI_args_print_other_doc(struct bArgs *ba)
}
}
+bool BLI_args_has_other_doc(const struct bArgs *ba)
+{
+ for (const bArgDoc *d = ba->docs.first; d; d = d->next) {
+ if (d->done == 0) {
+ return true;
+ }
+ }
+ return false;
+}
+
void BLI_args_parse(struct bArgs *ba, int pass, BA_ArgCallback default_cb, void *default_data)
{
BLI_assert((pass != 0) && (pass >= -1));
diff --git a/source/blender/compositor/COM_compositor.h b/source/blender/compositor/COM_compositor.h
index 79c1ebcfe9f..b308241ff34 100644
--- a/source/blender/compositor/COM_compositor.h
+++ b/source/blender/compositor/COM_compositor.h
@@ -298,7 +298,7 @@ extern "C" {
/**
* \brief The main method that is used to execute the compositor tree.
- * It can be executed during editing (blenkernel/node.c) or rendering
+ * It can be executed during editing (blenkernel/node.cc) or rendering
* (renderer/pipeline.c)
*
* \param rd: [struct RenderData]
diff --git a/source/blender/draw/engines/overlay/overlay_wireframe.c b/source/blender/draw/engines/overlay/overlay_wireframe.c
index 617dda56421..7ba5fb3a426 100644
--- a/source/blender/draw/engines/overlay/overlay_wireframe.c
+++ b/source/blender/draw/engines/overlay/overlay_wireframe.c
@@ -20,6 +20,7 @@
* \ingroup draw_engine
*/
+#include "DNA_collection_types.h"
#include "DNA_mesh_types.h"
#include "DNA_particle_types.h"
#include "DNA_view3d_types.h"
@@ -141,7 +142,12 @@ static void wireframe_hair_cache_populate(OVERLAY_Data *vedata, Object *ob, Part
float dupli_mat[4][4];
if ((dupli_parent != NULL) && (dupli_object != NULL)) {
if (dupli_object->type & OB_DUPLICOLLECTION) {
- copy_m4_m4(dupli_mat, dupli_parent->obmat);
+ unit_m4(dupli_mat);
+ Collection *collection = dupli_parent->instance_collection;
+ if (collection != NULL) {
+ sub_v3_v3(dupli_mat[3], collection->instance_offset);
+ }
+ mul_m4_m4m4(dupli_mat, dupli_parent->obmat, dupli_mat);
}
else {
copy_m4_m4(dupli_mat, dupli_object->ob->obmat);
diff --git a/source/blender/draw/intern/draw_hair.c b/source/blender/draw/intern/draw_hair.c
index cc0aa09ed97..86f1b0e0ebb 100644
--- a/source/blender/draw/intern/draw_hair.c
+++ b/source/blender/draw/intern/draw_hair.c
@@ -28,6 +28,7 @@
#include "BLI_string_utils.h"
#include "BLI_utildefines.h"
+#include "DNA_collection_types.h"
#include "DNA_customdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_particle_types.h"
@@ -195,7 +196,12 @@ void DRW_hair_duplimat_get(Object *object,
if (psys) {
if ((dupli_parent != NULL) && (dupli_object != NULL)) {
if (dupli_object->type & OB_DUPLICOLLECTION) {
- copy_m4_m4(dupli_mat, dupli_parent->obmat);
+ unit_m4(dupli_mat);
+ Collection *collection = dupli_parent->instance_collection;
+ if (collection != NULL) {
+ sub_v3_v3(dupli_mat[3], collection->instance_offset);
+ }
+ mul_m4_m4m4(dupli_mat, dupli_parent->obmat, dupli_mat);
}
else {
copy_m4_m4(dupli_mat, dupli_object->ob->obmat);
diff --git a/source/blender/editors/interface/interface_region_search.c b/source/blender/editors/interface/interface_region_search.c
index 7f51eb90fe8..d5a9a94b8ae 100644
--- a/source/blender/editors/interface/interface_region_search.c
+++ b/source/blender/editors/interface/interface_region_search.c
@@ -463,8 +463,11 @@ static void ui_searchbox_update_fn(bContext *C,
const char *str,
uiSearchItems *items)
{
- wmWindow *win = CTX_wm_window(C);
- WM_tooltip_clear(C, win);
+ /* While the button is in text editing mode (searchbox open), remove tooltips on every update. */
+ if (search_but->but.editstr) {
+ wmWindow *win = CTX_wm_window(C);
+ WM_tooltip_clear(C, win);
+ }
search_but->items_update_fn(C, search_but->arg, str, items);
}
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c
index 381bf317bee..a761701f60b 100644
--- a/source/blender/editors/physics/dynamicpaint_ops.c
+++ b/source/blender/editors/physics/dynamicpaint_ops.c
@@ -233,7 +233,7 @@ static int output_toggle_exec(bContext *C, wmOperator *op)
/* if type is already enabled, toggle it off */
if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
- int exists = dynamicPaint_outputLayerExists(surface, ob, output);
+ bool exists = dynamicPaint_outputLayerExists(surface, ob, output);
const char *name;
if (output == 0) {
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 4bba3ef605e..be54df1ce9e 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -2165,6 +2165,7 @@ static int smart_project_exec(bContext *C, wmOperator *op)
scene->toolsettings->uvcalc_margin = island_margin;
/* Depsgraph refresh functions are called here. */
+ const bool correct_aspect = RNA_boolean_get(op->ptr, "correct_aspect");
ED_uvedit_pack_islands_multi(scene,
objects_changed,
object_changed_len,
@@ -2173,7 +2174,7 @@ static int smart_project_exec(bContext *C, wmOperator *op)
/* We could make this optional. */
.rotate_align_axis = 1,
.only_selected_faces = true,
- .correct_aspect = true,
+ .correct_aspect = correct_aspect,
.use_seams = true,
});
diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
index f45ff77cf41..7772a30c5f4 100644
--- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
+++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
@@ -500,6 +500,11 @@ void FRS_composite_result(Render *re, ViewLayer *view_layer, Render *freestyle_r
int x, y, rectx, recty;
if (freestyle_render == nullptr || freestyle_render->result == nullptr) {
+ if (view_layer->freestyle_config.flags & FREESTYLE_AS_RENDER_PASS) {
+ // Create a blank render pass output.
+ RE_create_render_pass(
+ re->result, RE_PASSNAME_FREESTYLE, 4, "RGBA", view_layer->name, re->viewname);
+ }
return;
}
@@ -677,8 +682,8 @@ void FRS_do_stroke_rendering(Render *re, ViewLayer *view_layer)
g_freestyle.scene = nullptr;
// composite result
+ FRS_composite_result(re, view_layer, freestyle_render);
if (freestyle_render) {
- FRS_composite_result(re, view_layer, freestyle_render);
RE_FreeRender(freestyle_render);
}
}
diff --git a/source/blender/gpu/GPU_platform.h b/source/blender/gpu/GPU_platform.h
index bb7e1d58041..c457b829bf7 100644
--- a/source/blender/gpu/GPU_platform.h
+++ b/source/blender/gpu/GPU_platform.h
@@ -34,6 +34,7 @@ typedef enum eGPUDeviceType {
GPU_DEVICE_ATI = (1 << 1),
GPU_DEVICE_INTEL = (1 << 2),
GPU_DEVICE_INTEL_UHD = (1 << 3),
+ GPU_DEVICE_APPLE = (1 << 3),
GPU_DEVICE_SOFTWARE = (1 << 4),
GPU_DEVICE_UNKNOWN = (1 << 5),
GPU_DEVICE_ANY = (0xff),
diff --git a/source/blender/gpu/opengl/gl_backend.cc b/source/blender/gpu/opengl/gl_backend.cc
index c49158176c6..573ae654af4 100644
--- a/source/blender/gpu/opengl/gl_backend.cc
+++ b/source/blender/gpu/opengl/gl_backend.cc
@@ -96,6 +96,11 @@ void GLBackend::platform_init()
GPG.device = GPU_DEVICE_SOFTWARE;
GPG.driver = GPU_DRIVER_SOFTWARE;
}
+ else if (strstr(vendor, "Apple")) {
+ /* Apple Silicon. */
+ GPG.device = GPU_DEVICE_APPLE;
+ GPG.driver = GPU_DRIVER_OFFICIAL;
+ }
else if (strstr(renderer, "Apple Software Renderer")) {
GPG.device = GPU_DEVICE_SOFTWARE;
GPG.driver = GPU_DRIVER_SOFTWARE;
diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c
index 3126f3e11f4..0c2860c05e7 100644
--- a/source/blender/makesrna/intern/rna_render.c
+++ b/source/blender/makesrna/intern/rna_render.c
@@ -848,6 +848,14 @@ static void rna_def_render_engine(BlenderRNA *brna)
RNA_def_property_ui_text(
prop, "Use Eevee Viewport", "Uses Eevee for viewport shading in LookDev shading mode");
+ prop = RNA_def_property(srna, "bl_use_custom_freestyle", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "type->flag", RE_USE_CUSTOM_FREESTYLE);
+ RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
+ RNA_def_property_ui_text(
+ prop,
+ "Use Custom Freestyle",
+ "Handles freestyle rendering on its own, instead of delegating it to EEVEE");
+
prop = RNA_def_property(srna, "bl_use_gpu_context", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "type->flag", RE_USE_GPU_CONTEXT);
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
diff --git a/source/blender/nodes/texture/node_texture_util.c b/source/blender/nodes/texture/node_texture_util.c
index 96a0be6babc..2091a8bf10e 100644
--- a/source/blender/nodes/texture/node_texture_util.c
+++ b/source/blender/nodes/texture/node_texture_util.c
@@ -146,7 +146,7 @@ void tex_output(bNode *node,
}
if (!out->data) {
- /* Freed in tex_end_exec (node.c) */
+ /* Freed in tex_end_exec (node.cc) */
dg = out->data = MEM_mallocN(sizeof(TexDelegate), "tex delegate");
}
else {
diff --git a/source/blender/render/RE_engine.h b/source/blender/render/RE_engine.h
index 1af40ac760b..c31a41f66d5 100644
--- a/source/blender/render/RE_engine.h
+++ b/source/blender/render/RE_engine.h
@@ -64,6 +64,7 @@ extern "C" {
#define RE_USE_SPHERICAL_STEREO 128
#define RE_USE_STEREO_VIEWPORT 256
#define RE_USE_GPU_CONTEXT 512
+#define RE_USE_CUSTOM_FREESTYLE 1024
/* RenderEngine.flag */
#define RE_ENGINE_ANIMATION 1
diff --git a/source/blender/render/intern/pipeline.c b/source/blender/render/intern/pipeline.c
index 320f8b8ed03..8567835f55c 100644
--- a/source/blender/render/intern/pipeline.c
+++ b/source/blender/render/intern/pipeline.c
@@ -2007,13 +2007,38 @@ void RE_RenderFrame(Render *re,
G.is_rendering = false;
}
+static void change_renderdata_engine(Render *re, const char *new_engine)
+{
+ if (!STREQ(re->r.engine, new_engine)) {
+ if (re->engine) {
+ RE_engine_free(re->engine);
+ re->engine = NULL;
+ }
+ BLI_strncpy(re->r.engine, new_engine, sizeof(re->r.engine));
+ }
+}
+
#ifdef WITH_FREESTYLE
+static bool use_eevee_for_freestyle_render(Render *re)
+{
+ RenderEngineType *type = RE_engines_find(re->r.engine);
+ return !(type->flag & RE_USE_CUSTOM_FREESTYLE);
+}
+
void RE_RenderFreestyleStrokes(Render *re, Main *bmain, Scene *scene, int render)
{
re->result_ok = 0;
if (render_init_from_main(re, &scene->r, bmain, scene, NULL, NULL, 0, 0)) {
if (render) {
+ char scene_engine[32];
+ BLI_strncpy(scene_engine, re->r.engine, sizeof(scene_engine));
+ if (use_eevee_for_freestyle_render(re)) {
+ change_renderdata_engine(re, RE_engine_id_BLENDER_EEVEE);
+ }
+
do_render_3d(re);
+
+ change_renderdata_engine(re, scene_engine);
}
}
re->result_ok = 1;
diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c
index a9677f3b3d4..b75a6a624d5 100644
--- a/source/creator/creator_args.c
+++ b/source/creator/creator_args.c
@@ -496,7 +496,7 @@ static const char arg_handle_print_help_doc[] =
"Print this help text and exit.";
static const char arg_handle_print_help_doc_win32[] =
"\n\t"
- "Print this help text and exit (windows only).";
+ "Print this help text and exit (Windows only).";
static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), void *data)
{
bArgs *ba = (bArgs *)data;
@@ -586,8 +586,12 @@ static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), vo
BLI_args_print_arg_doc(ba, "--debug-depsgraph-no-threads");
BLI_args_print_arg_doc(ba, "--debug-depsgraph-time");
BLI_args_print_arg_doc(ba, "--debug-depsgraph-pretty");
+ BLI_args_print_arg_doc(ba, "--debug-depsgraph-uuid");
+ BLI_args_print_arg_doc(ba, "--debug-ghost");
BLI_args_print_arg_doc(ba, "--debug-gpu");
BLI_args_print_arg_doc(ba, "--debug-gpu-force-workarounds");
+ BLI_args_print_arg_doc(ba, "--debug-gpu-shaders");
+ BLI_args_print_arg_doc(ba, "--debug-gpumem");
BLI_args_print_arg_doc(ba, "--debug-wm");
# ifdef WITH_XR_OPENXR
BLI_args_print_arg_doc(ba, "--debug-xr");
@@ -598,9 +602,12 @@ static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), vo
printf("\n");
BLI_args_print_arg_doc(ba, "--debug-fpe");
+ BLI_args_print_arg_doc(ba, "--debug-exit-on-error");
BLI_args_print_arg_doc(ba, "--disable-crash-handler");
BLI_args_print_arg_doc(ba, "--disable-abort-handler");
+ BLI_args_print_arg_doc(ba, "--verbose");
+
printf("\n");
printf("Misc Options:\n");
BLI_args_print_arg_doc(ba, "--app-template");
@@ -617,6 +624,7 @@ static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), vo
printf("\n");
BLI_args_print_arg_doc(ba, "--help");
+ BLI_args_print_arg_doc(ba, "/?");
/* WIN32 only (ignored for non-win32) */
BLI_args_print_arg_doc(ba, "-R");
@@ -629,10 +637,15 @@ static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), vo
// printf("\n");
// printf("Experimental Features:\n");
- /* Other options _must_ be last (anything not handled will show here) */
- printf("\n");
- printf("Other Options:\n");
- BLI_args_print_other_doc(ba);
+ /* Other options _must_ be last (anything not handled will show here).
+ *
+ * Note that it's good practice for this to remain empty,
+ * nevertheless print if any exist. */
+ if (BLI_args_has_other_doc(ba)) {
+ printf("\n");
+ printf("Other Options:\n");
+ BLI_args_print_other_doc(ba);
+ }
printf("\n");
printf("Argument Parsing:\n");