Commit: dd1f70ffb5ec44314931ae933cf3e1dc44a48716
Author: Lukas Tönne
Date:   Tue Nov 4 09:08:20 2014 +0100
Branches: alembic_pointcache
https://developer.blender.org/rBdd1f70ffb5ec44314931ae933cf3e1dc44a48716

Introduced a new modifier "Point Cache" for recording cache data at
user-defined points in the modifier stack.

These will replace the preliminary test changes in the mesh cache
modifier.

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

M       release/scripts/startup/bl_ui/properties_data_modifier.py
M       source/blender/editors/space_outliner/outliner_draw.c
M       source/blender/makesdna/DNA_modifier_types.h
M       source/blender/makesrna/RNA_access.h
M       source/blender/makesrna/intern/rna_modifier.c
M       source/blender/modifiers/CMakeLists.txt
M       source/blender/modifiers/MOD_modifiertypes.h
A       source/blender/modifiers/intern/MOD_pointcache.c
M       source/blender/modifiers/intern/MOD_util.c
M       source/blender/pointcache/PTC_api.h
M       source/blender/pointcache/intern/mesh.cpp
M       source/blender/pointcache/intern/mesh.h

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py 
b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 828fd82..c91e99a 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -673,6 +673,12 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
     def PARTICLE_SYSTEM(self, layout, ob, md):
         layout.label(text="Settings can be found inside the Particle context")
 
+    def POINT_CACHE(self, layout, ob, md):
+        col = layout.column()
+        col.context_pointer_set("point_cache", md.point_cache)
+        col.context_pointer_set("point_cache_user", md)
+        col.operator("PTCACHE_OT_export")
+
     def SCREW(self, layout, ob, md):
         split = layout.split()
 
