[Bf-blender-cvs] [0ec12d9] alembic_basic_io: Added frame start/scale properties to CacheFile, de-duplicate some code.
Kévin Dietrich
noreply at git.blender.org
Thu Jun 9 16:47:15 CEST 2016
Commit: 0ec12d9bb65a90733a48a6ca1205a9cb6f2b0f38
Author: Kévin Dietrich
Date: Thu Jun 9 16:06:37 2016 +0200
Branches: alembic_basic_io
https://developer.blender.org/rB0ec12d9bb65a90733a48a6ca1205a9cb6f2b0f38
Added frame start/scale properties to CacheFile, de-duplicate some code.
===================================================================
M source/blender/alembic/intern/alembic_capi.cc
A source/blender/blenkernel/BKE_cachefile.h
M source/blender/blenkernel/CMakeLists.txt
A source/blender/blenkernel/intern/cachefile.c
M source/blender/blenkernel/intern/constraint.c
M source/blender/editors/interface/interface_templates.c
M source/blender/makesdna/DNA_cachefile_types.h
M source/blender/makesrna/intern/rna_cachefile.c
M source/blender/modifiers/intern/MOD_meshsequencecache.c
===================================================================
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index 83696ea..f759307 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -42,6 +42,7 @@ extern "C" {
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
+#include "BKE_cachefile.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
@@ -483,7 +484,7 @@ static void import_startjob(void *cjv, short *stop, short *do_update, float *pro
return;
}
- CacheFile *cache_file = static_cast<CacheFile *>(BKE_libblock_alloc(data->bmain, ID_CF, BLI_path_basename(data->filename)));
+ CacheFile *cache_file = static_cast<CacheFile *>(BKE_cachefile_add(data->bmain, BLI_path_basename(data->filename)));
cache_file->is_sequence = data->settings.is_sequence;
BLI_strncpy(cache_file->filepath, data->filename, 1024);
diff --git a/source/blender/makesdna/DNA_cachefile_types.h b/source/blender/blenkernel/BKE_cachefile.h
similarity index 69%
copy from source/blender/makesdna/DNA_cachefile_types.h
copy to source/blender/blenkernel/BKE_cachefile.h
index 2899cad..7218e27 100644
--- a/source/blender/makesdna/DNA_cachefile_types.h
+++ b/source/blender/blenkernel/BKE_cachefile.h
@@ -23,29 +23,29 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file DNA_cachefile_types.h
- * \ingroup DNA
- */
-
-#ifndef __DNA_CACHEFILE_TYPES_H__
-#define __DNA_CACHEFILE_TYPES_H__
+#ifndef __BKE_CACHEFILE_H__
+#define __BKE_CACHEFILE_H__
-#include "DNA_ID.h"
+/** \file BKE_cachefile.h
+ * \ingroup bke
+ */
#ifdef __cplusplus
extern "C" {
#endif
-typedef struct CacheFile {
- ID id;
+struct Main;
+
+void *BKE_cachefile_add(struct Main *bmain, const char *name);
+
+void BKE_cachefile_filepath_get(struct Scene *scene,
+ struct CacheFile *cache_file,
+ char *r_filename);
- char filepath[1024]; /* 1024 = FILE_MAX */
- char is_sequence;
- char pad[7];
-} CacheFile;
+float BKE_cachefile_time_offset(struct CacheFile *cache_file, float time);
#ifdef __cplusplus
}
#endif
-#endif /* __DNA_CACHEFILE_TYPES_H__ */
+#endif /* __BKE_CACHEFILE_H__ */
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 2c9b047..c417e50 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -84,6 +84,7 @@ set(SRC
intern/brush.c
intern/bullet.c
intern/bvhutils.c
+ intern/cachefile.c
intern/camera.c
intern/cdderivedmesh.c
intern/cloth.c
@@ -209,6 +210,7 @@ set(SRC
BKE_brush.h
BKE_bullet.h
BKE_bvhutils.h
+ BKE_cachefile.h
BKE_camera.h
BKE_ccg.h
BKE_cdderivedmesh.h
diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c
new file mode 100644
index 0000000..2d10318
--- /dev/null
+++ b/source/blender/blenkernel/intern/cachefile.c
@@ -0,0 +1,77 @@
+/*
+ * ***** 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) 2016 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Kevin Dietrich.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenkernel/intern/cachefile.c
+ * \ingroup bke
+ */
+
+#include "DNA_cachefile_types.h"
+#include "DNA_scene_types.h"
+
+#include "BLI_fileops.h"
+#include "BLI_path_util.h"
+#include "BLI_string.h"
+
+#include "BKE_cachefile.h"
+#include "BKE_library.h"
+#include "BKE_main.h"
+#include "BKE_scene.h"
+
+void *BKE_cachefile_add(Main *bmain, const char *name)
+{
+ CacheFile *cache_file = BKE_libblock_alloc(bmain, ID_CF, name);
+
+ cache_file->filepath[0] = '\0';
+ cache_file->frame_start = 0.0f;
+ cache_file->frame_scale = 1.0f;
+ cache_file->is_sequence = false;
+
+ return cache_file;
+}
+
+void BKE_cachefile_filepath_get(Scene *scene, CacheFile *cache_file, char *r_filepath)
+{
+ const float frame = BKE_scene_frame_get(scene);
+ BLI_strncpy(r_filepath, cache_file->filepath, 1024);
+
+ int fframe;
+ int frame_len;
+
+ if (cache_file->is_sequence && BLI_path_frame_get(r_filepath, &fframe, &frame_len)) {
+ char ext[32];
+ BLI_path_frame_strip(r_filepath, true, ext);
+ BLI_path_frame(r_filepath, frame, frame_len);
+ BLI_ensure_extension(r_filepath, 1024, ext);
+
+ if (!BLI_exists(r_filepath)) {
+ return;
+ }
+ }
+}
+
+float BKE_cachefile_time_offset(CacheFile *cache_file, float time)
+{
+ return (cache_file->frame_scale * time) - cache_file->frame_start;
+}
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index f762ca7..881b883 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -64,6 +64,7 @@
#include "BKE_anim.h" /* for the curve calculation part */
#include "BKE_armature.h"
#include "BKE_bvhutils.h"
+#include "BKE_cachefile.h"
#include "BKE_camera.h"
#include "BKE_constraint.h"
#include "BKE_curve.h"
@@ -4351,10 +4352,11 @@ static void transformcache_evaluate(bConstraint *con, bConstraintOb *cob, ListBa
bTransformCacheConstraint *data = con->data;
Scene *scene = cob->scene;
- const float ctime = BKE_scene_frame_get(scene) / (float)scene->r.frs_sec;
+ const float frame = BKE_scene_frame_get(scene);
+ const float time = BKE_cachefile_time_offset(data->cache_file, frame / FPS);
ABC_get_transform(cob->ob, data->cache_file->filepath, data->abc_object_path,
- cob->matrix, ctime, data->scale);
+ cob->matrix, time, data->scale);
UNUSED_VARS(targets);
}
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index ea63ffc..a3cc35e 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -3882,4 +3882,10 @@ void uiTemplateCacheFile(uiLayout *layout, bContext *C, PointerRNA *ptr, const c
row = uiLayoutRow(split, true);
uiItemR(row, &fileptr, "filepath", 0, "", ICON_NONE);
+
+ row = uiLayoutRow(layout, false);
+ uiItemR(row, &fileptr, "frame_start", 0, "Frame Start", ICON_NONE);
+
+ row = uiLayoutRow(layout, false);
+ uiItemR(row, &fileptr, "frame_scale", 0, "Frame Scale", ICON_NONE);
}
diff --git a/source/blender/makesdna/DNA_cachefile_types.h b/source/blender/makesdna/DNA_cachefile_types.h
index 2899cad..33bff80 100644
--- a/source/blender/makesdna/DNA_cachefile_types.h
+++ b/source/blender/makesdna/DNA_cachefile_types.h
@@ -42,6 +42,9 @@ typedef struct CacheFile {
char filepath[1024]; /* 1024 = FILE_MAX */
char is_sequence;
char pad[7];
+
+ float frame_start;
+ float frame_scale;
} CacheFile;
#ifdef __cplusplus
diff --git a/source/blender/makesrna/intern/rna_cachefile.c b/source/blender/makesrna/intern/rna_cachefile.c
index 0d9fb12..1c6da38 100644
--- a/source/blender/makesrna/intern/rna_cachefile.c
+++ b/source/blender/makesrna/intern/rna_cachefile.c
@@ -24,6 +24,7 @@
*/
#include "DNA_cachefile_types.h"
+#include "DNA_scene_types.h"
#include "RNA_define.h"
#include "RNA_access.h"
@@ -47,6 +48,20 @@ static void rna_def_cachefile(BlenderRNA *brna)
prop = RNA_def_property(srna, "is_sequence", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_ui_text(prop, "Sequence", "Whether the cache is separated in a series of files");
RNA_def_property_update(prop, 0, NULL);
+
+ /* ----------------- For Scene time ------------------- */
+
+ prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "frame_start");
+ RNA_def_property_range(prop, -MAXFRAME, MAXFRAME);
+ RNA_def_property_ui_text(prop, "Frame Start", "Add this to the start frame");
+ RNA_def_property_update(prop, 0, NULL);
+
+ prop = RNA_def_property(srna, "frame_scale", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "frame_scale");
+ RNA_def_property_range(prop, 0.0f, 100.0f);
+ RNA_def_property_ui_text(prop, "Frame Scale", "Evaluation time in seconds");
+ RNA_def_property_update(prop, 0, NULL);
}
void RNA_def_cachefile(BlenderRNA *brna)
diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c b/source/blender/modifiers/intern/MOD_meshsequencecache.c
index 3104a60..26c141d 100644
--- a/source/blender/modifiers/intern/MOD_meshsequencecache.c
+++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c
@@ -29,10 +29,7 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
-#include "BLI_fileops.h"
-#include "BLI_path_util.h"
-#include "BLI_string.h"
-
+#include "BKE_cachefile.h"
#include "BKE_DerivedMesh.h"
#include "BKE_library_query.h"
#include "BKE_scene.h"
@@ -76,25 +73,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *) md;
Scene *scene = md->scene;
- const float frame = BKE_scene_frame_get(scene);
- const float time = frame / FPS;
char filepath[1024];
- BLI_strncpy(filepath, mcmd->cache_file->filepath, 1024);
-
- int fframe;
- int frame_len;
+ BKE_cachefile_filepath_get(scene, mcmd->cache_file, filepath);
- if (mcmd->cache_file->is_sequence && BLI_path_frame_get(filepath, &fframe, &frame_len)) {
- char ext[32];
- BLI_path_frame_strip(filepath, true, ext);
- BLI_path_frame(filepath, frame, frame_len);
- BLI_ensure_extension(filepath, 1024, ext);
-
- if (!BLI_exists(filepath)) {
- return dm;
- }
- }
+ const float frame = BKE_scene_frame_get(scene);
+ const float time
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list