[Bf-blender-cvs] [c41b5bddc34] new-object-types: Updates from code reviews
Brecht Van Lommel
noreply at git.blender.org
Fri Feb 28 15:48:23 CET 2020
Commit: c41b5bddc343aeea6dcce1b735935437345e2cf6
Author: Brecht Van Lommel
Date: Fri Feb 28 15:06:21 2020 +0100
Branches: new-object-types
https://developer.blender.org/rBc41b5bddc343aeea6dcce1b735935437345e2cf6
Updates from code reviews
===================================================================
M intern/mantaflow/extern/manta_fluid_API.h
M intern/mantaflow/intern/manta_fluid_API.cpp
M release/scripts/startup/bl_ui/space_userpref.py
M source/blender/blenkernel/intern/hair.c
M source/blender/blenkernel/intern/lib_id.c
M source/blender/blenkernel/intern/pointcloud.c
M source/blender/blenkernel/intern/volume.cc
M source/blender/blenloader/intern/readfile.c
M source/blender/editors/interface/interface_templates.c
M source/blender/editors/object/object_volume.c
M source/blender/makesdna/DNA_ID.h
M source/blender/makesdna/DNA_fluid_types.h
A source/blender/makesdna/DNA_hair_defaults.h
A source/blender/makesdna/DNA_pointcloud_defaults.h
A source/blender/makesdna/DNA_volume_defaults.h
M source/blender/makesdna/intern/CMakeLists.txt
M source/blender/makesdna/intern/dna_defaults.c
M source/blender/makesrna/intern/rna_fluid.c
M source/blender/makesrna/intern/rna_volume.c
===================================================================
diff --git a/intern/mantaflow/extern/manta_fluid_API.h b/intern/mantaflow/extern/manta_fluid_API.h
index 4ebedeb5e38..df5cf2673a0 100644
--- a/intern/mantaflow/extern/manta_fluid_API.h
+++ b/intern/mantaflow/extern/manta_fluid_API.h
@@ -130,14 +130,14 @@ void manta_smoke_turbulence_export(struct MANTA *smoke,
float **tcw2);
void manta_smoke_get_rgba(struct MANTA *smoke, float *data, int sequential);
void manta_smoke_turbulence_get_rgba(struct MANTA *smoke, float *data, int sequential);
-void manta_smoke_get_rgba_from_density(struct MANTA *smoke,
- float color[3],
- float *data,
- int sequential);
-void manta_smoke_turbulence_get_rgba_from_density(struct MANTA *smoke,
- float color[3],
- float *data,
- int sequential);
+void manta_smoke_get_rgba_fixed_color(struct MANTA *smoke,
+ float color[3],
+ float *data,
+ int sequential);
+void manta_smoke_turbulence_get_rgba_fixed_color(struct MANTA *smoke,
+ float color[3],
+ float *data,
+ int sequential);
void manta_smoke_ensure_heat(struct MANTA *smoke, struct FluidModifierData *mmd);
void manta_smoke_ensure_fire(struct MANTA *smoke, struct FluidModifierData *mmd);
void manta_smoke_ensure_colors(struct MANTA *smoke, struct FluidModifierData *mmd);
diff --git a/intern/mantaflow/intern/manta_fluid_API.cpp b/intern/mantaflow/intern/manta_fluid_API.cpp
index 82bfed7cf61..4784d453c9b 100644
--- a/intern/mantaflow/intern/manta_fluid_API.cpp
+++ b/intern/mantaflow/intern/manta_fluid_API.cpp
@@ -447,14 +447,9 @@ static void get_rgba(
for (i = 0; i < total_cells; i++) {
float alpha = a[i];
- if (alpha) {
- data[i * m] = r[i];
- data[i * m + i_g] = g[i];
- data[i * m + i_b] = b[i];
- }
- else {
- data[i * m] = data[i * m + i_g] = data[i * m + i_b] = 0.0f;
- }
+ data[i * m] = r[i] * alpha;
+ data[i * m + i_g] = g[i] * alpha;
+ data[i * m + i_b] = b[i] * alpha;
data[i * m + i_a] = alpha;
}
}
@@ -481,8 +476,7 @@ void manta_smoke_turbulence_get_rgba(MANTA *smoke, float *data, int sequential)
sequential);
}
-static void get_rgba_from_density(
- float color[3], float *a, int total_cells, float *data, int sequential)
+static void get_rgba_fixed_color(float color[3], int total_cells, float *data, int sequential)
{
int i;
int m = 4, i_g = 1, i_b = 2, i_a = 3;
@@ -494,31 +488,24 @@ static void get_rgba_from_density(
}
for (i = 0; i < total_cells; i++) {
- float alpha = a[i];
- if (alpha) {
- data[i * m] = color[0] * alpha;
- data[i * m + i_g] = color[1] * alpha;
- data[i * m + i_b] = color[2] * alpha;
- }
- else {
- data[i * m] = data[i * m + i_g] = data[i * m + i_b] = 0.0f;
- }
- data[i * m + i_a] = alpha;
+ data[i * m] = color[0];
+ data[i * m + i_g] = color[1];
+ data[i * m + i_b] = color[2];
+ data[i * m + i_a] = 1.0f;
}
}
-void manta_smoke_get_rgba_from_density(MANTA *smoke, float color[3], float *data, int sequential)
+void manta_smoke_get_rgba_fixed_color(MANTA *smoke, float color[3], float *data, int sequential)
{
- get_rgba_from_density(color, smoke->getDensity(), smoke->getTotalCells(), data, sequential);
+ get_rgba_fixed_color(color, smoke->getTotalCells(), data, sequential);
}
-void manta_smoke_turbulence_get_rgba_from_density(MANTA *smoke,
- float color[3],
- float *data,
- int sequential)
+void manta_smoke_turbulence_get_rgba_fixed_color(MANTA *smoke,
+ float color[3],
+ float *data,
+ int sequential)
{
- get_rgba_from_density(
- color, smoke->getDensityHigh(), smoke->getTotalCellsHigh(), data, sequential);
+ get_rgba_fixed_color(color, smoke->getTotalCellsHigh(), data, sequential);
}
void manta_smoke_ensure_heat(MANTA *smoke, struct FluidModifierData *mmd)
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 5fd7ecc025d..743bff7f87c 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -378,14 +378,14 @@ class USERPREF_PT_edit_objects_duplicate_data(EditingPanel, CenterAlignMixIn, Pa
col.prop(edit, "use_duplicate_grease_pencil", text="Grease Pencil")
if hasattr(edit, "use_duplicate_hair"):
col.prop(edit, "use_duplicate_hair", text="Hair")
- col = flow.column()
col.prop(edit, "use_duplicate_light", text="Light")
+ col = flow.column()
col.prop(edit, "use_duplicate_lightprobe", text="Light Probe")
col.prop(edit, "use_duplicate_material", text="Material")
col.prop(edit, "use_duplicate_mesh", text="Mesh")
col.prop(edit, "use_duplicate_metaball", text="Metaball")
- col = flow.column()
col.prop(edit, "use_duplicate_particle", text="Particle")
+ col = flow.column()
if hasattr(edit, "use_duplicate_pointcloud"):
col.prop(edit, "use_duplicate_pointcloud", text="Point Cloud")
col.prop(edit, "use_duplicate_surface", text="Surface")
diff --git a/source/blender/blenkernel/intern/hair.c b/source/blender/blenkernel/intern/hair.c
index c5da6049db3..795d7d371a5 100644
--- a/source/blender/blenkernel/intern/hair.c
+++ b/source/blender/blenkernel/intern/hair.c
@@ -24,8 +24,9 @@
#include "MEM_guardedalloc.h"
-#include "DNA_object_types.h"
+#include "DNA_defaults.h"
#include "DNA_hair_types.h"
+#include "DNA_object_types.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
@@ -97,9 +98,7 @@ void BKE_hair_init(Hair *hair)
{
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(hair, id));
- hair->flag = 0;
- hair->totpoint = 0;
- hair->totcurve = 0;
+ MEMCPY_STRUCT_AFTER(hair, DNA_struct_default_get(Hair), id);
CustomData_reset(&hair->pdata);
CustomData_reset(&hair->cdata);
diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c
index ccc446b1cc3..14b9108e414 100644
--- a/source/blender/blenkernel/intern/lib_id.c
+++ b/source/blender/blenkernel/intern/lib_id.c
@@ -565,16 +565,19 @@ bool id_make_local(Main *bmain, ID *id, const bool test, const bool lib_local)
}
return true;
case ID_HA:
- if (!test)
+ if (!test) {
BKE_hair_make_local(bmain, (Hair *)id, lib_local);
+ }
return true;
case ID_PT:
- if (!test)
+ if (!test) {
BKE_pointcloud_make_local(bmain, (PointCloud *)id, lib_local);
+ }
return true;
case ID_VO:
- if (!test)
+ if (!test) {
BKE_volume_make_local(bmain, (Volume *)id, lib_local);
+ }
return true;
case ID_WS:
case ID_SCR:
diff --git a/source/blender/blenkernel/intern/pointcloud.c b/source/blender/blenkernel/intern/pointcloud.c
index 99ce9947130..cc60c0b2cc7 100644
--- a/source/blender/blenkernel/intern/pointcloud.c
+++ b/source/blender/blenkernel/intern/pointcloud.c
@@ -24,6 +24,7 @@
#include "MEM_guardedalloc.h"
+#include "DNA_defaults.h"
#include "DNA_object_types.h"
#include "DNA_pointcloud_types.h"
@@ -70,8 +71,7 @@ void BKE_pointcloud_init(PointCloud *pointcloud)
{
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(pointcloud, id));
- pointcloud->flag = 0;
- pointcloud->totpoint = 0;
+ MEMCPY_STRUCT_AFTER(pointcloud, DNA_struct_default_get(PointCloud), id);
CustomData_reset(&pointcloud->pdata);
CustomData_add_layer(&pointcloud->pdata, CD_LOCATION, CD_CALLOC, NULL, pointcloud->totpoint);
diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc
index 581a71c4d47..3c94e391852 100644
--- a/source/blender/blenkernel/intern/volume.cc
+++ b/source/blender/blenkernel/intern/volume.cc
@@ -24,6 +24,7 @@
#include "MEM_guardedalloc.h"
+#include "DNA_defaults.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_volume_types.h"
@@ -109,11 +110,6 @@ struct VolumeFileCache {
{
}
- bool operator()(const char *s1, const char *s2) const
- {
- return strcmp(s1, s2) == 0;
- }
-
/* Unique key: filename + grid name. */
std::string filepath;
std::string grid_name;
@@ -345,7 +341,7 @@ struct VolumeGrid {
/* Make a deep copy of the grid and remove any reference to a grid in the
* file cache. Load file grid into memory first if needed. */
load(volume_name, filepath);
- // TODO: avoid deep copy if we are the only user
+ /* TODO: avoid deep copy if we are the only user. */
vdb = vdb->deepCopyGrid();
if (entry) {
GLOBAL_CACHE.remove_user(*entry, is_loaded);
@@ -439,14 +435,8 @@ void BKE_volume_init(Volume *volume)
{
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(volume, id));
- volume->filepath[0] = '\0';
- volume->packedfile = NULL;
- volume->flag = 0;
- volume->frame_start = 1;
- volume->frame_offset = 0;
- volume->frame_duration = 0;
- volume->display.density = 1.0f;
- volume->display.wireframe_type = VOLUME_WIREFRAME_COARSE;
+ MEMCPY_STRUCT_AFTER(volume, DNA_struct_default_get(Volume), id);
+
BKE_volume_init_grids(volume);
}
@@ -574,7 +564,7 @@ static int volume_sequence_frame(const Depsgraph *depsgraph, const Volume *volum
}
}
- /* important to apply after else we cant loop on frames 100 - 110 for eg. */
+ /* Important to apply after, else we cant loop on e.g. frames 100 - 110. */
frame += frame_offset;
return frame;
@@ -642,8 +632,6 @@ bool BKE_volume_load(Volume *volume, Main *bmain)
retur
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list