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 'intern/cycles/blender')
-rw-r--r--intern/cycles/blender/CMakeLists.txt1
-rw-r--r--intern/cycles/blender/blender_object.cpp3
-rw-r--r--intern/cycles/blender/blender_smoke.cpp96
-rw-r--r--intern/cycles/blender/blender_sync.h2
-rw-r--r--intern/cycles/blender/blender_util.h8
5 files changed, 110 insertions, 0 deletions
diff --git a/intern/cycles/blender/CMakeLists.txt b/intern/cycles/blender/CMakeLists.txt
index a8c7eef89fa..6e77daf6f8d 100644
--- a/intern/cycles/blender/CMakeLists.txt
+++ b/intern/cycles/blender/CMakeLists.txt
@@ -23,6 +23,7 @@ set(SRC
blender_mesh.cpp
blender_object.cpp
blender_particles.cpp
+ blender_smoke.cpp
blender_python.cpp
blender_session.cpp
blender_shader.cpp
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp
index 242f7c8ecef..fe6488efb3f 100644
--- a/intern/cycles/blender/blender_object.cpp
+++ b/intern/cycles/blender/blender_object.cpp
@@ -277,6 +277,9 @@ void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::Object b_ob,
/* particle sync */
if (object_use_particles(b_ob))
sync_particles(object, b_ob);
+
+ if(object_use_smoke(b_ob))
+ sync_smoke(object, b_ob);
object->tag_update(scene);
}
diff --git a/intern/cycles/blender/blender_smoke.cpp b/intern/cycles/blender/blender_smoke.cpp
new file mode 100644
index 00000000000..e59d9bea01d
--- /dev/null
+++ b/intern/cycles/blender/blender_smoke.cpp
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * 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.
+ */
+
+#include "object.h"
+
+#include "mesh.h"
+#include "blender_sync.h"
+#include "blender_util.h"
+
+#include "util_foreach.h"
+
+CCL_NAMESPACE_BEGIN
+
+/* Utilities */
+
+
+/* Smoke Sync */
+
+/* Only looking for Smoke domains */
+// TODO DG: disable rendering of smoke flow??
+bool BlenderSync::object_use_smoke(BL::Object b_ob)
+{
+ BL::Object::modifiers_iterator b_modifiers;
+ for(b_ob.modifiers.begin(b_modifiers); b_modifiers != b_ob.modifiers.end(); ++b_modifiers) {
+ BL::Modifier mod = (*b_modifiers);
+
+ if (mod.is_a(&RNA_SmokeModifier)) {
+ BL::SmokeModifier smd(mod);
+
+ if(smd.smoke_type() == BL::SmokeModifier::smoke_type_DOMAIN) {
+ BL::ID key = (BKE_object_is_modified(b_ob))? b_ob: b_ob.data();
+ Mesh *mesh = mesh_map.find(key);
+ if (mesh) {
+ return mesh->need_attribute(scene, ATTR_STD_SMOKE_DENSITY);
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+static BL::SmokeModifier *get_smoke(BL::Object b_ob)
+{
+ BL::Object::modifiers_iterator b_modifiers;
+ for(b_ob.modifiers.begin(b_modifiers); b_modifiers != b_ob.modifiers.end(); ++b_modifiers) {
+ BL::Modifier mod = (*b_modifiers);
+
+ if (mod.is_a(&RNA_SmokeModifier)) {
+ BL::SmokeModifier *smd = (BL::SmokeModifier *)(&mod);
+
+ if(smd->smoke_type() == BL::SmokeModifier::smoke_type_DOMAIN) {
+ return smd;
+ }
+ }
+ }
+
+ return NULL;
+}
+
+void BlenderSync::sync_smoke(Object *ob, BL::Object b_ob)
+{
+ BL::SmokeModifier *smd = get_smoke(b_ob);
+ BL::SmokeDomainSettings sds = smd->domain_settings();
+
+ ob->grid.clear();
+ ob->resolution = get_int3(sds.domain_resolution());
+
+ int length[3];
+ int numcells = rna_SmokeModifier_density_get_length(&sds.ptr, length);
+
+ if(numcells != 0)
+ {
+ vector<float> &grid = ob->grid;
+ grid.reserve(numcells);
+ grid.resize(numcells);
+ rna_SmokeModifier_density_get(&sds.ptr, &grid[0]);
+ }
+}
+
+CCL_NAMESPACE_END
diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h
index 1a6c04db10c..a82c9e29b43 100644
--- a/intern/cycles/blender/blender_sync.h
+++ b/intern/cycles/blender/blender_sync.h
@@ -86,10 +86,12 @@ private:
void sync_mesh_motion(BL::Object b_ob, Mesh *mesh, int motion);
void sync_camera_motion(BL::Object b_ob, int motion);
void sync_particles(Object *ob, BL::Object b_ob);
+ void sync_smoke(Object *ob, BL::Object b_ob);
/* util */
void find_shader(BL::ID id, vector<uint>& used_shaders, int default_shader);
bool BKE_object_is_modified(BL::Object b_ob);
+ bool object_use_smoke(BL::Object b_ob);
bool object_is_mesh(BL::Object b_ob);
bool object_is_light(BL::Object b_ob);
bool object_use_particles(BL::Object b_ob);
diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h
index ebbd4e1221c..3639d85c03a 100644
--- a/intern/cycles/blender/blender_util.h
+++ b/intern/cycles/blender/blender_util.h
@@ -56,6 +56,9 @@ void rna_Scene_frame_set(void *scene, int frame, float subframe);
void BKE_image_user_frame_calc(void *iuser, int cfra, int fieldnr);
void BKE_image_user_file_path(void *iuser, void *ima, char *path);
+int rna_SmokeModifier_density_get_length(PointerRNA *ptr, int length[3]);
+void rna_SmokeModifier_density_get(PointerRNA *ptr, float *values);
+
}
CCL_NAMESPACE_BEGIN
@@ -155,6 +158,11 @@ static inline int4 get_int4(BL::Array<int, 4> array)
return make_int4(array[0], array[1], array[2], array[3]);
}
+static inline int3 get_int3(BL::Array<int, 3> array)
+{
+ return make_int3(array[0], array[1], array[2]);
+}
+
static inline uint get_layer(BL::Array<int, 20> array)
{
uint layer = 0;