Commit: deb760896b162ff98146986442638696eaa0f8ed
Author: Lukas Tönne
Date:   Sat Nov 10 14:44:20 2018 +0000
Branches: hair_object
https://developer.blender.org/rBdeb760896b162ff98146986442638696eaa0f8ed

Runtime struct for non-serialized hair data, similar to Mesh runtime.

===================================================================

A       source/blender/blenkernel/BKE_hair_runtime.h
M       source/blender/blenkernel/CMakeLists.txt
M       source/blender/blenkernel/intern/hair.c
M       source/blender/blenkernel/intern/hair_draw.c
A       source/blender/blenkernel/intern/hair_runtime.c
M       source/blender/blenloader/intern/readfile.c
M       source/blender/draw/intern/draw_cache_impl_hair.c
M       source/blender/makesdna/DNA_hair_types.h

===================================================================

diff --git a/source/blender/blenkernel/BKE_hair_runtime.h 
b/source/blender/blenkernel/BKE_hair_runtime.h
new file mode 100644
index 00000000000..bf421386ba2
--- /dev/null
+++ b/source/blender/blenkernel/BKE_hair_runtime.h
@@ -0,0 +1,41 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) Blender Foundation
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Lukas Toenne
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __BKE_HAIR_RUNTIME_H__
+#define __BKE_HAIR_RUNTIME_H__
+
+/** \file blender/blenkernel/BKE_hair_runtime.h
+ *  \ingroup bke
+ */
+
+#include "BLI_utildefines.h"
+
+struct HairSystem;
+
+void BKE_hair_runtime_reset(struct HairSystem *hsys);
+
+#endif
diff --git a/source/blender/blenkernel/CMakeLists.txt 
b/source/blender/blenkernel/CMakeLists.txt
index 9f3533b9f35..604d5efeb47 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -121,6 +121,7 @@ set(SRC
        intern/gpencil_modifier.c
        intern/hair.c
        intern/hair_draw.c
+       intern/hair_runtime.c
        intern/icons.c
        intern/icons_rasterize.c
        intern/idcode.c
@@ -278,6 +279,7 @@ set(SRC
        BKE_gpencil_modifier.h
        BKE_hair.h
        BKE_hair_iterators.h
+       BKE_hair_runtime.h
        BKE_icons.h
        BKE_idcode.h
        BKE_idprop.h
diff --git a/source/blender/blenkernel/intern/hair.c 
b/source/blender/blenkernel/intern/hair.c
index 3cec48ca403..c5e184076c4 100644
--- a/source/blender/blenkernel/intern/hair.c
+++ b/source/blender/blenkernel/intern/hair.c
@@ -52,6 +52,7 @@
 #include "BKE_global.h"
 #include "BKE_hair.h"
 #include "BKE_hair_iterators.h"
+#include "BKE_hair_runtime.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_mesh.h"
@@ -181,7 +182,7 @@ void BKE_hair_copy_data(Main *UNUSED(bmain), HairSystem 
*hsys_dst, const HairSys
                hsys_dst->draw_settings = 
BKE_hair_draw_settings_copy(hsys_src->draw_settings);
        }
 
-       hsys_dst->draw_batch_cache = NULL;
+       BKE_hair_runtime_reset(hsys_dst);
 }
 
 HairSystem *BKE_hair_copy(Main *bmain, const HairSystem *hsys)
diff --git a/source/blender/blenkernel/intern/hair_draw.c 
b/source/blender/blenkernel/intern/hair_draw.c
index b62ce6888b1..b215a4fd92f 100644
--- a/source/blender/blenkernel/intern/hair_draw.c
+++ b/source/blender/blenkernel/intern/hair_draw.c
@@ -77,14 +77,14 @@ void (*BKE_hair_batch_cache_free_cb)(HairSystem* hsys) = 
NULL;
 
 void BKE_hair_batch_cache_dirty(HairSystem* hsys, int mode)
 {
-       if (hsys->draw_batch_cache) {
+       if (hsys->runtime.draw_batch_cache) {
                BKE_hair_batch_cache_dirty_cb(hsys, mode);
        }
 }
 
 void BKE_hair_batch_cache_free(HairSystem* hsys)
 {
-       if (hsys->draw_batch_cache) {
+       if (hsys->runtime.draw_batch_cache) {
                BKE_hair_batch_cache_free_cb(hsys);
        }
 }
diff --git a/source/blender/blenkernel/intern/hair_runtime.c 
b/source/blender/blenkernel/intern/hair_runtime.c
new file mode 100644
index 00000000000..384c16bce15
--- /dev/null
+++ b/source/blender/blenkernel/intern/hair_runtime.c
@@ -0,0 +1,58 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) Blender Foundation
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Lukas Toenne
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenkernel/intern/hair_runtime.c
+ *  \ingroup bke
+ */
+
+#include <limits.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_hair_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
+
+#include "BKE_animsys.h"
+#include "BKE_customdata.h"
+#include "BKE_global.h"
+#include "BKE_hair.h"
+#include "BKE_hair_iterators.h"
+#include "BKE_hair_runtime.h"
+#include "BKE_mesh_sample.h"
+#include "BKE_object.h"
+
+#include "DEG_depsgraph_query.h"
+
+void BKE_hair_runtime_reset(HairSystem *hsys)
+{
+       HairSystem_Runtime *runtime = &hsys->runtime;
+
+       runtime->draw_batch_cache = NULL;
+}
diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index 3f397a6d10b..16eb2213375 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -135,6 +135,7 @@
 #include "BKE_global.h" // for G
 #include "BKE_gpencil.h"
 #include "BKE_gpencil_modifier.h"
+#include "BKE_hair_runtime.h"
 #include "BKE_layer.h"
 #include "BKE_library.h" // for which_libbase
 #include "BKE_library_idmap.h"
@@ -8430,7 +8431,7 @@ static void direct_link_hair(FileData *fd, HairSystem* 
hsys)
 
        hsys->bb = NULL;
        hsys->edithair = NULL;
-       hsys->draw_batch_cache = NULL;
+       BKE_hair_runtime_reset(hsys);
 }
 
 /* ************** GENERAL & MAIN ******************** */
diff --git a/source/blender/draw/intern/draw_cache_impl_hair.c 
b/source/blender/draw/intern/draw_cache_impl_hair.c
index a6a3e5e971b..f7493df584c 100644
--- a/source/blender/draw/intern/draw_cache_impl_hair.c
+++ b/source/blender/draw/intern/draw_cache_impl_hair.c
@@ -79,7 +79,7 @@ static void hair_batch_cache_clear(HairSystem *hsys);
 
 static bool hair_batch_cache_valid(HairSystem *hsys)
 {
-       HairBatchCache *cache = hsys->draw_batch_cache;
+       HairBatchCache *cache = hsys->runtime.draw_batch_cache;
 
        if (cache == NULL) {
                return false;
@@ -98,10 +98,10 @@ static bool hair_batch_cache_valid(HairSystem *hsys)
 
 static void hair_batch_cache_init(HairSystem *hsys)
 {
-       HairBatchCache *cache = hsys->draw_batch_cache;
+       HairBatchCache *cache = hsys->runtime.draw_batch_cache;
        
        if (!cache) {
-               cache = hsys->draw_batch_cache = MEM_callocN(sizeof(*cache), 
__func__);
+               cache = hsys->runtime.draw_batch_cache = 
MEM_callocN(sizeof(*cache), __func__);
        }
        else {
                memset(cache, 0, sizeof(*cache));
@@ -117,12 +117,12 @@ static HairBatchCache *hair_batch_cache_get(HairSystem 
*hsys)
                hair_batch_cache_clear(hsys);
                hair_batch_cache_init(hsys);
        }
-       return hsys->draw_batch_cache;
+       return hsys->runtime.draw_batch_cache;
 }
 
 void DRW_hair_batch_cache_dirty(HairSystem *hsys, int mode)
 {
-       HairBatchCache *cache = hsys->draw_batch_cache;
+       HairBatchCache *cache = hsys->runtime.draw_batch_cache;
        if (cache == NULL) {
                return;
        }
@@ -140,7 +140,7 @@ void DRW_hair_batch_cache_dirty(HairSystem *hsys, int mode)
 
 static void hair_batch_cache_clear(HairSystem *hsys)
 {
-       HairBatchCache *cache = hsys->draw_batch_cache;
+       HairBatchCache *cache = hsys->runtime.draw_batch_cache;
        if (cache) {
                particle_batch_cache_clear_hair(&cache->hair);
                particle_batch_cache_clear_hair(&cache->edit_hair);
@@ -153,7 +153,7 @@ static void hair_batch_cache_clear(HairSystem *hsys)
 void DRW_hair_batch_cache_free(HairSystem *hsys)
 {
        hair_batch_cache_clear(hsys);
-       MEM_SAFE_FREE(hsys->draw_batch_cache);
+       MEM_SAFE_FREE(hsys->runtime.draw_batch_cache);
 }
 
 static void hair_batch_cache_ensure_count(
diff --git a/source/blender/makesdna/DNA_hair_types.h 
b/source/blender/makesdna/DNA_hair_types.h
index d5472f019f3..013f87a3dc4 100644
--- a/source/blender/makesdna/DNA_hair_types.h
+++ b/source/blender/makesdna/DNA_hair_types.h
@@ -101,6 +101,14 @@ typedef struct EditHair {
        HairCurveData curve_data;
 } EditHair;
 
+/* not saved in file! */
+typedef struct HairSystem_Runtime {
+       // struct EditHair *edithair;
+       void *draw_batch_cache;     /* Data buffers for drawing */
+
+       // int64_t cd_dirty_follicles;
+} HairSystem_Runtime;
+
 typedef struct HairSystem {
        ID id;                      /* Hair data is a datablock */
        struct AnimData *adt;       /* Animation data - for animating settings 
*/
@@ -125,8 +133,7 @@ typedef struct HairSystem {
 
        struct HairDrawSettings *draw_settings;
 
-       /* Data buffers for drawing */
-       void *draw_batch_cache;
+       HairSystem_Runtime runtime;
 } HairSystem;
 
 // typedef enum eHairSystemFlag

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to