diff --git a/source/blender/editors/space_outliner/outliner_draw.c 
b/source/blender/editors/space_outliner/outliner_draw.c
index e033f78..2381296 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -1020,6 +1020,8 @@ static void tselem_draw_icon(uiBlock *block, int xmax, 
float x, float y, TreeSto
                                                UI_icon_draw(x, y, 
ICON_MOD_WIREFRAME); break;
                                        case eModifierType_LaplacianDeform:
                                                UI_icon_draw(x, y, 
ICON_MOD_MESHDEFORM); break;  /* XXX, needs own icon */
+                                       case eModifierType_PointCache:
+                                               UI_icon_draw(x, y, 
ICON_MOD_MESHDEFORM); break;  /* XXX, needs own icon */
                                        /* Default */
                                        case eModifierType_None:
                                        case eModifierType_ShapeKey:
diff --git a/source/blender/makesdna/DNA_modifier_types.h 
b/source/blender/makesdna/DNA_modifier_types.h
index c395552..8555e28 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -82,6 +82,7 @@ typedef enum ModifierType {
        eModifierType_MeshCache         = 46,
        eModifierType_LaplacianDeform   = 47,
        eModifierType_Wireframe         = 48,
+       eModifierType_PointCache        = 49,
        NUM_MODIFIER_TYPES
 } ModifierType;
 
@@ -1368,6 +1369,15 @@ enum {
        MOD_WIREFRAME_CREASE        = (1 << 5),
 };
 
+/* point cache modifier */
+typedef struct PointCacheModifierData {
+       ModifierData modifier;
+       
+       int flag;
+       int pad;
+       
+       struct PointCache *point_cache;
+} PointCacheModifierData;
 
 
 #endif  /* __DNA_MODIFIER_TYPES_H__ */
diff --git a/source/blender/makesrna/RNA_access.h 
b/source/blender/makesrna/RNA_access.h
index f0582b3..c8902de 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -448,6 +448,7 @@ extern StructRNA RNA_ParticleSystemModifier;
 extern StructRNA RNA_ParticleTarget;
 extern StructRNA RNA_PivotConstraint;
 extern StructRNA RNA_PointCache;
+extern StructRNA RNA_PointCacheModifier;
 extern StructRNA RNA_PointDensity;
 extern StructRNA RNA_PointDensityTexture;
 extern StructRNA RNA_PointLamp;
diff --git a/source/blender/makesrna/intern/rna_modifier.c 
b/source/blender/makesrna/intern/rna_modifier.c
index e1a4fbb..994809f 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -58,6 +58,7 @@
 EnumPropertyItem modifier_type_items[] = {
        {0, "", 0, N_("Modify"), ""},
        {eModifierType_MeshCache, "MESH_CACHE", ICON_MOD_MESHDEFORM, "Mesh 
Cache", ""},
+       {eModifierType_PointCache, "POINT_CACHE", ICON_MOD_MESHDEFORM, "Point 
Cache", ""},
        {eModifierType_UVProject, "UV_PROJECT", ICON_MOD_UVPROJECT, "UV 
Project", ""},
        {eModifierType_UVWarp, "UV_WARP", ICON_MOD_UVPROJECT, "UV Warp", ""},
        {eModifierType_WeightVGEdit, "VERTEX_WEIGHT_EDIT", 
ICON_MOD_VERTEX_WEIGHT, "Vertex Weight Edit", ""},
@@ -244,6 +245,8 @@ static StructRNA *rna_Modifier_refine(struct PointerRNA 
*ptr)
                        return &RNA_LaplacianDeformModifier;
                case eModifierType_Wireframe:
                        return &RNA_WireframeModifier;
+               case eModifierType_PointCache:
+                       return &RNA_PointCacheModifier;
                /* Default */
                case eModifierType_None:
                case eModifierType_ShapeKey:
@@ -3672,6 +3675,23 @@ static void rna_def_modifier_wireframe(BlenderRNA *brna)
        RNA_def_property_update(prop, 0, "rna_Modifier_update");
 }
 
+static void rna_def_modifier_pointcache(BlenderRNA *brna)
+{
+       StructRNA *srna;
+       PropertyRNA *prop;
+
+       srna = RNA_def_struct(brna, "PointCacheModifier", "Modifier");
+       RNA_def_struct_ui_text(srna, "Point Cache Modifier", "Write and Read 
mesh results to/from point cache");
+       RNA_def_struct_sdna(srna, "PointCacheModifierData");
+       RNA_def_struct_ui_icon(srna, ICON_MOD_MESHDEFORM);  /* XXX, needs own 
icon */
+
+       prop = RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NONE);
+       RNA_def_property_flag(prop, PROP_NEVER_NULL);
+       RNA_def_property_pointer_sdna(prop, NULL, "point_cache");
+       RNA_def_property_struct_type(prop, "PointCache");
+       RNA_def_property_ui_text(prop, "Point Cache", "");
+}
+
 void RNA_def_modifier(BlenderRNA *brna)
 {
        StructRNA *srna;
@@ -3785,6 +3805,7 @@ void RNA_def_modifier(BlenderRNA *brna)
        rna_def_modifier_meshcache(brna);
        rna_def_modifier_laplaciandeform(brna);
        rna_def_modifier_wireframe(brna);
+       rna_def_modifier_pointcache(brna);
 }
 
 #endif
diff --git a/source/blender/modifiers/CMakeLists.txt 
b/source/blender/modifiers/CMakeLists.txt
index 18f8f12..58bd515 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -76,6 +76,7 @@ set(SRC
        intern/MOD_ocean.c
        intern/MOD_particleinstance.c
        intern/MOD_particlesystem.c
+       intern/MOD_pointcache.c
        intern/MOD_remesh.c
        intern/MOD_screw.c
        intern/MOD_shapekey.c
diff --git a/source/blender/modifiers/MOD_modifiertypes.h 
b/source/blender/modifiers/MOD_modifiertypes.h
index 9c7c21c..2e50c5a 100644
--- a/source/blender/modifiers/MOD_modifiertypes.h
+++ b/source/blender/modifiers/MOD_modifiertypes.h
@@ -81,6 +81,7 @@ extern ModifierTypeInfo modifierType_UVWarp;
 extern ModifierTypeInfo modifierType_MeshCache;
 extern ModifierTypeInfo modifierType_LaplacianDeform;
 extern ModifierTypeInfo modifierType_Wireframe;
+extern ModifierTypeInfo modifierType_PointCache;
 
 /* MOD_util.c */
 void modifier_type_init(ModifierTypeInfo *types[]);
diff --git a/source/blender/modifiers/intern/MOD_pointcache.c 
b/source/blender/modifiers/intern/MOD_pointcache.c
new file mode 100644
index 0000000..57ff83d
--- /dev/null
+++ b/source/blender/modifiers/intern/MOD_pointcache.c
@@ -0,0 +1,152 @@
+/*
+ * ***** 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.
+ *
+ * Contributor(s): Lukas Toenne
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/modifiers/intern/MOD_pointcache.c
+ *  \ingroup modifiers
+ */
+
+#include <stdio.h>
+
+#include "DNA_scene_types.h"
+#include "DNA_object_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_string.h"
+
+#include "BKE_cdderivedmesh.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_scene.h"
+#include "BKE_global.h"
+#include "BKE_mesh.h"
+#include "BKE_main.h"
+#include "BKE_pointcache.h"
+
+#include "PTC_api.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "MOD_modifiertypes.h"
+
+#include "MOD_util.h"
+
+struct BMEditMesh;
+
+static void initData(ModifierData *md)
+{
+       PointCacheModifierData *pcmd = (PointCacheModifierData *)md;
+
+       pcmd->flag = 0;
+       pcmd->point_cache = BKE_ptcache_new();
+}
+
+static void copyData(ModifierData *md, ModifierData *target)
+{
+       PointCacheModifierData *pcmd = (PointCacheModifierData *)md;
+       PointCacheModifierData *tpcmd = (PointCacheModifierData *)target;
+
+       modifier_copyData_generic(md, target);
+
+       tpcmd->point_cache = BKE_ptcache_copy(pcmd->point_cache, false);
+}
+
+static void freeData(ModifierData *md)
+{
+       PointCacheModifierData *pcmd = (PointCacheModifierData *)md;
+       BKE_ptcache_free(pcmd->point_cache);
+}
+
+static bool dependsOnTime(ModifierData *UNUSED(md))
+{
+       return true;
+}
+
+static DerivedMesh *pointcache_do(PointCacheModifierData *pcmd, Object *ob, 
DerivedMesh *dm)
+{
+       Scene *scene = pcmd->modifier.scene;
+       const float cfra = BKE_scene_frame_get(scene);
+       
+       DerivedMesh *finaldm = dm;
+
+       struct PTCReader *reader = PTC_reader_point_cache(scene, ob, pcmd);
+       
+       if (PTC_read_sample(reader, cfra) == PTC_READ_SAMPLE_INVALID) {
+               modifier_setError(&pcmd->modifier, "%s", "Cannot read Alembic 
cache file");
+       }
+       else {
+               DerivedMesh *result = 
PTC_reader_point_cache_acquire_result(reader);
+               if (result)
+                       finaldm = result;
+       }
+       
+       PTC_reader_free(reader);
+       
+       return finaldm;
+}
+
+static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
+                                  DerivedMesh *dm,
+                                  ModifierApplyFlag UNUSED(flag))
+{
+       PointCacheModifierData *pcmd = (PointCacheModifierData *)md;
+
+       return pointcache_do(pcmd, ob, dm);
+}
+
+static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob,
+                                    struct BMEditMesh *UNUSED(editData),
+                                    DerivedMesh *dm,
+                                    ModifierApplyFlag UNUSED(flag))
+{
+       PointCacheModifierData *pcmd = (PointCacheModifierData *)md;
+
+       return pointcache_do(pcmd, ob, dm);
+}
+
+ModifierTypeInfo modifierType_PointCache = {
+       /* name */              "Point Cache",
+       /* structName */        "PointCacheModifierData",
+       /* structSize */        sizeof(PointCacheModifierData),
+       /* type */              eModifierTypeType_Constructive,
+       /* flags */             eModifierTypeFlag_AcceptsMesh |
+                               eModifierTypeFlag_AcceptsCVs |
+                               eM

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to