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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2020-03-17 16:41:48 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2020-03-18 13:23:05 +0300
commitb0a1cf2c9ae696b07f7a236bc855a5ab4a493dcb (patch)
tree92295af11db5e984da42bfac7ca60190b8549a3f /source/blender/blenloader/intern/writefile.c
parent8dcfd392e4e62f193b666304425bc5ae635ecffe (diff)
Objects: add Volume object type, and prototypes for Hair and PointCloud
Only the volume object is exposed in the user interface. It is based on OpenVDB internally. Drawing and rendering code will follow in another commit. https://wiki.blender.org/wiki/Source/Objects/Volume https://wiki.blender.org/wiki/Reference/Release_Notes/2.83/Volumes Hair and PointCloud object types are hidden behind a WITH_NEW_OBJECT_TYPES build option. These are unfinished, and included only to make it easier to cooperate on development in the future and avoid tricky merges. https://wiki.blender.org/wiki/Source/Objects/New_Object_Types Ref T73201, T68981 Differential Revision: https://developer.blender.org/D6945
Diffstat (limited to 'source/blender/blenloader/intern/writefile.c')
-rw-r--r--source/blender/blenloader/intern/writefile.c104
1 files changed, 104 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 837134c0156..c948949c06e 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -106,6 +106,7 @@
#include "DNA_gpencil_types.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_shader_fx_types.h"
+#include "DNA_hair_types.h"
#include "DNA_fileglobal_types.h"
#include "DNA_key_types.h"
#include "DNA_lattice_types.h"
@@ -121,6 +122,7 @@
#include "DNA_object_force_types.h"
#include "DNA_packedFile_types.h"
#include "DNA_particle_types.h"
+#include "DNA_pointcloud_types.h"
#include "DNA_lightprobe_types.h"
#include "DNA_rigidbody_types.h"
#include "DNA_scene_types.h"
@@ -134,6 +136,7 @@
#include "DNA_text_types.h"
#include "DNA_view3d_types.h"
#include "DNA_vfont_types.h"
+#include "DNA_volume_types.h"
#include "DNA_world_types.h"
#include "DNA_windowmanager_types.h"
#include "DNA_workspace_types.h"
@@ -3712,6 +3715,98 @@ static void write_workspace(WriteData *wd, WorkSpace *workspace)
}
}
+static void write_hair(WriteData *wd, Hair *hair)
+{
+ if (hair->id.us > 0 || wd->use_memfile) {
+ /* Write a copy of the hair with possibly reduced number of data layers.
+ * Don't edit the original since other threads might be reading it. */
+ Hair *old_hair = hair;
+ Hair copy_hair = *hair;
+ hair = &copy_hair;
+
+ CustomDataLayer *players = NULL, players_buff[CD_TEMP_CHUNK_SIZE];
+ CustomDataLayer *clayers = NULL, clayers_buff[CD_TEMP_CHUNK_SIZE];
+ CustomData_file_write_prepare(&hair->pdata, &players, players_buff, ARRAY_SIZE(players_buff));
+ CustomData_file_write_prepare(&hair->cdata, &clayers, clayers_buff, ARRAY_SIZE(clayers_buff));
+
+ /* Write LibData */
+ writestruct_at_address(wd, ID_HA, Hair, 1, old_hair, hair);
+ write_iddata(wd, &hair->id);
+
+ /* Direct data */
+ write_customdata(wd, &hair->id, hair->totpoint, &hair->pdata, players, CD_MASK_ALL);
+ write_customdata(wd, &hair->id, hair->totcurve, &hair->cdata, clayers, CD_MASK_ALL);
+ writedata(wd, DATA, sizeof(void *) * hair->totcol, hair->mat);
+ if (hair->adt) {
+ write_animdata(wd, hair->adt);
+ }
+
+ /* Remove temporary data. */
+ if (players && players != players_buff) {
+ MEM_freeN(players);
+ }
+ if (clayers && clayers != clayers_buff) {
+ MEM_freeN(clayers);
+ }
+
+ /* restore pointer */
+ hair = old_hair;
+ }
+}
+
+static void write_pointcloud(WriteData *wd, PointCloud *pointcloud)
+{
+ if (pointcloud->id.us > 0 || wd->use_memfile) {
+ /* Write a copy of the pointcloud with possibly reduced number of data layers.
+ * Don't edit the original since other threads might be reading it. */
+ PointCloud *old_pointcloud = pointcloud;
+ PointCloud copy_pointcloud = *pointcloud;
+ pointcloud = &copy_pointcloud;
+
+ CustomDataLayer *players = NULL, players_buff[CD_TEMP_CHUNK_SIZE];
+ CustomData_file_write_prepare(
+ &pointcloud->pdata, &players, players_buff, ARRAY_SIZE(players_buff));
+
+ /* Write LibData */
+ writestruct_at_address(wd, ID_PT, PointCloud, 1, old_pointcloud, pointcloud);
+ write_iddata(wd, &pointcloud->id);
+
+ /* Direct data */
+ write_customdata(
+ wd, &pointcloud->id, pointcloud->totpoint, &pointcloud->pdata, players, CD_MASK_ALL);
+ writedata(wd, DATA, sizeof(void *) * pointcloud->totcol, pointcloud->mat);
+ if (pointcloud->adt) {
+ write_animdata(wd, pointcloud->adt);
+ }
+
+ /* Remove temporary data. */
+ if (players && players != players_buff) {
+ MEM_freeN(players);
+ }
+ }
+}
+
+static void write_volume(WriteData *wd, Volume *volume)
+{
+ if (volume->id.us > 0 || wd->use_memfile) {
+ /* write LibData */
+ writestruct(wd, ID_VO, Volume, 1, volume);
+ write_iddata(wd, &volume->id);
+
+ /* direct data */
+ writedata(wd, DATA, sizeof(void *) * volume->totcol, volume->mat);
+ if (volume->adt) {
+ write_animdata(wd, volume->adt);
+ }
+
+ if (volume->packedfile) {
+ PackedFile *pf = volume->packedfile;
+ writestruct(wd, DATA, PackedFile, 1, pf);
+ writedata(wd, DATA, pf->size, pf->data);
+ }
+ }
+}
+
/* Keep it last of write_foodata functions. */
static void write_libraries(WriteData *wd, Main *main)
{
@@ -4017,6 +4112,15 @@ static bool write_file_handle(Main *mainvar,
case ID_CF:
write_cachefile(wd, (CacheFile *)id);
break;
+ case ID_HA:
+ write_hair(wd, (Hair *)id);
+ break;
+ case ID_PT:
+ write_pointcloud(wd, (PointCloud *)id);
+ break;
+ case ID_VO:
+ write_volume(wd, (Volume *)id);
+ break;
case ID_LI:
/* Do nothing, handled below - and should never be reached. */
BLI_assert(0);