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:
Diffstat (limited to 'source/blender/blenkernel/intern/volume.cc')
-rw-r--r--source/blender/blenkernel/intern/volume.cc50
1 files changed, 50 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc
index 82405830437..d7762400f64 100644
--- a/source/blender/blenkernel/intern/volume.cc
+++ b/source/blender/blenkernel/intern/volume.cc
@@ -1089,6 +1089,8 @@ static void volume_evaluate_modifiers(struct Depsgraph *depsgraph,
ModifierApplyFlag apply_flag = use_render ? MOD_APPLY_RENDER : MOD_APPLY_USECACHE;
const ModifierEvalContext mectx = {depsgraph, object, apply_flag};
+ BKE_modifiers_clear_errors(object);
+
/* Get effective list of modifiers to execute. Some effects like shape keys
* are added as virtual modifiers before the user created modifiers. */
VirtualModifierData virtualModifierData;
@@ -1359,6 +1361,26 @@ const char *BKE_volume_grid_name(const VolumeGrid *volume_grid)
}
#ifdef WITH_OPENVDB
+struct ClearGridOp {
+ openvdb::GridBase &grid;
+
+ template<typename Grid> void operator()()
+ {
+ static_cast<Grid &>(grid).clear();
+ }
+};
+void BKE_volume_grid_clear_tree(openvdb::GridBase &grid)
+{
+ const VolumeGridType grid_type = BKE_volume_grid_type_openvdb(grid);
+ ClearGridOp op{grid};
+ BKE_volume_grid_type_operation(grid_type, op);
+}
+void BKE_volume_grid_clear_tree(Volume &volume, VolumeGrid &volume_grid)
+{
+ openvdb::GridBase::Ptr grid = BKE_volume_grid_openvdb_for_write(&volume, &volume_grid, false);
+ BKE_volume_grid_clear_tree(*grid);
+}
+
VolumeGridType BKE_volume_grid_type_openvdb(const openvdb::GridBase &grid)
{
if (grid.isType<openvdb::FloatGrid>()) {
@@ -1449,6 +1471,23 @@ void BKE_volume_grid_transform_matrix(const VolumeGrid *volume_grid, float mat[4
#endif
}
+void BKE_volume_grid_transform_matrix_set(struct VolumeGrid *volume_grid, const float mat[4][4])
+{
+#ifdef WITH_OPENVDB
+ openvdb::math::Mat4f mat_openvdb;
+ for (int col = 0; col < 4; col++) {
+ for (int row = 0; row < 4; row++) {
+ mat_openvdb(col, row) = mat[col][row];
+ }
+ }
+ openvdb::GridBase::Ptr grid = volume_grid->grid();
+ grid->setTransform(std::make_shared<openvdb::math::Transform>(
+ std::make_shared<openvdb::math::AffineMap>(mat_openvdb)));
+#else
+ UNUSED_VARS(volume_grid, mat);
+#endif
+}
+
/* Grid Tree and Voxels */
/* Volume Editing */
@@ -1545,6 +1584,17 @@ void BKE_volume_grid_remove(Volume *volume, VolumeGrid *grid)
#endif
}
+bool BKE_volume_grid_determinant_valid(const double determinant)
+{
+#ifdef WITH_OPENVDB
+ /* Limit taken from openvdb/math/Maps.h. */
+ return std::abs(determinant) >= 3.0 * openvdb::math::Tolerance<double>::value();
+#else
+ UNUSED_VARS(determinant);
+ return true;
+#endif
+}
+
int BKE_volume_simplify_level(const Depsgraph *depsgraph)
{
if (DEG_get_mode(depsgraph) != DAG_EVAL_RENDER) {