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/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);