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:
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_cloth.py25
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_common.py105
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py23
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_smoke.py14
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_softbody.py26
-rw-r--r--release/scripts/startup/bl_ui/properties_scene.py19
-rw-r--r--source/blender/blenkernel/BKE_cloth.h3
-rw-r--r--source/blender/blenkernel/BKE_dynamicpaint.h1
-rw-r--r--source/blender/blenkernel/BKE_pointcache.h341
-rw-r--r--source/blender/blenkernel/BKE_rigidbody.h1
-rw-r--r--source/blender/blenkernel/CMakeLists.txt2
-rw-r--r--source/blender/blenkernel/intern/bpath.c29
-rw-r--r--source/blender/blenkernel/intern/cloth.c78
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c56
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c49
-rw-r--r--source/blender/blenkernel/intern/object.c31
-rw-r--r--source/blender/blenkernel/intern/pointcache.c3765
-rw-r--r--source/blender/blenkernel/intern/rigidbody.c91
-rw-r--r--source/blender/blenkernel/intern/smoke.c45
-rw-r--r--source/blender/blenkernel/intern/softbody.c59
-rw-r--r--source/blender/blenloader/intern/readfile.c109
-rw-r--r--source/blender/blenloader/intern/versioning_250.c2
-rw-r--r--source/blender/blenloader/intern/versioning_260.c3
-rw-r--r--source/blender/blenloader/intern/versioning_legacy.c19
-rw-r--r--source/blender/blenloader/intern/writefile.c72
-rw-r--r--source/blender/editors/object/object_edit.c13
-rw-r--r--source/blender/editors/physics/CMakeLists.txt1
-rw-r--r--source/blender/editors/physics/physics_intern.h9
-rw-r--r--source/blender/editors/physics/physics_ops.c28
-rw-r--r--source/blender/editors/physics/physics_pointcache.c464
-rw-r--r--source/blender/editors/space_time/space_time.c154
-rw-r--r--source/blender/editors/space_view3d/drawobject.c5
-rw-r--r--source/blender/editors/transform/transform_conversions.c14
-rw-r--r--source/blender/editors/transform/transform_manipulator.c1
-rw-r--r--source/blender/makesdna/DNA_dynamicpaint_types.h2
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h3
-rw-r--r--source/blender/makesdna/DNA_object_force.h109
-rw-r--r--source/blender/makesdna/DNA_rigidbody_types.h3
-rw-r--r--source/blender/makesdna/DNA_smoke_types.h3
-rw-r--r--source/blender/makesrna/RNA_access.h1
-rw-r--r--source/blender/makesrna/intern/rna_dynamicpaint.c30
-rw-r--r--source/blender/makesrna/intern/rna_fluidsim.c1
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c16
-rw-r--r--source/blender/makesrna/intern/rna_object_force.c366
-rw-r--r--source/blender/makesrna/intern/rna_rigidbody.c17
-rw-r--r--source/blender/makesrna/intern/rna_scene.c12
-rw-r--r--source/blender/makesrna/intern/rna_sculpt_paint.c1
-rw-r--r--source/blender/makesrna/intern/rna_smoke.c79
-rw-r--r--source/blender/modifiers/intern/MOD_cloth.c13
-rw-r--r--source/blender/modifiers/intern/MOD_collision.c2
-rw-r--r--source/blender/render/intern/source/pipeline.c28
-rw-r--r--source/blender/render/intern/source/voxeldata.c6
52 files changed, 84 insertions, 6265 deletions
diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py b/release/scripts/startup/bl_ui/properties_physics_cloth.py
index a5cbffb2e2c..28a8858a61e 100644
--- a/release/scripts/startup/bl_ui/properties_physics_cloth.py
+++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py
@@ -21,15 +21,10 @@ import bpy
from bpy.types import Menu, Panel
from bl_ui.properties_physics_common import (
- point_cache_ui,
effector_weights_ui,
)
-def cloth_panel_enabled(md):
- return md.point_cache.is_baked is False
-
-
class CLOTH_MT_presets(Menu):
bl_label = "Cloth Presets"
preset_subdir = "cloth"
@@ -61,8 +56,6 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel):
split = layout.split()
- split.active = cloth_panel_enabled(md)
-
col = split.column()
col.label(text="Presets:")
@@ -110,15 +103,6 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel):
col.prop_search(cloth, "rest_shape_key", key, "key_blocks", text="")
-class PHYSICS_PT_cloth_cache(PhysicButtonsPanel, Panel):
- bl_label = "Cloth Cache"
- bl_options = {'DEFAULT_CLOSED'}
-
- def draw(self, context):
- md = context.cloth
- point_cache_ui(self, context, md.point_cache, cloth_panel_enabled(md), 'CLOTH')
-
-
class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, Panel):
bl_label = "Cloth Collision"
bl_options = {'DEFAULT_CLOSED'}
@@ -126,7 +110,6 @@ class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, Panel):
def draw_header(self, context):
cloth = context.cloth.collision_settings
- self.layout.active = cloth_panel_enabled(context.cloth)
self.layout.prop(cloth, "use_collision", text="")
def draw(self, context):
@@ -136,7 +119,7 @@ class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, Panel):
md = context.cloth
ob = context.object
- layout.active = cloth.use_collision and cloth_panel_enabled(md)
+ layout.active = cloth.use_collision
split = layout.split()
@@ -165,7 +148,6 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel):
def draw_header(self, context):
cloth = context.cloth.settings
- self.layout.active = cloth_panel_enabled(context.cloth)
self.layout.prop(cloth, "use_stiffness_scale", text="")
def draw(self, context):
@@ -175,7 +157,7 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel):
ob = context.object
cloth = context.cloth.settings
- layout.active = (cloth.use_stiffness_scale and cloth_panel_enabled(md))
+ layout.active = cloth.use_stiffness_scale
split = layout.split()
@@ -197,7 +179,6 @@ class PHYSICS_PT_cloth_sewing(PhysicButtonsPanel, Panel):
def draw_header(self, context):
cloth = context.cloth.settings
- self.layout.active = cloth_panel_enabled(context.cloth)
self.layout.prop(cloth, "use_sewing_springs", text="")
def draw(self, context):
@@ -207,7 +188,7 @@ class PHYSICS_PT_cloth_sewing(PhysicButtonsPanel, Panel):
ob = context.object
cloth = context.cloth.settings
- layout.active = (cloth.use_sewing_springs and cloth_panel_enabled(md))
+ layout.active = cloth.use_sewing_springs
layout.prop(cloth, "sewing_force_max", text="Sewing Force")
diff --git a/release/scripts/startup/bl_ui/properties_physics_common.py b/release/scripts/startup/bl_ui/properties_physics_common.py
index 04cb592a0d1..a3a5c503908 100644
--- a/release/scripts/startup/bl_ui/properties_physics_common.py
+++ b/release/scripts/startup/bl_ui/properties_physics_common.py
@@ -97,111 +97,6 @@ class PHYSICS_PT_add(PhysicButtonsPanel, Panel):
'CONSTRAINT') # RB_TODO needs better icon
-# cache-type can be 'CLOTH', 'SMOKE' etc
-
-def point_cache_ui(self, context, cache, enabled, cachetype):
- layout = self.layout
-
- layout.context_pointer_set("point_cache", cache)
-
- if not cachetype == 'RIGID_BODY':
- row = layout.row()
- row.template_list("UI_UL_list", "point_caches", cache, "point_caches",
- cache.point_caches, "active_index", rows=1)
- col = row.column(align=True)
- col.operator("ptcache.add", icon='ZOOMIN', text="")
- col.operator("ptcache.remove", icon='ZOOMOUT', text="")
-
- row = layout.row()
- if cachetype == 'SMOKE':
- row.prop(cache, "use_external")
- row.prop(cache, "use_library_path", "Use Lib Path")
-
- if cache.use_external:
- split = layout.split(percentage=0.35)
- col = split.column()
- col.label(text="Index Number:")
- col.label(text="File Path:")
-
- col = split.column()
- col.prop(cache, "index", text="")
- col.prop(cache, "filepath", text="")
-
- cache_info = cache.info
- if cache_info:
- layout.label(text=cache_info)
- else:
- if cachetype in {'SMOKE', 'DYNAMIC_PAINT'}:
- if not bpy.data.is_saved:
- layout.label(text="Cache is disabled until the file is saved")
- layout.enabled = False
-
- if not cache.use_external or cachetype == 'SMOKE':
- row = layout.row(align=True)
-
- if cachetype != 'DYNAMIC_PAINT':
- row.enabled = enabled
- row.prop(cache, "frame_start")
- row.prop(cache, "frame_end")
- if cachetype not in {'SMOKE', 'CLOTH', 'DYNAMIC_PAINT', 'RIGID_BODY'}:
- row.prop(cache, "frame_step")
-
- if cachetype != 'SMOKE':
- layout.label(text=cache.info)
-
- can_bake = True
-
- if cachetype not in {'SMOKE', 'DYNAMIC_PAINT', 'RIGID_BODY'}:
- split = layout.split()
- split.enabled = enabled and bpy.data.is_saved
-
- col = split.column()
- col.prop(cache, "use_disk_cache")
-
- col = split.column()
- col.active = cache.use_disk_cache
- col.prop(cache, "use_library_path", "Use Lib Path")
-
- row = layout.row()
- row.enabled = enabled and bpy.data.is_saved
- row.active = cache.use_disk_cache
- row.label(text="Compression:")
- row.prop(cache, "compression", expand=True)
-
- layout.separator()
-
- if cache.id_data.library and not cache.use_disk_cache:
- can_bake = False
-
- col = layout.column(align=True)
- col.label(text="Linked object baking requires Disk Cache to be enabled", icon='INFO')
- else:
- layout.separator()
-
- split = layout.split()
- split.active = can_bake
-
- col = split.column()
-
- if cache.is_baked is True:
- col.operator("ptcache.free_bake", text="Free Bake")
- else:
- col.operator("ptcache.bake", text="Bake").bake = True
-
- sub = col.row()
- sub.enabled = (cache.is_frame_skip or cache.is_outdated) and enabled
- sub.operator("ptcache.bake", text="Calculate To Frame").bake = False
-
- sub = col.column()
- sub.enabled = enabled
- sub.operator("ptcache.bake_from_cache", text="Current Cache to Bake")
-
- col = split.column()
- col.operator("ptcache.bake_all", text="Bake All Dynamics").bake = True
- col.operator("ptcache.free_bake_all", text="Free All Bakes")
- col.operator("ptcache.bake_all", text="Update All To Frame").bake = False
-
-
def effector_weights_ui(self, context, weights, weight_type):
layout = self.layout
diff --git a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
index 87ec206de08..bba13a90aa2 100644
--- a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
+++ b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
@@ -21,7 +21,6 @@ import bpy
from bpy.types import Panel, UIList
from bl_ui.properties_physics_common import (
- point_cache_ui,
effector_weights_ui,
)
@@ -386,28 +385,6 @@ class PHYSICS_PT_dp_effects(PhysicButtonsPanel, Panel):
row.prop(surface, "shrink_speed")
-class PHYSICS_PT_dp_cache(PhysicButtonsPanel, Panel):
- bl_label = "Dynamic Paint Cache"
- bl_options = {'DEFAULT_CLOSED'}
-
- @classmethod
- def poll(cls, context):
- md = context.dynamic_paint
- rd = context.scene.render
- return (md and
- md.ui_type == 'CANVAS' and
- md.canvas_settings and
- md.canvas_settings.canvas_surfaces.active and
- md.canvas_settings.canvas_surfaces.active.is_cache_user and
- (not rd.use_game_engine))
-
- def draw(self, context):
- surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active
- cache = surface.point_cache
-
- point_cache_ui(self, context, cache, (cache.is_baked is False), 'DYNAMIC_PAINT')
-
-
class PHYSICS_PT_dp_brush_source(PhysicButtonsPanel, Panel):
bl_label = "Dynamic Paint Source"
diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py b/release/scripts/startup/bl_ui/properties_physics_smoke.py
index 4d5ee0c5742..5c98cb45bac 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -21,7 +21,6 @@ import bpy
from bpy.types import Panel
from bl_ui.properties_physics_common import (
- point_cache_ui,
effector_weights_ui,
)
@@ -54,8 +53,6 @@ class PHYSICS_PT_smoke(PhysicButtonsPanel, Panel):
split = layout.split()
- split.enabled = not domain.point_cache.is_baked
-
col = split.column()
col.label(text="Resolution:")
col.prop(domain, "resolution_max", text="Divisions")
@@ -169,7 +166,6 @@ class PHYSICS_PT_smoke_fire(PhysicButtonsPanel, Panel):
domain = context.smoke.domain_settings
split = layout.split()
- split.enabled = not domain.point_cache.is_baked
col = split.column(align=True)
col.label(text="Reaction:")
@@ -205,7 +201,6 @@ class PHYSICS_PT_smoke_adaptive_domain(PhysicButtonsPanel, Panel):
layout.active = domain.use_adaptive_domain
split = layout.split()
- split.enabled = (not domain.point_cache.is_baked)
col = split.column(align=True)
col.label(text="Resolution:")
@@ -240,7 +235,6 @@ class PHYSICS_PT_smoke_highres(PhysicButtonsPanel, Panel):
layout.active = md.use_high_resolution
split = layout.split()
- split.enabled = not md.point_cache.is_baked
col = split.column()
col.label(text="Resolution:")
@@ -302,10 +296,7 @@ class PHYSICS_PT_smoke_cache(PhysicButtonsPanel, Panel):
layout.prop(domain, "cache_file_format")
- if cache_file_format == 'POINTCACHE':
- layout.label(text="Compression:")
- layout.prop(domain, "point_cache_compress_type", expand=True)
- elif cache_file_format == 'OPENVDB':
+ if cache_file_format == 'OPENVDB':
if not bpy.app.build_options.openvdb:
layout.label("Built without OpenVDB support")
return
@@ -316,9 +307,6 @@ class PHYSICS_PT_smoke_cache(PhysicButtonsPanel, Panel):
row.label("Data Depth:")
row.prop(domain, "data_depth", expand=True, text="Data Depth")
- cache = domain.point_cache
- point_cache_ui(self, context, cache, (cache.is_baked is False), 'SMOKE')
-
class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel, Panel):
bl_label = "Smoke Field Weights"
diff --git a/release/scripts/startup/bl_ui/properties_physics_softbody.py b/release/scripts/startup/bl_ui/properties_physics_softbody.py
index e74cac3d06b..32f220ce7c1 100644
--- a/release/scripts/startup/bl_ui/properties_physics_softbody.py
+++ b/release/scripts/startup/bl_ui/properties_physics_softbody.py
@@ -21,15 +21,10 @@ import bpy
from bpy.types import Panel
from bl_ui.properties_physics_common import (
- point_cache_ui,
effector_weights_ui,
)
-def softbody_panel_enabled(md):
- return (md.point_cache.is_baked is False)
-
-
class PhysicButtonsPanel:
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
@@ -55,7 +50,6 @@ class PHYSICS_PT_softbody(PhysicButtonsPanel, Panel):
# General
split = layout.split()
- split.enabled = softbody_panel_enabled(md)
col = split.column()
col.label(text="Object:")
@@ -68,15 +62,6 @@ class PHYSICS_PT_softbody(PhysicButtonsPanel, Panel):
col.prop(softbody, "speed")
-class PHYSICS_PT_softbody_cache(PhysicButtonsPanel, Panel):
- bl_label = "Soft Body Cache"
- bl_options = {'DEFAULT_CLOSED'}
-
- def draw(self, context):
- md = context.soft_body
- point_cache_ui(self, context, md.point_cache, softbody_panel_enabled(md), 'SOFTBODY')
-
-
class PHYSICS_PT_softbody_goal(PhysicButtonsPanel, Panel):
bl_label = "Soft Body Goal"
bl_options = {'DEFAULT_CLOSED'}
@@ -84,7 +69,6 @@ class PHYSICS_PT_softbody_goal(PhysicButtonsPanel, Panel):
def draw_header(self, context):
softbody = context.soft_body.settings
- self.layout.active = softbody_panel_enabled(context.soft_body)
self.layout.prop(softbody, "use_goal", text="")
def draw(self, context):
@@ -94,7 +78,7 @@ class PHYSICS_PT_softbody_goal(PhysicButtonsPanel, Panel):
softbody = md.settings
ob = context.object
- layout.active = softbody.use_goal and softbody_panel_enabled(md)
+ layout.active = softbody.use_goal
split = layout.split()
@@ -123,7 +107,6 @@ class PHYSICS_PT_softbody_edge(PhysicButtonsPanel, Panel):
def draw_header(self, context):
softbody = context.soft_body.settings
- self.layout.active = softbody_panel_enabled(context.soft_body)
self.layout.prop(softbody, "use_edges", text="")
def draw(self, context):
@@ -133,7 +116,7 @@ class PHYSICS_PT_softbody_edge(PhysicButtonsPanel, Panel):
softbody = md.settings
ob = context.object
- layout.active = softbody.use_edges and softbody_panel_enabled(md)
+ layout.active = softbody.use_edges
split = layout.split()
@@ -172,7 +155,6 @@ class PHYSICS_PT_softbody_collision(PhysicButtonsPanel, Panel):
def draw_header(self, context):
softbody = context.soft_body.settings
- self.layout.active = softbody_panel_enabled(context.soft_body)
self.layout.prop(softbody, "use_self_collision", text="")
def draw(self, context):
@@ -181,7 +163,7 @@ class PHYSICS_PT_softbody_collision(PhysicButtonsPanel, Panel):
md = context.soft_body
softbody = md.settings
- layout.active = softbody.use_self_collision and softbody_panel_enabled(md)
+ layout.active = softbody.use_self_collision
layout.label(text="Collision Ball Size Calculation:")
layout.prop(softbody, "collision_type", expand=True)
@@ -203,8 +185,6 @@ class PHYSICS_PT_softbody_solver(PhysicButtonsPanel, Panel):
md = context.soft_body
softbody = md.settings
- layout.active = softbody_panel_enabled(md)
-
# Solver
split = layout.split()
diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py
index 069b27701c8..7b7e2367a42 100644
--- a/release/scripts/startup/bl_ui/properties_scene.py
+++ b/release/scripts/startup/bl_ui/properties_scene.py
@@ -27,7 +27,6 @@ from bpy.types import (
from rna_prop_ui import PropertyPanel
from bl_ui.properties_physics_common import (
- point_cache_ui,
effector_weights_ui,
)
@@ -371,24 +370,6 @@ class SCENE_PT_rigid_body_world(SceneButtonsPanel, Panel):
col.prop(rbw, "solver_iterations", text="Solver Iterations")
-class SCENE_PT_rigid_body_cache(SceneButtonsPanel, Panel):
- bl_label = "Rigid Body Cache"
- bl_options = {'DEFAULT_CLOSED'}
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- @classmethod
- def poll(cls, context):
- rd = context.scene.render
- scene = context.scene
- return scene and scene.rigidbody_world and (rd.engine in cls.COMPAT_ENGINES)
-
- def draw(self, context):
- scene = context.scene
- rbw = scene.rigidbody_world
-
- point_cache_ui(self, context, rbw.point_cache, rbw.point_cache.is_baked is False and rbw.enabled, 'RIGID_BODY')
-
-
class SCENE_PT_rigid_body_field_weights(SceneButtonsPanel, Panel):
bl_label = "Rigid Body Field Weights"
bl_options = {'DEFAULT_CLOSED'}
diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h
index 28de270bbd1..38ee690b857 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -236,9 +236,6 @@ int cloth_uses_vgroup(struct ClothModifierData *clmd);
void bvhtree_update_from_cloth(struct ClothModifierData *clmd, bool moving);
void bvhselftree_update_from_cloth(struct ClothModifierData *clmd, bool moving);
-// needed for button_object.c
-void cloth_clear_cache (struct Object *ob, struct ClothModifierData *clmd, float framenr );
-
// needed for cloth.c
int cloth_add_spring (struct ClothModifierData *clmd, unsigned int indexA, unsigned int indexB, float restlength, int spring_type);
diff --git a/source/blender/blenkernel/BKE_dynamicpaint.h b/source/blender/blenkernel/BKE_dynamicpaint.h
index 00256176d98..142ef1893ce 100644
--- a/source/blender/blenkernel/BKE_dynamicpaint.h
+++ b/source/blender/blenkernel/BKE_dynamicpaint.h
@@ -73,7 +73,6 @@ void dynamicPaint_freeCanvas(struct DynamicPaintModifierData *pmd);
void dynamicPaint_freeBrush(struct DynamicPaintModifierData *pmd);
void dynamicPaint_freeSurfaceData(struct DynamicPaintSurface *surface);
-void dynamicPaint_cacheUpdateFrames(struct DynamicPaintSurface *surface);
bool dynamicPaint_surfaceHasColorPreview(struct DynamicPaintSurface *surface);
bool dynamicPaint_outputLayerExists(struct DynamicPaintSurface *surface, struct Object *ob, int output);
void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface);
diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h
deleted file mode 100644
index c0ddfa35748..00000000000
--- a/source/blender/blenkernel/BKE_pointcache.h
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * ***** 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) 2006 Blender Foundation.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Campbell Barton <ideasman42@gmail.com>
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifndef __BKE_POINTCACHE_H__
-#define __BKE_POINTCACHE_H__
-
-/** \file BKE_pointcache.h
- * \ingroup bke
- */
-
-#include "DNA_ID.h"
-#include "DNA_dynamicpaint_types.h"
-#include "DNA_object_force.h"
-#include <stdio.h> /* for FILE */
-
-/* Point cache clearing option, for BKE_ptcache_id_clear, before
- * and after are non inclusive (they wont remove the cfra) */
-#define PTCACHE_CLEAR_ALL 0
-#define PTCACHE_CLEAR_FRAME 1
-#define PTCACHE_CLEAR_BEFORE 2
-#define PTCACHE_CLEAR_AFTER 3
-
-/* Point cache reset options */
-#define PTCACHE_RESET_DEPSGRAPH 0
-#define PTCACHE_RESET_BAKED 1
-#define PTCACHE_RESET_OUTDATED 2
-/* #define PTCACHE_RESET_FREE 3 */ /*UNUSED*/
-
-/* Add the blendfile name after blendcache_ */
-#define PTCACHE_EXT ".bphys"
-#define PTCACHE_PATH "blendcache_"
-
-/* File open options, for BKE_ptcache_file_open */
-#define PTCACHE_FILE_READ 0
-#define PTCACHE_FILE_WRITE 1
-#define PTCACHE_FILE_UPDATE 2
-
-/* PTCacheID types */
-#define PTCACHE_TYPE_SOFTBODY 0
-#define PTCACHE_TYPE_CLOTH 1
-#define PTCACHE_TYPE_SMOKE_DOMAIN 2
-#define PTCACHE_TYPE_SMOKE_HIGHRES 3
-#define PTCACHE_TYPE_DYNAMICPAINT 4
-#define PTCACHE_TYPE_RIGIDBODY 5
-
-/* high bits reserved for flags that need to be stored in file */
-#define PTCACHE_TYPEFLAG_COMPRESS (1 << 16)
-#define PTCACHE_TYPEFLAG_EXTRADATA (1 << 17)
-
-#define PTCACHE_TYPEFLAG_TYPEMASK 0x0000FFFF
-#define PTCACHE_TYPEFLAG_FLAGMASK 0xFFFF0000
-
-/* PTCache read return code */
-#define PTCACHE_READ_EXACT 1
-#define PTCACHE_READ_INTERPOLATED 2
-#define PTCACHE_READ_OLD 3
-
-/* Structs */
-struct ClothModifierData;
-struct ListBase;
-struct Main;
-struct Object;
-struct PointCacheKey;
-struct PointCache;
-struct Scene;
-struct SmokeModifierData;
-struct SoftBody;
-struct RigidBodyWorld;
-
-struct OpenVDBReader;
-struct OpenVDBWriter;
-
-/* temp structure for read/write */
-typedef struct PTCacheData {
- unsigned int index;
- float loc[3];
- float vel[3];
- float rot[4];
- float ave[3];
- float size;
- float times[3];
-} PTCacheData;
-
-typedef struct PTCacheFile {
- FILE *fp;
-
- int frame, old_format;
- unsigned int totpoint, type;
- unsigned int data_types, flag;
-
- struct PTCacheData data;
- void *cur[BPHYS_TOT_DATA];
-} PTCacheFile;
-
-#define PTCACHE_VEL_PER_SEC 1
-
-enum {
- PTCACHE_FILE_PTCACHE = 0,
- PTCACHE_FILE_OPENVDB = 1,
-};
-
-typedef struct PTCacheID {
- struct PTCacheID *next, *prev;
-
- struct Scene *scene;
- struct Object *ob;
- void *calldata;
- unsigned int type, file_type;
- unsigned int stack_index;
- unsigned int flag;
-
- unsigned int default_step;
- unsigned int max_step;
-
- /* flags defined in DNA_object_force.h */
- unsigned int data_types, info_types;
-
- /* copies point data to cache data */
- int (*write_point)(int index, void *calldata, void **data, int cfra);
- /* copies cache cata to point data */
- void (*read_point)(int index, void *calldata, void **data, float cfra, float *old_data);
- /* interpolated between previously read point data and cache data */
- void (*interpolate_point)(int index, void *calldata, void **data, float cfra, float cfra1, float cfra2, float *old_data);
-
- /* copies point data to cache data */
- int (*write_stream)(PTCacheFile *pf, void *calldata);
- /* copies cache cata to point data */
- int (*read_stream)(PTCacheFile *pf, void *calldata);
-
- /* copies point data to cache data */
- int (*write_openvdb_stream)(struct OpenVDBWriter *writer, void *calldata);
- /* copies cache cata to point data */
- int (*read_openvdb_stream)(struct OpenVDBReader *reader, void *calldata);
-
- /* copies custom extradata to cache data */
- void (*write_extra_data)(void *calldata, struct PTCacheMem *pm, int cfra);
- /* copies custom extradata to cache data */
- void (*read_extra_data)(void *calldata, struct PTCacheMem *pm, float cfra);
- /* copies custom extradata to cache data */
- void (*interpolate_extra_data)(void *calldata, struct PTCacheMem *pm, float cfra, float cfra1, float cfra2);
-
- /* total number of simulated points (the cfra parameter is just for using same function pointer with totwrite) */
- int (*totpoint)(void *calldata, int cfra);
- /* report error if number of points does not match */
- void (*error)(void *calldata, const char *message);
- /* number of points written for current cache frame */
- int (*totwrite)(void *calldata, int cfra);
-
- int (*write_header)(PTCacheFile *pf);
- int (*read_header)(PTCacheFile *pf);
-
- struct PointCache *cache;
- /* used for setting the current cache from ptcaches list */
- struct PointCache **cache_ptr;
- struct ListBase *ptcaches;
-} PTCacheID;
-
-typedef struct PTCacheBaker {
- struct Main *main;
- struct Scene *scene;
- int bake;
- int render;
- int anim_init;
- int quick_step;
- struct PTCacheID pid;
-
- void (*update_progress)(void *data, float progress, int *cancel);
- void *bake_job;
-} PTCacheBaker;
-
-/* PTCacheEditKey->flag */
-#define PEK_SELECT 1
-#define PEK_TAG 2
-#define PEK_HIDE 4
-#define PEK_USE_WCO 8
-
-typedef struct PTCacheEditKey {
- float *co;
- float *vel;
- float *rot;
- float *time;
-
- float world_co[3];
- float ftime;
- float length;
- short flag;
-} PTCacheEditKey;
-
-/* PTCacheEditPoint->flag */
-#define PEP_TAG 1
-#define PEP_EDIT_RECALC 2
-#define PEP_TRANSFORM 4
-#define PEP_HIDE 8
-
-typedef struct PTCacheEditPoint {
- struct PTCacheEditKey *keys;
- int totkey;
- short flag;
-} PTCacheEditPoint;
-
-typedef struct PTCacheUndo {
- struct PTCacheUndo *next, *prev;
- struct PTCacheEditPoint *points;
-
- /* particles stuff */
- struct ParticleData *particles;
- struct KDTree *emitter_field;
- float *emitter_cosnos;
- int psys_flag;
-
- /* cache stuff */
- struct ListBase mem_cache;
-
- int totpoint;
- char name[64];
-} PTCacheUndo;
-
-typedef struct PTCacheEdit {
- ListBase undo;
- struct PTCacheUndo *curundo;
- PTCacheEditPoint *points;
-
- struct PTCacheID pid;
-
- int totpoint, totframes, totcached, edited;
-
- unsigned char sel_col[3];
- unsigned char nosel_col[3];
-} PTCacheEdit;
-
-typedef struct PointCacheKey {
- float co[3]; /* location */
- float vel[3]; /* velocity */
- float rot[4]; /* rotation quaternion */
- float ave[3]; /* angular velocity */
- float time; /* when this key happens */
-} PointCacheKey;
-
-void BKE_ptcache_make_key(struct PointCacheKey *key, int index, void **data, float time);
-
-/**************** Creating ID's ****************************/
-void BKE_ptcache_id_from_softbody(PTCacheID *pid, struct Object *ob, struct SoftBody *sb);
-void BKE_ptcache_id_from_cloth(PTCacheID *pid, struct Object *ob, struct ClothModifierData *clmd);
-void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd);
-void BKE_ptcache_id_from_dynamicpaint(PTCacheID *pid, struct Object *ob, struct DynamicPaintSurface *surface);
-void BKE_ptcache_id_from_rigidbody(PTCacheID *pid, struct Object *ob, struct RigidBodyWorld *rbw);
-
-void BKE_ptcache_ids_from_object(struct ListBase *lb, struct Object *ob, struct Scene *scene, int duplis);
-
-/***************** Global funcs ****************************/
-void BKE_ptcache_remove(void);
-
-/************ ID specific functions ************************/
-void BKE_ptcache_id_clear(PTCacheID *id, int mode, unsigned int cfra);
-int BKE_ptcache_id_exist(PTCacheID *id, int cfra);
-int BKE_ptcache_id_reset(struct Scene *scene, PTCacheID *id, int mode);
-void BKE_ptcache_id_time(PTCacheID *pid, struct Scene *scene, float cfra, int *startframe, int *endframe, float *timescale);
-int BKE_ptcache_object_reset(struct Scene *scene, struct Object *ob, int mode);
-
-void BKE_ptcache_update_info(PTCacheID *pid);
-
-/*********** General cache reading/writing ******************/
-
-/* Size of cache data type. */
-int BKE_ptcache_data_size(int data_type);
-
-/* Is point with indes in memory cache */
-int BKE_ptcache_mem_index_find(struct PTCacheMem *pm, unsigned int index);
-
-/* Memory cache read/write helpers. */
-void BKE_ptcache_mem_pointers_init(struct PTCacheMem *pm);
-void BKE_ptcache_mem_pointers_incr(struct PTCacheMem *pm);
-int BKE_ptcache_mem_pointers_seek(int point_index, struct PTCacheMem *pm);
-
-/* Main cache reading call. */
-int BKE_ptcache_read(PTCacheID *pid, float cfra);
-
-/* Main cache writing call. */
-int BKE_ptcache_write(PTCacheID *pid, unsigned int cfra);
-
-/******************* Allocate & free ***************/
-struct PointCache *BKE_ptcache_add(struct ListBase *ptcaches);
-void BKE_ptcache_free_mem(struct ListBase *mem_cache);
-void BKE_ptcache_free(struct PointCache *cache);
-void BKE_ptcache_free_list(struct ListBase *ptcaches);
-struct PointCache *BKE_ptcache_copy_list(struct ListBase *ptcaches_new, const struct ListBase *ptcaches_old, bool copy_data);
-
-/********************** Baking *********************/
-
-/* Bakes cache with cache_step sized jumps in time, not accurate but very fast. */
-void BKE_ptcache_quick_cache_all(struct Main *bmain, struct Scene *scene);
-
-/* Bake cache or simulate to current frame with settings defined in the baker. */
-void BKE_ptcache_bake(struct PTCacheBaker *baker);
-
-/* Convert disk cache to memory cache. */
-void BKE_ptcache_disk_to_mem(struct PTCacheID *pid);
-
-/* Convert memory cache to disk cache. */
-void BKE_ptcache_mem_to_disk(struct PTCacheID *pid);
-
-/* Convert disk cache to memory cache and vice versa. Clears the cache that was converted. */
-void BKE_ptcache_toggle_disk_cache(struct PTCacheID *pid);
-
-/* Rename all disk cache files with a new name. Doesn't touch the actual content of the files. */
-void BKE_ptcache_disk_cache_rename(struct PTCacheID *pid, const char *name_src, const char *name_dst);
-
-/* Loads simulation from external (disk) cache files. */
-void BKE_ptcache_load_external(struct PTCacheID *pid);
-
-/* Set correct flags after successful simulation step */
-void BKE_ptcache_validate(struct PointCache *cache, int framenr);
-
-/* Set correct flags after unsuccessful simulation step */
-void BKE_ptcache_invalidate(struct PointCache *cache);
-
-#endif
diff --git a/source/blender/blenkernel/BKE_rigidbody.h b/source/blender/blenkernel/BKE_rigidbody.h
index 272abc42899..6731356a5af 100644
--- a/source/blender/blenkernel/BKE_rigidbody.h
+++ b/source/blender/blenkernel/BKE_rigidbody.h
@@ -99,7 +99,6 @@ void BKE_rigidbody_remove_constraint(struct Scene *scene, struct Object *ob);
void BKE_rigidbody_aftertrans_update(struct Object *ob, float loc[3], float rot[3], float quat[4], float rotAxis[3], float rotAngle);
void BKE_rigidbody_sync_transforms(struct RigidBodyWorld *rbw, struct Object *ob, float ctime);
bool BKE_rigidbody_check_sim_running(struct RigidBodyWorld *rbw, float ctime);
-void BKE_rigidbody_cache_reset(struct RigidBodyWorld *rbw);
void BKE_rigidbody_rebuild_world(struct Scene *scene, float ctime);
void BKE_rigidbody_do_simulation(struct Scene *scene, float ctime);
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index b8a6b230a02..f051ca7f07e 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -149,7 +149,6 @@ set(SRC
intern/paint.c
intern/pbvh.c
intern/pbvh_bmesh.c
- intern/pointcache.c
intern/property.c
intern/report.c
intern/rigidbody.c
@@ -260,7 +259,6 @@ set(SRC
BKE_packedFile.h
BKE_paint.h
BKE_pbvh.h
- BKE_pointcache.h
BKE_property.h
BKE_report.h
BKE_rigidbody.h
diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c
index 37ecbb383e5..e338974eca6 100644
--- a/source/blender/blenkernel/intern/bpath.c
+++ b/source/blender/blenkernel/intern/bpath.c
@@ -462,19 +462,6 @@ void BKE_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int
Object *ob = (Object *)id;
ModifierData *md;
-#define BPATH_TRAVERSE_POINTCACHE(ptcaches) \
- { \
- PointCache *cache; \
- for (cache = (ptcaches).first; cache; cache = cache->next) { \
- if (cache->flag & PTCACHE_DISK_CACHE) { \
- rewrite_path_fixed(cache->path, \
- visit_cb, \
- absbase, \
- bpath_user_data); \
- } \
- } \
- } (void)0
-
/* do via modifiers instead */
#if 0
if (ob->fluidsimSettings) {
@@ -489,16 +476,6 @@ void BKE_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int
rewrite_path_fixed(fluidmd->fss->surfdataPath, visit_cb, absbase, bpath_user_data);
}
}
- else if (md->type == eModifierType_Smoke) {
- SmokeModifierData *smd = (SmokeModifierData *)md;
- if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
- BPATH_TRAVERSE_POINTCACHE(smd->domain->ptcaches[0]);
- }
- }
- else if (md->type == eModifierType_Cloth) {
- ClothModifierData *clmd = (ClothModifierData *) md;
- BPATH_TRAVERSE_POINTCACHE(clmd->ptcaches);
- }
else if (md->type == eModifierType_Ocean) {
OceanModifierData *omd = (OceanModifierData *) md;
rewrite_path_fixed(omd->cachepath, visit_cb, absbase, bpath_user_data);
@@ -509,12 +486,6 @@ void BKE_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int
}
}
- if (ob->soft) {
- BPATH_TRAVERSE_POINTCACHE(ob->soft->ptcaches);
- }
-
-#undef BPATH_TRAVERSE_POINTCACHE
-
break;
}
case ID_SO:
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index fa37e324e49..9454ad62ed3 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -45,7 +45,6 @@
#include "BKE_effect.h"
#include "BKE_global.h"
#include "BKE_modifier.h"
-#include "BKE_pointcache.h"
#include "BPH_mass_spring.h"
@@ -126,9 +125,6 @@ void cloth_init(ClothModifierData *clmd )
if (!clmd->sim_parms->effector_weights)
clmd->sim_parms->effector_weights = BKE_add_effector_weights(NULL);
-
- if (clmd->point_cache)
- clmd->point_cache->step = 1;
}
static BVHTree *bvhselftree_build_from_cloth (ClothModifierData *clmd, float epsilon)
@@ -299,30 +295,16 @@ void bvhselftree_update_from_cloth(ClothModifierData *clmd, bool moving)
}
}
-void cloth_clear_cache(Object *ob, ClothModifierData *clmd, float framenr)
-{
- PTCacheID pid;
-
- BKE_ptcache_id_from_cloth(&pid, ob, clmd);
- BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_AFTER, framenr);
-}
-
static int do_init_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *result, int framenr)
{
- PointCache *cache;
-
- cache= clmd->point_cache;
-
/* initialize simulation data if it didn't exist already */
if (clmd->clothObject == NULL) {
if (!cloth_from_object(ob, clmd, result, framenr, 1)) {
- BKE_ptcache_invalidate(cache);
modifier_setError(&(clmd->modifier), "Can't initialize cloth");
return 0;
}
if (clmd->clothObject == NULL) {
- BKE_ptcache_invalidate(cache);
modifier_setError(&(clmd->modifier), "Null cloth object");
return 0;
}
@@ -385,27 +367,14 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
************************************************/
void clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, DerivedMesh *dm, float (*vertexCos)[3])
{
- PointCache *cache;
- PTCacheID pid;
- float timescale;
- int framenr, startframe, endframe;
- int cache_result;
+ int framenr = scene->r.cfra, startframe = scene->r.sfra, endframe = scene->r.efra;
clmd->scene= scene; /* nice to pass on later :) */
- framenr= (int)scene->r.cfra;
- cache= clmd->point_cache;
- BKE_ptcache_id_from_cloth(&pid, ob, clmd);
- BKE_ptcache_id_time(&pid, scene, framenr, &startframe, &endframe, &timescale);
- clmd->sim_parms->timescale= timescale;
+ clmd->sim_parms->timescale= 1.0f;
if (clmd->sim_parms->reset || (clmd->clothObject && dm->getNumVerts(dm) != clmd->clothObject->mvert_num)) {
clmd->sim_parms->reset = 0;
- cache->flag |= PTCACHE_OUTDATED;
- BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
- BKE_ptcache_validate(cache, 0);
- cache->last_exact= 0;
- cache->flag &= ~PTCACHE_REDO_NEEDED;
}
// unused in the moment, calculated separately in implicit.c
@@ -413,7 +382,6 @@ void clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, Derived
/* simulation is only active during a specific period */
if (framenr < startframe) {
- BKE_ptcache_invalidate(cache);
return;
}
else if (framenr > endframe) {
@@ -425,56 +393,18 @@ void clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, Derived
return;
if (framenr == startframe) {
- BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
do_init_cloth(ob, clmd, dm, framenr);
- BKE_ptcache_validate(cache, framenr);
- cache->flag &= ~PTCACHE_REDO_NEEDED;
- clmd->clothObject->last_frame= framenr;
- return;
- }
-
- /* try to read from cache */
- cache_result = BKE_ptcache_read(&pid, (float)framenr+scene->r.subframe);
-
- if (cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) {
- BKE_cloth_solver_set_positions(clmd);
- cloth_to_object (ob, clmd, vertexCos);
-
- BKE_ptcache_validate(cache, framenr);
-
- if (cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED)
- BKE_ptcache_write(&pid, framenr);
-
clmd->clothObject->last_frame= framenr;
-
- return;
- }
- else if (cache_result==PTCACHE_READ_OLD) {
- BKE_cloth_solver_set_positions(clmd);
- }
- else if ( /*ob->id.lib ||*/ (cache->flag & PTCACHE_BAKED)) { /* 2.4x disabled lib, but this can be used in some cases, testing further - campbell */
- /* if baked and nothing in cache, do nothing */
- BKE_ptcache_invalidate(cache);
return;
}
if (framenr!=clmd->clothObject->last_frame+1)
return;
- /* if on second frame, write cache for first frame */
- if (cache->simframe == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0))
- BKE_ptcache_write(&pid, startframe);
-
- clmd->sim_parms->timescale *= framenr - cache->simframe;
+ clmd->sim_parms->timescale *= 1.0f;
/* do simulation */
- BKE_ptcache_validate(cache, framenr);
-
- if (!do_step_cloth(ob, clmd, dm, framenr)) {
- BKE_ptcache_invalidate(cache);
- }
- else
- BKE_ptcache_write(&pid, framenr);
+ do_step_cloth(ob, clmd, dm, framenr);
cloth_to_object (ob, clmd, vertexCos);
clmd->clothObject->last_frame= framenr;
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 30dcba66c5e..f06f7f55699 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -54,6 +54,7 @@
#include "DNA_mesh_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
+#include "DNA_object_force.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_windowmanager_types.h"
@@ -77,7 +78,6 @@
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_paint.h"
-#include "BKE_pointcache.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_tracking.h"
@@ -1795,38 +1795,6 @@ static unsigned int flush_layer_node(Scene *sce, DagNode *node, int curtime)
return node->lay;
}
-/* node was checked to have lasttime != curtime, and is of type ID_OB */
-static void flush_pointcache_reset(Main *bmain, Scene *scene, DagNode *node,
- int curtime, unsigned int lay, bool reset)
-{
- DagAdjList *itA;
- Object *ob;
-
- node->lasttime = curtime;
-
- for (itA = node->child; itA; itA = itA->next) {
- if (itA->node->type == ID_OB) {
- if (itA->node->lasttime != curtime) {
- ob = (Object *)(itA->node->ob);
-
- if (reset || (ob->recalc & OB_RECALC_ALL)) {
- if (BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH)) {
- /* Don't tag nodes which are on invisible layer. */
- if (itA->node->lay & lay) {
- ob->recalc |= OB_RECALC_DATA;
- lib_id_recalc_data_tag(bmain, &ob->id);
- }
- }
-
- flush_pointcache_reset(bmain, scene, itA->node, curtime, lay, true);
- }
- else
- flush_pointcache_reset(bmain, scene, itA->node, curtime, lay, false);
- }
- }
- }
-}
-
/* flush layer flags to dependencies */
static void dag_scene_flush_layers(Scene *sce, int lay)
{
@@ -1904,7 +1872,6 @@ void DAG_scene_flush_update(Main *bmain, Scene *sce, unsigned int lay, const sho
{
DagNode *firstnode;
DagAdjList *itA;
- Object *ob;
int lasttime;
if (!DEG_depsgraph_use_legacy()) {
@@ -1932,24 +1899,6 @@ void DAG_scene_flush_update(Main *bmain, Scene *sce, unsigned int lay, const sho
if (!time) {
sce->theDag->time++; /* so we know which nodes were accessed */
lasttime = sce->theDag->time;
- for (itA = firstnode->child; itA; itA = itA->next) {
- if (itA->node->lasttime != lasttime && itA->node->type == ID_OB) {
- ob = (Object *)(itA->node->ob);
-
- if (ob->recalc & OB_RECALC_ALL) {
- if (BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH)) {
- ob->recalc |= OB_RECALC_DATA;
- lib_id_recalc_data_tag(bmain, &ob->id);
- }
-
- flush_pointcache_reset(bmain, sce, itA->node, lasttime,
- lay, true);
- }
- else
- flush_pointcache_reset(bmain, sce, itA->node, lasttime,
- lay, false);
- }
- }
}
dag_tag_renderlayers(sce, lay);
@@ -2466,7 +2415,6 @@ static void dag_id_flush_update(Main *bmain, Scene *sce, ID *id)
/* set flags & pointcache for object */
if (GS(id->name) == ID_OB) {
ob = (Object *)id;
- BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH);
/* So if someone tagged object recalc directly,
* id_tag_update bit-field stays relevant
@@ -2497,7 +2445,6 @@ static void dag_id_flush_update(Main *bmain, Scene *sce, ID *id)
if (!(ob && obt == ob) && obt->data == id) {
obt->recalc |= OB_RECALC_DATA;
lib_id_recalc_data_tag(bmain, &obt->id);
- BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH);
}
}
}
@@ -2536,7 +2483,6 @@ static void dag_id_flush_update(Main *bmain, Scene *sce, ID *id)
obt->flag |= (OB_RECALC_OB | OB_RECALC_DATA);
lib_id_recalc_tag(bmain, &obt->id);
lib_id_recalc_data_tag(bmain, &obt->id);
- BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH);
}
}
}
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index ba9a47d9334..73d64c23840 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -47,6 +47,7 @@
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
+#include "DNA_object_force.h"
#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
@@ -66,7 +67,6 @@
#include "BKE_material.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
-#include "BKE_pointcache.h"
#include "BKE_scene.h"
#include "BKE_texture.h"
@@ -837,8 +837,7 @@ static void surface_freeUnusedData(DynamicPaintSurface *surface)
if (!surface->data) return;
/* free bakedata if not active or surface is baked */
- if (!(surface->flags & MOD_DPAINT_ACTIVE) ||
- (surface->pointcache && surface->pointcache->flag & PTCACHE_BAKED))
+ if (!(surface->flags & MOD_DPAINT_ACTIVE))
{
free_bakeData(surface->data);
}
@@ -871,10 +870,6 @@ void dynamicPaint_freeSurfaceData(DynamicPaintSurface *surface)
void dynamicPaint_freeSurface(DynamicPaintSurface *surface)
{
- /* point cache */
- BKE_ptcache_free_list(&(surface->ptcaches));
- surface->pointcache = NULL;
-
if (surface->effector_weights)
MEM_freeN(surface->effector_weights);
surface->effector_weights = NULL;
@@ -935,11 +930,6 @@ DynamicPaintSurface *dynamicPaint_createNewSurface(DynamicPaintCanvasSettings *c
surface->format = MOD_DPAINT_SURFACE_F_VERTEX;
surface->type = MOD_DPAINT_SURFACE_T_PAINT;
- /* cache */
- surface->pointcache = BKE_ptcache_add(&(surface->ptcaches));
- surface->pointcache->flag |= PTCACHE_DISK_CACHE;
- surface->pointcache->step = 1;
-
/* Set initial values */
surface->flags = MOD_DPAINT_ANTIALIAS | MOD_DPAINT_MULALPHA | MOD_DPAINT_DRY_LOG | MOD_DPAINT_DISSOLVE_LOG |
MOD_DPAINT_ACTIVE | MOD_DPAINT_PREVIEW | MOD_DPAINT_OUT1 | MOD_DPAINT_USE_DRYING;
@@ -1804,15 +1794,6 @@ static DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd,
return result;
}
-/* update cache frame range */
-void dynamicPaint_cacheUpdateFrames(DynamicPaintSurface *surface)
-{
- if (surface->pointcache) {
- surface->pointcache->startframe = surface->start_frame;
- surface->pointcache->endframe = surface->end_frame;
- }
-}
-
static void canvas_copyDerivedMesh(DynamicPaintCanvasSettings *canvas, DerivedMesh *dm)
{
if (canvas->dm) {
@@ -1857,29 +1838,10 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
CLAMP(current_frame, surface->start_frame, surface->end_frame);
if (no_surface_data || current_frame != surface->current_frame || (int)scene->r.cfra == surface->start_frame) {
- PointCache *cache = surface->pointcache;
- PTCacheID pid;
surface->current_frame = current_frame;
- /* read point cache */
- BKE_ptcache_id_from_dynamicpaint(&pid, ob, surface);
- pid.cache->startframe = surface->start_frame;
- pid.cache->endframe = surface->end_frame;
- BKE_ptcache_id_time(&pid, scene, (float)scene->r.cfra, NULL, NULL, NULL);
-
- /* reset non-baked cache at first frame */
- if ((int)scene->r.cfra == surface->start_frame && !(cache->flag & PTCACHE_BAKED)) {
- cache->flag |= PTCACHE_REDO_NEEDED;
- BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
- cache->flag &= ~PTCACHE_REDO_NEEDED;
- }
-
- /* try to read from cache */
- if (BKE_ptcache_read(&pid, (float)scene->r.cfra)) {
- BKE_ptcache_validate(cache, (int)scene->r.cfra);
- }
- /* if read failed and we're on surface range do recalculate */
- else if ((int)scene->r.cfra == current_frame && !(cache->flag & PTCACHE_BAKED)) {
+ /* if we're on surface range do recalculate */
+ if ((int)scene->r.cfra == current_frame) {
/* calculate surface frame */
canvas->flags |= MOD_DPAINT_BAKING;
dynamicPaint_calculateFrame(surface, scene, ob, current_frame);
@@ -1891,9 +1853,6 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
{
canvas_copyDerivedMesh(canvas, dm);
}
-
- BKE_ptcache_validate(cache, surface->current_frame);
- BKE_ptcache_write(&pid, surface->current_frame);
}
}
}
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 8ae0d7dd204..a3597541529 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -50,6 +50,8 @@
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_movieclip_types.h"
+#include "DNA_object_force.h"
+#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_sequence_types.h"
@@ -102,7 +104,6 @@
#include "BKE_node.h"
#include "BKE_object.h"
#include "BKE_paint.h"
-#include "BKE_pointcache.h"
#include "BKE_property.h"
#include "BKE_rigidbody.h"
#include "BKE_sca.h"
@@ -1160,8 +1161,6 @@ SoftBody *copy_softbody(const SoftBody *sb, bool copy_caches)
sbn->scratch = NULL;
- sbn->pointcache = BKE_ptcache_copy_list(&sbn->ptcaches, &sb->ptcaches, copy_caches);
-
if (sb->effector_weights)
sbn->effector_weights = MEM_dupallocN(sb->effector_weights);
@@ -3897,25 +3896,6 @@ bool BKE_object_modifier_use_time(Object *ob, ModifierData *md)
return false;
}
-/* set "ignore cache" flag for all caches on this object */
-static void object_cacheIgnoreClear(Object *ob, int state)
-{
- ListBase pidlist;
- PTCacheID *pid;
- BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0);
-
- for (pid = pidlist.first; pid; pid = pid->next) {
- if (pid->cache) {
- if (state)
- pid->cache->flag |= PTCACHE_IGNORE_CLEAR;
- else
- pid->cache->flag &= ~PTCACHE_IGNORE_CLEAR;
- }
- }
-
- BLI_freelistN(&pidlist);
-}
-
/* Note: this function should eventually be replaced by depsgraph functionality.
* Avoid calling this in new code unless there is a very good reason for it!
*/
@@ -3974,13 +3954,8 @@ bool BKE_object_modifier_update_subframe(Scene *scene, Object *ob, bool update_m
/* was originally OB_RECALC_ALL - TODO - which flags are really needed??? */
ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, frame, ADT_RECALC_ANIM);
- if (update_mesh) {
- /* ignore cache clear during subframe updates
- * to not mess up cache validity */
- object_cacheIgnoreClear(ob, 1);
+ if (update_mesh)
BKE_object_handle_update(G.main->eval_ctx, scene, ob);
- object_cacheIgnoreClear(ob, 0);
- }
else
BKE_object_where_is_calc_time(scene, ob, frame);
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
deleted file mode 100644
index c2950530e5c..00000000000
--- a/source/blender/blenkernel/intern/pointcache.c
+++ /dev/null
@@ -1,3765 +0,0 @@
-/*
- * ***** 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) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * Contributor(s): Campbell Barton <ideasman42@gmail.com>
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/blenkernel/intern/pointcache.c
- * \ingroup bke
- */
-
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_ID.h"
-#include "DNA_dynamicpaint_types.h"
-#include "DNA_modifier_types.h"
-#include "DNA_object_types.h"
-#include "DNA_object_force.h"
-#include "DNA_rigidbody_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_smoke_types.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_threads.h"
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
-#include "BLT_translation.h"
-
-#include "PIL_time.h"
-
-#include "WM_api.h"
-
-#include "BKE_appdir.h"
-#include "BKE_anim.h"
-#include "BKE_cloth.h"
-#include "BKE_dynamicpaint.h"
-#include "BKE_key.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_modifier.h"
-#include "BKE_object.h"
-#include "BKE_pointcache.h"
-#include "BKE_scene.h"
-#include "BKE_smoke.h"
-#include "BKE_softbody.h"
-
-#include "BIK_api.h"
-
-#ifdef WITH_BULLET
-# include "RBI_api.h"
-#endif
-
-/* both in intern */
-#ifdef WITH_SMOKE
-#include "smoke_API.h"
-#endif
-
-#ifdef WITH_OPENVDB
-#include "openvdb_capi.h"
-#endif
-
-#ifdef WITH_LZO
-# ifdef WITH_SYSTEM_LZO
-# include <lzo/lzo1x.h>
-# else
-# include "minilzo.h"
-# endif
-# define LZO_HEAP_ALLOC(var,size) \
- lzo_align_t __LZO_MMODEL var [ ((size) + (sizeof(lzo_align_t) - 1)) / sizeof(lzo_align_t) ]
-#endif
-
-#define LZO_OUT_LEN(size) ((size) + (size) / 16 + 64 + 3)
-
-#ifdef WITH_LZMA
-#include "LzmaLib.h"
-#endif
-
-/* needed for directory lookup */
-#ifndef WIN32
-# include <dirent.h>
-#else
-# include "BLI_winstuff.h"
-#endif
-
-#define PTCACHE_DATA_FROM(data, type, from) \
- if (data[type]) { \
- memcpy(data[type], from, ptcache_data_size[type]); \
- } (void)0
-
-#define PTCACHE_DATA_TO(data, type, index, to) \
- if (data[type]) { \
- memcpy(to, (char *)(data)[type] + ((index) ? (index) * ptcache_data_size[type] : 0), ptcache_data_size[type]); \
- } (void)0
-
-/* could be made into a pointcache option */
-#define DURIAN_POINTCACHE_LIB_OK 1
-
-static int ptcache_data_size[] = {
- sizeof(unsigned int), // BPHYS_DATA_INDEX
- 3 * sizeof(float), // BPHYS_DATA_LOCATION
- 3 * sizeof(float), // BPHYS_DATA_VELOCITY
- 4 * sizeof(float), // BPHYS_DATA_ROTATION
- 3 * sizeof(float), // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST
- sizeof(float), // BPHYS_DATA_SIZE
- 3 * sizeof(float), // BPHYS_DATA_TIMES
- 0 // case BPHYS_DATA_BOIDS
-};
-
-static int ptcache_extra_datasize[] = {
- 0,
- 0
-};
-
-/* forward declerations */
-static int ptcache_file_compressed_read(PTCacheFile *pf, unsigned char *result, unsigned int len);
-static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, unsigned int in_len, unsigned char *out, int mode);
-static int ptcache_file_write(PTCacheFile *pf, const void *f, unsigned int tot, unsigned int size);
-static int ptcache_file_read(PTCacheFile *pf, void *f, unsigned int tot, unsigned int size);
-
-/* Common functions */
-static int ptcache_basic_header_read(PTCacheFile *pf)
-{
- int error=0;
-
- /* Custom functions should read these basic elements too! */
- if (!error && !fread(&pf->totpoint, sizeof(unsigned int), 1, pf->fp))
- error = 1;
-
- if (!error && !fread(&pf->data_types, sizeof(unsigned int), 1, pf->fp))
- error = 1;
-
- return !error;
-}
-static int ptcache_basic_header_write(PTCacheFile *pf)
-{
- /* Custom functions should write these basic elements too! */
- if (!fwrite(&pf->totpoint, sizeof(unsigned int), 1, pf->fp))
- return 0;
-
- if (!fwrite(&pf->data_types, sizeof(unsigned int), 1, pf->fp))
- return 0;
-
- return 1;
-}
-/* Softbody functions */
-static int ptcache_softbody_write(int index, void *soft_v, void **data, int UNUSED(cfra))
-{
- SoftBody *soft= soft_v;
- BodyPoint *bp = soft->bpoint + index;
-
- PTCACHE_DATA_FROM(data, BPHYS_DATA_LOCATION, bp->pos);
- PTCACHE_DATA_FROM(data, BPHYS_DATA_VELOCITY, bp->vec);
-
- return 1;
-}
-static void ptcache_softbody_read(int index, void *soft_v, void **data, float UNUSED(cfra), float *old_data)
-{
- SoftBody *soft= soft_v;
- BodyPoint *bp = soft->bpoint + index;
-
- if (old_data) {
- memcpy(bp->pos, data, 3 * sizeof(float));
- memcpy(bp->vec, data + 3, 3 * sizeof(float));
- }
- else {
- PTCACHE_DATA_TO(data, BPHYS_DATA_LOCATION, 0, bp->pos);
- PTCACHE_DATA_TO(data, BPHYS_DATA_VELOCITY, 0, bp->vec);
- }
-}
-
-static void interpolate_particle_keys(short type, PointCacheKey keys[4], float dt, PointCacheKey *result, bool velocity)
-{
- float t[4];
-
- if (type < 0) {
- interp_cubic_v3(result->co, result->vel, keys[1].co, keys[1].vel, keys[2].co, keys[2].vel, dt);
- }
- else {
- key_curve_position_weights(dt, t, type);
-
- interp_v3_v3v3v3v3(result->co, keys[0].co, keys[1].co, keys[2].co, keys[3].co, t);
-
- if (velocity) {
- float temp[3];
-
- if (dt > 0.999f) {
- key_curve_position_weights(dt - 0.001f, t, type);
- interp_v3_v3v3v3v3(temp, keys[0].co, keys[1].co, keys[2].co, keys[3].co, t);
- sub_v3_v3v3(result->vel, result->co, temp);
- }
- else {
- key_curve_position_weights(dt + 0.001f, t, type);
- interp_v3_v3v3v3v3(temp, keys[0].co, keys[1].co, keys[2].co, keys[3].co, t);
- sub_v3_v3v3(result->vel, temp, result->co);
- }
- }
- }
-}
-
-static void ptcache_softbody_interpolate(int index, void *soft_v, void **data, float cfra, float cfra1, float cfra2, float *old_data)
-{
- SoftBody *soft= soft_v;
- BodyPoint *bp = soft->bpoint + index;
- PointCacheKey keys[4];
- float dfra;
-
- if (cfra1 == cfra2)
- return;
-
- copy_v3_v3(keys[1].co, bp->pos);
- copy_v3_v3(keys[1].vel, bp->vec);
-
- if (old_data) {
- memcpy(keys[2].co, old_data, 3 * sizeof(float));
- memcpy(keys[2].vel, old_data + 3, 3 * sizeof(float));
- }
- else
- BKE_ptcache_make_key(keys+2, 0, data, cfra2);
-
- dfra = cfra2 - cfra1;
-
- mul_v3_fl(keys[1].vel, dfra);
- mul_v3_fl(keys[2].vel, dfra);
-
- interpolate_particle_keys(-1, keys, (cfra - cfra1) / dfra, keys, 1);
-
- mul_v3_fl(keys->vel, 1.0f / dfra);
-
- copy_v3_v3(bp->pos, keys->co);
- copy_v3_v3(bp->vec, keys->vel);
-}
-static int ptcache_softbody_totpoint(void *soft_v, int UNUSED(cfra))
-{
- SoftBody *soft= soft_v;
- return soft->totpoint;
-}
-static void ptcache_softbody_error(void *UNUSED(soft_v), const char *UNUSED(message))
-{
- /* ignored for now */
-}
-
-void BKE_ptcache_make_key(PointCacheKey *key, int index, void **data, float time)
-{
- PTCACHE_DATA_TO(data, BPHYS_DATA_LOCATION, index, key->co);
- PTCACHE_DATA_TO(data, BPHYS_DATA_VELOCITY, index, key->vel);
-
- /* no rotation info, so make something nice up */
- if (data[BPHYS_DATA_ROTATION]==NULL) {
- vec_to_quat(key->rot, key->vel, OB_NEGX, OB_POSZ);
- }
- else {
- PTCACHE_DATA_TO(data, BPHYS_DATA_ROTATION, index, key->rot);
- }
-
- PTCACHE_DATA_TO(data, BPHYS_DATA_AVELOCITY, index, key->ave);
- key->time = time;
-}
-
-/* Cloth functions */
-static int ptcache_cloth_write(int index, void *cloth_v, void **data, int UNUSED(cfra))
-{
- ClothModifierData *clmd= cloth_v;
- Cloth *cloth= clmd->clothObject;
- ClothVertex *vert = cloth->verts + index;
-
- PTCACHE_DATA_FROM(data, BPHYS_DATA_LOCATION, vert->x);
- PTCACHE_DATA_FROM(data, BPHYS_DATA_VELOCITY, vert->v);
- PTCACHE_DATA_FROM(data, BPHYS_DATA_XCONST, vert->xconst);
-
- return 1;
-}
-static void ptcache_cloth_read(int index, void *cloth_v, void **data, float UNUSED(cfra), float *old_data)
-{
- ClothModifierData *clmd= cloth_v;
- Cloth *cloth= clmd->clothObject;
- ClothVertex *vert = cloth->verts + index;
-
- if (old_data) {
- memcpy(vert->x, data, 3 * sizeof(float));
- memcpy(vert->xconst, data + 3, 3 * sizeof(float));
- memcpy(vert->v, data + 6, 3 * sizeof(float));
- }
- else {
- PTCACHE_DATA_TO(data, BPHYS_DATA_LOCATION, 0, vert->x);
- PTCACHE_DATA_TO(data, BPHYS_DATA_VELOCITY, 0, vert->v);
- PTCACHE_DATA_TO(data, BPHYS_DATA_XCONST, 0, vert->xconst);
- }
-}
-static void ptcache_cloth_interpolate(int index, void *cloth_v, void **data, float cfra, float cfra1, float cfra2, float *old_data)
-{
- ClothModifierData *clmd= cloth_v;
- Cloth *cloth= clmd->clothObject;
- ClothVertex *vert = cloth->verts + index;
- PointCacheKey keys[4];
- float dfra;
-
- if (cfra1 == cfra2)
- return;
-
- copy_v3_v3(keys[1].co, vert->x);
- copy_v3_v3(keys[1].vel, vert->v);
-
- if (old_data) {
- memcpy(keys[2].co, old_data, 3 * sizeof(float));
- memcpy(keys[2].vel, old_data + 6, 3 * sizeof(float));
- }
- else
- BKE_ptcache_make_key(keys+2, 0, data, cfra2);
-
- dfra = cfra2 - cfra1;
-
- mul_v3_fl(keys[1].vel, dfra);
- mul_v3_fl(keys[2].vel, dfra);
-
- interpolate_particle_keys(-1, keys, (cfra - cfra1) / dfra, keys, 1);
-
- mul_v3_fl(keys->vel, 1.0f / dfra);
-
- copy_v3_v3(vert->x, keys->co);
- copy_v3_v3(vert->v, keys->vel);
-
- /* should vert->xconst be interpolated somehow too? - jahka */
-}
-
-static int ptcache_cloth_totpoint(void *cloth_v, int UNUSED(cfra))
-{
- ClothModifierData *clmd= cloth_v;
- return clmd->clothObject ? clmd->clothObject->mvert_num : 0;
-}
-
-static void ptcache_cloth_error(void *cloth_v, const char *message)
-{
- ClothModifierData *clmd= cloth_v;
- modifier_setError(&clmd->modifier, "%s", message);
-}
-
-#ifdef WITH_SMOKE
-/* Smoke functions */
-static int ptcache_smoke_totpoint(void *smoke_v, int UNUSED(cfra))
-{
- SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
- SmokeDomainSettings *sds = smd->domain;
-
- if (sds->fluid) {
- return sds->base_res[0]*sds->base_res[1]*sds->base_res[2];
- }
- else
- return 0;
-}
-
-static void ptcache_smoke_error(void *smoke_v, const char *message)
-{
- SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
- modifier_setError(&smd->modifier, "%s", message);
-}
-
-#define SMOKE_CACHE_VERSION "1.04"
-
-static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
-{
- SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
- SmokeDomainSettings *sds = smd->domain;
- int ret = 0;
- int fluid_fields = smoke_get_data_flags(sds);
-
- /* version header */
- ptcache_file_write(pf, SMOKE_CACHE_VERSION, 4, sizeof(char));
- ptcache_file_write(pf, &fluid_fields, 1, sizeof(int));
- ptcache_file_write(pf, &sds->active_fields, 1, sizeof(int));
- ptcache_file_write(pf, &sds->res, 3, sizeof(int));
- ptcache_file_write(pf, &sds->dx, 1, sizeof(float));
-
- if (sds->fluid) {
- size_t res = sds->res[0]*sds->res[1]*sds->res[2];
- float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold, *vx, *vy, *vz, *r, *g, *b;
- unsigned char *obstacles;
- unsigned int in_len = sizeof(float)*(unsigned int)res;
- unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len) * 4, "pointcache_lzo_buffer");
- //int mode = res >= 1000000 ? 2 : 1;
- int mode=1; // light
- if (sds->cache_comp == SM_CACHE_HEAVY) mode=2; // heavy
-
- smoke_export(sds->fluid, &dt, &dx, &dens, &react, &flame, &fuel, &heat, &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles);
-
- ptcache_file_compressed_write(pf, (unsigned char *)sds->shadow, in_len, out, mode);
- ptcache_file_compressed_write(pf, (unsigned char *)dens, in_len, out, mode);
- if (fluid_fields & SM_ACTIVE_HEAT) {
- ptcache_file_compressed_write(pf, (unsigned char *)heat, in_len, out, mode);
- ptcache_file_compressed_write(pf, (unsigned char *)heatold, in_len, out, mode);
- }
- if (fluid_fields & SM_ACTIVE_FIRE) {
- ptcache_file_compressed_write(pf, (unsigned char *)flame, in_len, out, mode);
- ptcache_file_compressed_write(pf, (unsigned char *)fuel, in_len, out, mode);
- ptcache_file_compressed_write(pf, (unsigned char *)react, in_len, out, mode);
- }
- if (fluid_fields & SM_ACTIVE_COLORS) {
- ptcache_file_compressed_write(pf, (unsigned char *)r, in_len, out, mode);
- ptcache_file_compressed_write(pf, (unsigned char *)g, in_len, out, mode);
- ptcache_file_compressed_write(pf, (unsigned char *)b, in_len, out, mode);
- }
- ptcache_file_compressed_write(pf, (unsigned char *)vx, in_len, out, mode);
- ptcache_file_compressed_write(pf, (unsigned char *)vy, in_len, out, mode);
- ptcache_file_compressed_write(pf, (unsigned char *)vz, in_len, out, mode);
- ptcache_file_compressed_write(pf, (unsigned char *)obstacles, (unsigned int)res, out, mode);
- ptcache_file_write(pf, &dt, 1, sizeof(float));
- ptcache_file_write(pf, &dx, 1, sizeof(float));
- ptcache_file_write(pf, &sds->p0, 3, sizeof(float));
- ptcache_file_write(pf, &sds->p1, 3, sizeof(float));
- ptcache_file_write(pf, &sds->dp0, 3, sizeof(float));
- ptcache_file_write(pf, &sds->shift, 3, sizeof(int));
- ptcache_file_write(pf, &sds->obj_shift_f, 3, sizeof(float));
- ptcache_file_write(pf, &sds->obmat, 16, sizeof(float));
- ptcache_file_write(pf, &sds->base_res, 3, sizeof(int));
- ptcache_file_write(pf, &sds->res_min, 3, sizeof(int));
- ptcache_file_write(pf, &sds->res_max, 3, sizeof(int));
- ptcache_file_write(pf, &sds->active_color, 3, sizeof(float));
-
- MEM_freeN(out);
-
- ret = 1;
- }
-
- if (sds->wt) {
- int res_big_array[3];
- int res_big;
- int res = sds->res[0]*sds->res[1]*sds->res[2];
- float *dens, *react, *fuel, *flame, *tcu, *tcv, *tcw, *r, *g, *b;
- unsigned int in_len = sizeof(float)*(unsigned int)res;
- unsigned int in_len_big;
- unsigned char *out;
- int mode;
-
- smoke_turbulence_get_res(sds->wt, res_big_array);
- res_big = res_big_array[0]*res_big_array[1]*res_big_array[2];
- //mode = res_big >= 1000000 ? 2 : 1;
- mode = 1; // light
- if (sds->cache_high_comp == SM_CACHE_HEAVY) mode=2; // heavy
-
- in_len_big = sizeof(float) * (unsigned int)res_big;
-
- smoke_turbulence_export(sds->wt, &dens, &react, &flame, &fuel, &r, &g, &b, &tcu, &tcv, &tcw);
-
- out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len_big), "pointcache_lzo_buffer");
- ptcache_file_compressed_write(pf, (unsigned char *)dens, in_len_big, out, mode);
- if (fluid_fields & SM_ACTIVE_FIRE) {
- ptcache_file_compressed_write(pf, (unsigned char *)flame, in_len_big, out, mode);
- ptcache_file_compressed_write(pf, (unsigned char *)fuel, in_len_big, out, mode);
- ptcache_file_compressed_write(pf, (unsigned char *)react, in_len_big, out, mode);
- }
- if (fluid_fields & SM_ACTIVE_COLORS) {
- ptcache_file_compressed_write(pf, (unsigned char *)r, in_len_big, out, mode);
- ptcache_file_compressed_write(pf, (unsigned char *)g, in_len_big, out, mode);
- ptcache_file_compressed_write(pf, (unsigned char *)b, in_len_big, out, mode);
- }
- MEM_freeN(out);
-
- out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len), "pointcache_lzo_buffer");
- ptcache_file_compressed_write(pf, (unsigned char *)tcu, in_len, out, mode);
- ptcache_file_compressed_write(pf, (unsigned char *)tcv, in_len, out, mode);
- ptcache_file_compressed_write(pf, (unsigned char *)tcw, in_len, out, mode);
- MEM_freeN(out);
-
- ret = 1;
- }
-
- return ret;
-}
-
-/* read old smoke cache from 2.64 */
-static int ptcache_smoke_read_old(PTCacheFile *pf, void *smoke_v)
-{
- SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
- SmokeDomainSettings *sds = smd->domain;
-
- if (sds->fluid) {
- const size_t res = sds->res[0] * sds->res[1] * sds->res[2];
- const unsigned int out_len = (unsigned int)res * sizeof(float);
- float dt, dx, *dens, *heat, *heatold, *vx, *vy, *vz;
- unsigned char *obstacles;
- float *tmp_array = MEM_callocN(out_len, "Smoke old cache tmp");
-
- int fluid_fields = smoke_get_data_flags(sds);
-
- /* Part part of the new cache header */
- sds->active_color[0] = 0.7f;
- sds->active_color[1] = 0.7f;
- sds->active_color[2] = 0.7f;
-
- smoke_export(sds->fluid, &dt, &dx, &dens, NULL, NULL, NULL, &heat, &heatold, &vx, &vy, &vz, NULL, NULL, NULL, &obstacles);
-
- ptcache_file_compressed_read(pf, (unsigned char *)sds->shadow, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)dens, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)tmp_array, out_len);
-
- if (fluid_fields & SM_ACTIVE_HEAT)
- {
- ptcache_file_compressed_read(pf, (unsigned char*)heat, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)heatold, out_len);
- }
- else
- {
- ptcache_file_compressed_read(pf, (unsigned char*)tmp_array, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)tmp_array, out_len);
- }
- ptcache_file_compressed_read(pf, (unsigned char*)vx, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)vy, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)vz, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)tmp_array, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)tmp_array, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)tmp_array, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)obstacles, (unsigned int)res);
- ptcache_file_read(pf, &dt, 1, sizeof(float));
- ptcache_file_read(pf, &dx, 1, sizeof(float));
-
- MEM_freeN(tmp_array);
-
- if (pf->data_types & (1<<BPHYS_DATA_SMOKE_HIGH) && sds->wt) {
- int res_big, res_big_array[3];
- float *tcu, *tcv, *tcw;
- unsigned int out_len_big;
- unsigned char *tmp_array_big;
- smoke_turbulence_get_res(sds->wt, res_big_array);
- res_big = res_big_array[0]*res_big_array[1]*res_big_array[2];
- out_len_big = sizeof(float) * (unsigned int)res_big;
-
- tmp_array_big = MEM_callocN(out_len_big, "Smoke old cache tmp");
-
- smoke_turbulence_export(sds->wt, &dens, NULL, NULL, NULL, NULL, NULL, NULL, &tcu, &tcv, &tcw);
-
- ptcache_file_compressed_read(pf, (unsigned char*)dens, out_len_big);
- ptcache_file_compressed_read(pf, (unsigned char*)tmp_array_big, out_len_big);
-
- ptcache_file_compressed_read(pf, (unsigned char*)tcu, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)tcv, out_len);
- ptcache_file_compressed_read(pf, (unsigned char*)tcw, out_len);
-
- MEM_freeN(tmp_array_big);
- }
- }
-
- return 1;
-}
-
-static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v)
-{
- SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
- SmokeDomainSettings *sds = smd->domain;
- char version[4];
- int ch_res[3];
- float ch_dx;
- int fluid_fields = smoke_get_data_flags(sds);
- int cache_fields = 0;
- int active_fields = 0;
- int reallocate = 0;
-
- /* version header */
- ptcache_file_read(pf, version, 4, sizeof(char));
- if (!STREQLEN(version, SMOKE_CACHE_VERSION, 4))
- {
- /* reset file pointer */
- fseek(pf->fp, -4, SEEK_CUR);
- return ptcache_smoke_read_old(pf, smoke_v);
- }
-
- /* fluid info */
- ptcache_file_read(pf, &cache_fields, 1, sizeof(int));
- ptcache_file_read(pf, &active_fields, 1, sizeof(int));
- ptcache_file_read(pf, &ch_res, 3, sizeof(int));
- ptcache_file_read(pf, &ch_dx, 1, sizeof(float));
-
- /* check if resolution has changed */
- if (sds->res[0] != ch_res[0] ||
- sds->res[1] != ch_res[1] ||
- sds->res[2] != ch_res[2]) {
- if (sds->flags & MOD_SMOKE_ADAPTIVE_DOMAIN)
- reallocate = 1;
- else
- return 0;
- }
- /* check if active fields have changed */
- if (fluid_fields != cache_fields ||
- active_fields != sds->active_fields)
- reallocate = 1;
-
- /* reallocate fluid if needed*/
- if (reallocate) {
- sds->active_fields = active_fields | cache_fields;
- smoke_reallocate_fluid(sds, ch_dx, ch_res, 1);
- sds->dx = ch_dx;
- VECCOPY(sds->res, ch_res);
- sds->total_cells = ch_res[0]*ch_res[1]*ch_res[2];
- if (sds->flags & MOD_SMOKE_HIGHRES) {
- smoke_reallocate_highres_fluid(sds, ch_dx, ch_res, 1);
- }
- }
-
- if (sds->fluid) {
- size_t res = sds->res[0]*sds->res[1]*sds->res[2];
- float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold, *vx, *vy, *vz, *r, *g, *b;
- unsigned char *obstacles;
- unsigned int out_len = (unsigned int)res * sizeof(float);
-
- smoke_export(sds->fluid, &dt, &dx, &dens, &react, &flame, &fuel, &heat, &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles);
-
- ptcache_file_compressed_read(pf, (unsigned char *)sds->shadow, out_len);
- ptcache_file_compressed_read(pf, (unsigned char *)dens, out_len);
- if (cache_fields & SM_ACTIVE_HEAT) {
- ptcache_file_compressed_read(pf, (unsigned char *)heat, out_len);
- ptcache_file_compressed_read(pf, (unsigned char *)heatold, out_len);
- }
- if (cache_fields & SM_ACTIVE_FIRE) {
- ptcache_file_compressed_read(pf, (unsigned char *)flame, out_len);
- ptcache_file_compressed_read(pf, (unsigned char *)fuel, out_len);
- ptcache_file_compressed_read(pf, (unsigned char *)react, out_len);
- }
- if (cache_fields & SM_ACTIVE_COLORS) {
- ptcache_file_compressed_read(pf, (unsigned char *)r, out_len);
- ptcache_file_compressed_read(pf, (unsigned char *)g, out_len);
- ptcache_file_compressed_read(pf, (unsigned char *)b, out_len);
- }
- ptcache_file_compressed_read(pf, (unsigned char *)vx, out_len);
- ptcache_file_compressed_read(pf, (unsigned char *)vy, out_len);
- ptcache_file_compressed_read(pf, (unsigned char *)vz, out_len);
- ptcache_file_compressed_read(pf, (unsigned char *)obstacles, (unsigned int)res);
- ptcache_file_read(pf, &dt, 1, sizeof(float));
- ptcache_file_read(pf, &dx, 1, sizeof(float));
- ptcache_file_read(pf, &sds->p0, 3, sizeof(float));
- ptcache_file_read(pf, &sds->p1, 3, sizeof(float));
- ptcache_file_read(pf, &sds->dp0, 3, sizeof(float));
- ptcache_file_read(pf, &sds->shift, 3, sizeof(int));
- ptcache_file_read(pf, &sds->obj_shift_f, 3, sizeof(float));
- ptcache_file_read(pf, &sds->obmat, 16, sizeof(float));
- ptcache_file_read(pf, &sds->base_res, 3, sizeof(int));
- ptcache_file_read(pf, &sds->res_min, 3, sizeof(int));
- ptcache_file_read(pf, &sds->res_max, 3, sizeof(int));
- ptcache_file_read(pf, &sds->active_color, 3, sizeof(float));
- }
-
- if (pf->data_types & (1<<BPHYS_DATA_SMOKE_HIGH) && sds->wt) {
- int res = sds->res[0]*sds->res[1]*sds->res[2];
- int res_big, res_big_array[3];
- float *dens, *react, *fuel, *flame, *tcu, *tcv, *tcw, *r, *g, *b;
- unsigned int out_len = sizeof(float)*(unsigned int)res;
- unsigned int out_len_big;
-
- smoke_turbulence_get_res(sds->wt, res_big_array);
- res_big = res_big_array[0]*res_big_array[1]*res_big_array[2];
- out_len_big = sizeof(float) * (unsigned int)res_big;
-
- smoke_turbulence_export(sds->wt, &dens, &react, &flame, &fuel, &r, &g, &b, &tcu, &tcv, &tcw);
-
- ptcache_file_compressed_read(pf, (unsigned char *)dens, out_len_big);
- if (cache_fields & SM_ACTIVE_FIRE) {
- ptcache_file_compressed_read(pf, (unsigned char *)flame, out_len_big);
- ptcache_file_compressed_read(pf, (unsigned char *)fuel, out_len_big);
- ptcache_file_compressed_read(pf, (unsigned char *)react, out_len_big);
- }
- if (cache_fields & SM_ACTIVE_COLORS) {
- ptcache_file_compressed_read(pf, (unsigned char *)r, out_len_big);
- ptcache_file_compressed_read(pf, (unsigned char *)g, out_len_big);
- ptcache_file_compressed_read(pf, (unsigned char *)b, out_len_big);
- }
-
- ptcache_file_compressed_read(pf, (unsigned char *)tcu, out_len);
- ptcache_file_compressed_read(pf, (unsigned char *)tcv, out_len);
- ptcache_file_compressed_read(pf, (unsigned char *)tcw, out_len);
- }
-
- return 1;
-}
-
-#ifdef WITH_OPENVDB
-/**
- * Construct matrices which represent the fluid object, for low and high res:
- * <pre>
- * vs 0 0 0
- * 0 vs 0 0
- * 0 0 vs 0
- * px py pz 1
- * </pre>
- *
- * with `vs` = voxel size, and `px, py, pz`,
- * the min position of the domain's bounding box.
- */
-static void compute_fluid_matrices(SmokeDomainSettings *sds)
-{
- float bbox_min[3];
-
- copy_v3_v3(bbox_min, sds->p0);
-
- if (sds->flags & MOD_SMOKE_ADAPTIVE_DOMAIN) {
- bbox_min[0] += (sds->cell_size[0] * (float)sds->res_min[0]);
- bbox_min[1] += (sds->cell_size[1] * (float)sds->res_min[1]);
- bbox_min[2] += (sds->cell_size[2] * (float)sds->res_min[2]);
- add_v3_v3(bbox_min, sds->obj_shift_f);
- }
-
- /* construct low res matrix */
- size_to_mat4(sds->fluidmat, sds->cell_size);
- copy_v3_v3(sds->fluidmat[3], bbox_min);
-
- /* The smoke simulator stores voxels cell-centered, whilst VDB is node
- * centered, so we offset the matrix by half a voxel to compensate. */
- madd_v3_v3fl(sds->fluidmat[3], sds->cell_size, 0.5f);
-
- mul_m4_m4m4(sds->fluidmat, sds->obmat, sds->fluidmat);
-
- if (sds->wt) {
- float voxel_size_high[3];
- /* construct high res matrix */
- mul_v3_v3fl(voxel_size_high, sds->cell_size, 1.0f / (float)(sds->amplify + 1));
- size_to_mat4(sds->fluidmat_wt, voxel_size_high);
- copy_v3_v3(sds->fluidmat_wt[3], bbox_min);
-
- /* Same here, add half a voxel to adjust the position of the fluid. */
- madd_v3_v3fl(sds->fluidmat_wt[3], voxel_size_high, 0.5f);
-
- mul_m4_m4m4(sds->fluidmat_wt, sds->obmat, sds->fluidmat_wt);
- }
-}
-
-static int ptcache_smoke_openvdb_write(struct OpenVDBWriter *writer, void *smoke_v)
-{
- SmokeModifierData *smd = (SmokeModifierData *)smoke_v;
- SmokeDomainSettings *sds = smd->domain;
-
- OpenVDBWriter_set_flags(writer, sds->openvdb_comp, (sds->data_depth == 16));
-
- OpenVDBWriter_add_meta_int(writer, "blender/smoke/active_fields", sds->active_fields);
- OpenVDBWriter_add_meta_v3_int(writer, "blender/smoke/resolution", sds->res);
- OpenVDBWriter_add_meta_v3_int(writer, "blender/smoke/min_resolution", sds->res_min);
- OpenVDBWriter_add_meta_v3_int(writer, "blender/smoke/max_resolution", sds->res_max);
- OpenVDBWriter_add_meta_v3_int(writer, "blender/smoke/base_resolution", sds->base_res);
- OpenVDBWriter_add_meta_v3(writer, "blender/smoke/min_bbox", sds->p0);
- OpenVDBWriter_add_meta_v3(writer, "blender/smoke/max_bbox", sds->p1);
- OpenVDBWriter_add_meta_v3(writer, "blender/smoke/dp0", sds->dp0);
- OpenVDBWriter_add_meta_v3_int(writer, "blender/smoke/shift", sds->shift);
- OpenVDBWriter_add_meta_v3(writer, "blender/smoke/obj_shift_f", sds->obj_shift_f);
- OpenVDBWriter_add_meta_v3(writer, "blender/smoke/active_color", sds->active_color);
- OpenVDBWriter_add_meta_mat4(writer, "blender/smoke/obmat", sds->obmat);
-
- int fluid_fields = smoke_get_data_flags(sds);
-
- struct OpenVDBFloatGrid *clip_grid = NULL;
-
- compute_fluid_matrices(sds);
-
- OpenVDBWriter_add_meta_int(writer, "blender/smoke/fluid_fields", fluid_fields);
-
- if (sds->wt) {
- struct OpenVDBFloatGrid *wt_density_grid;
- float *dens, *react, *fuel, *flame, *tcu, *tcv, *tcw, *r, *g, *b;
-
- smoke_turbulence_export(sds->wt, &dens, &react, &flame, &fuel, &r, &g, &b, &tcu, &tcv, &tcw);
-
- wt_density_grid = OpenVDB_export_grid_fl(writer, "density", dens, sds->res_wt, sds->fluidmat_wt, NULL);
- clip_grid = wt_density_grid;
-
- if (fluid_fields & SM_ACTIVE_FIRE) {
- OpenVDB_export_grid_fl(writer, "flame", flame, sds->res_wt, sds->fluidmat_wt, wt_density_grid);
- OpenVDB_export_grid_fl(writer, "fuel", fuel, sds->res_wt, sds->fluidmat_wt, wt_density_grid);
- OpenVDB_export_grid_fl(writer, "react", react, sds->res_wt, sds->fluidmat_wt, wt_density_grid);
- }
-
- if (fluid_fields & SM_ACTIVE_COLORS) {
- OpenVDB_export_grid_vec(writer, "color", r, g, b, sds->res_wt, sds->fluidmat_wt, VEC_INVARIANT, true, wt_density_grid);
- }
-
- OpenVDB_export_grid_vec(writer, "texture coordinates", tcu, tcv, tcw, sds->res, sds->fluidmat, VEC_INVARIANT, false, wt_density_grid);
- }
-
- if (sds->fluid) {
- struct OpenVDBFloatGrid *density_grid;
- float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold, *vx, *vy, *vz, *r, *g, *b;
- unsigned char *obstacles;
-
- smoke_export(sds->fluid, &dt, &dx, &dens, &react, &flame, &fuel, &heat,
- &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles);
-
- OpenVDBWriter_add_meta_fl(writer, "blender/smoke/dx", dx);
- OpenVDBWriter_add_meta_fl(writer, "blender/smoke/dt", dt);
-
- const char *name = (!sds->wt) ? "density" : "density low";
- density_grid = OpenVDB_export_grid_fl(writer, name, dens, sds->res, sds->fluidmat, NULL);
- clip_grid = sds->wt ? clip_grid : density_grid;
-
- OpenVDB_export_grid_fl(writer, "shadow", sds->shadow, sds->res, sds->fluidmat, NULL);
-
- if (fluid_fields & SM_ACTIVE_HEAT) {
- OpenVDB_export_grid_fl(writer, "heat", heat, sds->res, sds->fluidmat, clip_grid);
- OpenVDB_export_grid_fl(writer, "heat old", heatold, sds->res, sds->fluidmat, clip_grid);
- }
-
- if (fluid_fields & SM_ACTIVE_FIRE) {
- name = (!sds->wt) ? "flame" : "flame low";
- OpenVDB_export_grid_fl(writer, name, flame, sds->res, sds->fluidmat, density_grid);
- name = (!sds->wt) ? "fuel" : "fuel low";
- OpenVDB_export_grid_fl(writer, name, fuel, sds->res, sds->fluidmat, density_grid);
- name = (!sds->wt) ? "react" : "react low";
- OpenVDB_export_grid_fl(writer, name, react, sds->res, sds->fluidmat, density_grid);
- }
-
- if (fluid_fields & SM_ACTIVE_COLORS) {
- name = (!sds->wt) ? "color" : "color low";
- OpenVDB_export_grid_vec(writer, name, r, g, b, sds->res, sds->fluidmat, VEC_INVARIANT, true, density_grid);
- }
-
- OpenVDB_export_grid_vec(writer, "velocity", vx, vy, vz, sds->res, sds->fluidmat, VEC_CONTRAVARIANT_RELATIVE, false, clip_grid);
- OpenVDB_export_grid_ch(writer, "obstacles", obstacles, sds->res, sds->fluidmat, NULL);
- }
-
- return 1;
-}
-
-static int ptcache_smoke_openvdb_read(struct OpenVDBReader *reader, void *smoke_v)
-{
- SmokeModifierData *smd = (SmokeModifierData *)smoke_v;
-
- if (!smd) {
- return 0;
- }
-
- SmokeDomainSettings *sds = smd->domain;
-
- int fluid_fields = smoke_get_data_flags(sds);
- int active_fields, cache_fields = 0;
- int cache_res[3];
- float cache_dx;
- bool reallocate = false;
-
- OpenVDBReader_get_meta_v3_int(reader, "blender/smoke/min_resolution", sds->res_min);
- OpenVDBReader_get_meta_v3_int(reader, "blender/smoke/max_resolution", sds->res_max);
- OpenVDBReader_get_meta_v3_int(reader, "blender/smoke/base_resolution", sds->base_res);
- OpenVDBReader_get_meta_v3(reader, "blender/smoke/min_bbox", sds->p0);
- OpenVDBReader_get_meta_v3(reader, "blender/smoke/max_bbox", sds->p1);
- OpenVDBReader_get_meta_v3(reader, "blender/smoke/dp0", sds->dp0);
- OpenVDBReader_get_meta_v3_int(reader, "blender/smoke/shift", sds->shift);
- OpenVDBReader_get_meta_v3(reader, "blender/smoke/obj_shift_f", sds->obj_shift_f);
- OpenVDBReader_get_meta_v3(reader, "blender/smoke/active_color", sds->active_color);
- OpenVDBReader_get_meta_mat4(reader, "blender/smoke/obmat", sds->obmat);
- OpenVDBReader_get_meta_int(reader, "blender/smoke/fluid_fields", &cache_fields);
- OpenVDBReader_get_meta_int(reader, "blender/smoke/active_fields", &active_fields);
- OpenVDBReader_get_meta_fl(reader, "blender/smoke/dx", &cache_dx);
- OpenVDBReader_get_meta_v3_int(reader, "blender/smoke/resolution", cache_res);
-
- /* check if resolution has changed */
- if (sds->res[0] != cache_res[0] ||
- sds->res[1] != cache_res[1] ||
- sds->res[2] != cache_res[2])
- {
- if (sds->flags & MOD_SMOKE_ADAPTIVE_DOMAIN) {
- reallocate = true;
- }
- else {
- return 0;
- }
- }
-
- /* check if active fields have changed */
- if ((fluid_fields != cache_fields) || (active_fields != sds->active_fields)) {
- reallocate = true;
- }
-
- /* reallocate fluid if needed*/
- if (reallocate) {
- sds->active_fields = active_fields | cache_fields;
- smoke_reallocate_fluid(sds, cache_dx, cache_res, 1);
- sds->dx = cache_dx;
- copy_v3_v3_int(sds->res, cache_res);
- sds->total_cells = cache_res[0] * cache_res[1] * cache_res[2];
-
- if (sds->flags & MOD_SMOKE_HIGHRES) {
- smoke_reallocate_highres_fluid(sds, cache_dx, cache_res, 1);
- }
- }
-
- if (sds->fluid) {
- float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold, *vx, *vy, *vz, *r, *g, *b;
- unsigned char *obstacles;
-
- smoke_export(sds->fluid, &dt, &dx, &dens, &react, &flame, &fuel, &heat,
- &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles);
-
- OpenVDBReader_get_meta_fl(reader, "blender/smoke/dt", &dt);
-
- OpenVDB_import_grid_fl(reader, "shadow", &sds->shadow, sds->res);
-
- const char *name = (!sds->wt) ? "density" : "density low";
- OpenVDB_import_grid_fl(reader, name, &dens, sds->res);
-
- if (cache_fields & SM_ACTIVE_HEAT) {
- OpenVDB_import_grid_fl(reader, "heat", &heat, sds->res);
- OpenVDB_import_grid_fl(reader, "heat old", &heatold, sds->res);
- }
-
- if (cache_fields & SM_ACTIVE_FIRE) {
- name = (!sds->wt) ? "flame" : "flame low";
- OpenVDB_import_grid_fl(reader, name, &flame, sds->res);
- name = (!sds->wt) ? "fuel" : "fuel low";
- OpenVDB_import_grid_fl(reader, name, &fuel, sds->res);
- name = (!sds->wt) ? "react" : "react low";
- OpenVDB_import_grid_fl(reader, name, &react, sds->res);
- }
-
- if (cache_fields & SM_ACTIVE_COLORS) {
- name = (!sds->wt) ? "color" : "color low";
- OpenVDB_import_grid_vec(reader, name, &r, &g, &b, sds->res);
- }
-
- OpenVDB_import_grid_vec(reader, "velocity", &vx, &vy, &vz, sds->res);
- OpenVDB_import_grid_ch(reader, "obstacles", &obstacles, sds->res);
- }
-
- if (sds->wt) {
- float *dens, *react, *fuel, *flame, *tcu, *tcv, *tcw, *r, *g, *b;
-
- smoke_turbulence_export(sds->wt, &dens, &react, &flame, &fuel, &r, &g, &b, &tcu, &tcv, &tcw);
-
- OpenVDB_import_grid_fl(reader, "density", &dens, sds->res_wt);
-
- if (fluid_fields & SM_ACTIVE_FIRE) {
- OpenVDB_import_grid_fl(reader, "flame", &flame, sds->res_wt);
- OpenVDB_import_grid_fl(reader, "fuel", &fuel, sds->res_wt);
- OpenVDB_import_grid_fl(reader, "react", &react, sds->res_wt);
- }
-
- if (fluid_fields & SM_ACTIVE_COLORS) {
- OpenVDB_import_grid_vec(reader, "color", &r, &g, &b, sds->res_wt);
- }
-
- OpenVDB_import_grid_vec(reader, "texture coordinates", &tcu, &tcv, &tcw, sds->res);
- }
-
- OpenVDBReader_free(reader);
-
- return 1;
-}
-#endif
-
-#else // WITH_SMOKE
-static int ptcache_smoke_totpoint(void *UNUSED(smoke_v), int UNUSED(cfra)) { return 0; }
-static void ptcache_smoke_error(void *UNUSED(smoke_v), const char *UNUSED(message)) { }
-static int ptcache_smoke_read(PTCacheFile *UNUSED(pf), void *UNUSED(smoke_v)) { return 0; }
-static int ptcache_smoke_write(PTCacheFile *UNUSED(pf), void *UNUSED(smoke_v)) { return 0; }
-#endif // WITH_SMOKE
-
-#if !defined(WITH_SMOKE) || !defined(WITH_OPENVDB)
-static int ptcache_smoke_openvdb_write(struct OpenVDBWriter *writer, void *smoke_v)
-{
- UNUSED_VARS(writer, smoke_v);
- return 0;
-}
-
-static int ptcache_smoke_openvdb_read(struct OpenVDBReader *reader, void *smoke_v)
-{
- UNUSED_VARS(reader, smoke_v);
- return 0;
-}
-#endif
-
-static int ptcache_dynamicpaint_totpoint(void *sd, int UNUSED(cfra))
-{
- DynamicPaintSurface *surface = (DynamicPaintSurface*)sd;
-
- if (!surface->data) return 0;
- else return surface->data->total_points;
-}
-
-static void ptcache_dynamicpaint_error(void *UNUSED(sd), const char *UNUSED(message))
-{
- /* ignored for now */
-}
-
-#define DPAINT_CACHE_VERSION "1.01"
-
-static int ptcache_dynamicpaint_write(PTCacheFile *pf, void *dp_v)
-{
- DynamicPaintSurface *surface = (DynamicPaintSurface*)dp_v;
- int cache_compress = 1;
-
- /* version header */
- ptcache_file_write(pf, DPAINT_CACHE_VERSION, 1, sizeof(char) * 4);
-
- if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && surface->data) {
- int total_points=surface->data->total_points;
- unsigned int in_len;
- unsigned char *out;
-
- /* cache type */
- ptcache_file_write(pf, &surface->type, 1, sizeof(int));
-
- if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
- in_len = sizeof(PaintPoint) * total_points;
- }
- else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE ||
- surface->type == MOD_DPAINT_SURFACE_T_WEIGHT)
- {
- in_len = sizeof(float) * total_points;
- }
- else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) {
- in_len = sizeof(PaintWavePoint) * total_points;
- }
- else {
- return 0;
- }
-
- out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len), "pointcache_lzo_buffer");
-
- ptcache_file_compressed_write(pf, (unsigned char *)surface->data->type_data, in_len, out, cache_compress);
- MEM_freeN(out);
-
- }
- return 1;
-}
-static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v)
-{
- DynamicPaintSurface *surface = (DynamicPaintSurface*)dp_v;
- char version[4];
-
- /* version header */
- ptcache_file_read(pf, version, 1, sizeof(char) * 4);
- if (!STREQLEN(version, DPAINT_CACHE_VERSION, 4)) {
- printf("Dynamic Paint: Invalid cache version: '%c%c%c%c'!\n", UNPACK4(version));
- return 0;
- }
-
- if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && surface->data) {
- unsigned int data_len;
- int surface_type;
-
- /* cache type */
- ptcache_file_read(pf, &surface_type, 1, sizeof(int));
-
- if (surface_type != surface->type)
- return 0;
-
- /* read surface data */
- if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
- data_len = sizeof(PaintPoint);
- }
- else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE ||
- surface->type == MOD_DPAINT_SURFACE_T_WEIGHT)
- {
- data_len = sizeof(float);
- }
- else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) {
- data_len = sizeof(PaintWavePoint);
- }
- else {
- return 0;
- }
-
- ptcache_file_compressed_read(pf, (unsigned char *)surface->data->type_data, data_len*surface->data->total_points);
-
- }
- return 1;
-}
-
-/* Rigid Body functions */
-static int ptcache_rigidbody_write(int index, void *rb_v, void **data, int UNUSED(cfra))
-{
- RigidBodyWorld *rbw = rb_v;
- Object *ob = NULL;
-
- if (rbw->objects)
- ob = rbw->objects[index];
-
- if (ob && ob->rigidbody_object) {
- RigidBodyOb *rbo = ob->rigidbody_object;
-
- if (rbo->type == RBO_TYPE_ACTIVE) {
-#ifdef WITH_BULLET
- RB_body_get_position(rbo->physics_object, rbo->pos);
- RB_body_get_orientation(rbo->physics_object, rbo->orn);
-#endif
- PTCACHE_DATA_FROM(data, BPHYS_DATA_LOCATION, rbo->pos);
- PTCACHE_DATA_FROM(data, BPHYS_DATA_ROTATION, rbo->orn);
- }
- }
-
- return 1;
-}
-static void ptcache_rigidbody_read(int index, void *rb_v, void **data, float UNUSED(cfra), float *old_data)
-{
- RigidBodyWorld *rbw = rb_v;
- Object *ob = NULL;
-
- if (rbw->objects)
- ob = rbw->objects[index];
-
- if (ob && ob->rigidbody_object) {
- RigidBodyOb *rbo = ob->rigidbody_object;
-
- if (rbo->type == RBO_TYPE_ACTIVE) {
-
- if (old_data) {
- memcpy(rbo->pos, data, 3 * sizeof(float));
- memcpy(rbo->orn, data + 3, 4 * sizeof(float));
- }
- else {
- PTCACHE_DATA_TO(data, BPHYS_DATA_LOCATION, 0, rbo->pos);
- PTCACHE_DATA_TO(data, BPHYS_DATA_ROTATION, 0, rbo->orn);
- }
- }
- }
-}
-static void ptcache_rigidbody_interpolate(int index, void *rb_v, void **data, float cfra, float cfra1, float cfra2, float *old_data)
-{
- RigidBodyWorld *rbw = rb_v;
- Object *ob = NULL;
-
- if (rbw->objects)
- ob = rbw->objects[index];
-
- if (ob && ob->rigidbody_object) {
- RigidBodyOb *rbo = ob->rigidbody_object;
-
- if (rbo->type == RBO_TYPE_ACTIVE) {
- PointCacheKey keys[4];
- PointCacheKey result;
- float dfra;
-
- memset(keys, 0, sizeof(keys));
-
- copy_v3_v3(keys[1].co, rbo->pos);
- copy_qt_qt(keys[1].rot, rbo->orn);
-
- if (old_data) {
- memcpy(keys[2].co, data, 3 * sizeof(float));
- memcpy(keys[2].rot, data + 3, 4 * sizeof(float));
- }
- else {
- BKE_ptcache_make_key(&keys[2], 0, data, cfra2);
- }
-
- dfra = cfra2 - cfra1;
-
- /* note: keys[0] and keys[3] unused for type < 1 (crappy) */
- interpolate_particle_keys(-1, keys, (cfra - cfra1) / dfra, &result, true);
- interp_qt_qtqt(result.rot, keys[1].rot, keys[2].rot, (cfra - cfra1) / dfra);
-
- copy_v3_v3(rbo->pos, result.co);
- copy_qt_qt(rbo->orn, result.rot);
- }
- }
-}
-static int ptcache_rigidbody_totpoint(void *rb_v, int UNUSED(cfra))
-{
- RigidBodyWorld *rbw = rb_v;
-
- return rbw->numbodies;
-}
-
-static void ptcache_rigidbody_error(void *UNUSED(rb_v), const char *UNUSED(message))
-{
- /* ignored for now */
-}
-
-/* Creating ID's */
-void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb)
-{
- memset(pid, 0, sizeof(PTCacheID));
-
- pid->ob= ob;
- pid->calldata= sb;
- pid->type= PTCACHE_TYPE_SOFTBODY;
- pid->cache= sb->pointcache;
- pid->cache_ptr= &sb->pointcache;
- pid->ptcaches= &sb->ptcaches;
- pid->totpoint= pid->totwrite= ptcache_softbody_totpoint;
- pid->error = ptcache_softbody_error;
-
- pid->write_point = ptcache_softbody_write;
- pid->read_point = ptcache_softbody_read;
- pid->interpolate_point = ptcache_softbody_interpolate;
-
- pid->write_stream = NULL;
- pid->read_stream = NULL;
-
- pid->write_openvdb_stream = NULL;
- pid->read_openvdb_stream = NULL;
-
- pid->write_extra_data = NULL;
- pid->read_extra_data = NULL;
- pid->interpolate_extra_data = NULL;
-
- pid->write_header = ptcache_basic_header_write;
- pid->read_header = ptcache_basic_header_read;
-
- pid->data_types= (1<<BPHYS_DATA_LOCATION) | (1<<BPHYS_DATA_VELOCITY);
- pid->info_types= 0;
-
- pid->stack_index = pid->cache->index;
-
- pid->default_step = 10;
- pid->max_step = 20;
- pid->file_type = PTCACHE_FILE_PTCACHE;
-}
-void BKE_ptcache_id_from_cloth(PTCacheID *pid, Object *ob, ClothModifierData *clmd)
-{
- memset(pid, 0, sizeof(PTCacheID));
-
- pid->ob= ob;
- pid->calldata= clmd;
- pid->type= PTCACHE_TYPE_CLOTH;
- pid->stack_index= clmd->point_cache->index;
- pid->cache= clmd->point_cache;
- pid->cache_ptr= &clmd->point_cache;
- pid->ptcaches= &clmd->ptcaches;
- pid->totpoint= pid->totwrite= ptcache_cloth_totpoint;
- pid->error = ptcache_cloth_error;
-
- pid->write_point = ptcache_cloth_write;
- pid->read_point = ptcache_cloth_read;
- pid->interpolate_point = ptcache_cloth_interpolate;
-
- pid->write_openvdb_stream = NULL;
- pid->read_openvdb_stream = NULL;
-
- pid->write_stream = NULL;
- pid->read_stream = NULL;
-
- pid->write_extra_data = NULL;
- pid->read_extra_data = NULL;
- pid->interpolate_extra_data = NULL;
-
- pid->write_header = ptcache_basic_header_write;
- pid->read_header = ptcache_basic_header_read;
-
- pid->data_types= (1<<BPHYS_DATA_LOCATION) | (1<<BPHYS_DATA_VELOCITY) | (1<<BPHYS_DATA_XCONST);
- pid->info_types= 0;
-
- pid->default_step = 1;
- pid->max_step = 1;
- pid->file_type = PTCACHE_FILE_PTCACHE;
-}
-void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd)
-{
- SmokeDomainSettings *sds = smd->domain;
-
- memset(pid, 0, sizeof(PTCacheID));
-
- pid->ob= ob;
- pid->calldata= smd;
-
- pid->type= PTCACHE_TYPE_SMOKE_DOMAIN;
- pid->stack_index= sds->point_cache[0]->index;
-
- pid->cache= sds->point_cache[0];
- pid->cache_ptr= &(sds->point_cache[0]);
- pid->ptcaches= &(sds->ptcaches[0]);
-
- pid->totpoint= pid->totwrite= ptcache_smoke_totpoint;
- pid->error = ptcache_smoke_error;
-
- pid->write_point = NULL;
- pid->read_point = NULL;
- pid->interpolate_point = NULL;
-
- pid->read_stream = ptcache_smoke_read;
- pid->write_stream = ptcache_smoke_write;
-
- pid->write_openvdb_stream = ptcache_smoke_openvdb_write;
- pid->read_openvdb_stream = ptcache_smoke_openvdb_read;
-
- pid->write_extra_data = NULL;
- pid->read_extra_data = NULL;
- pid->interpolate_extra_data = NULL;
-
- pid->write_header = ptcache_basic_header_write;
- pid->read_header = ptcache_basic_header_read;
-
- pid->data_types= 0;
- pid->info_types= 0;
-
- if (sds->fluid)
- pid->data_types |= (1<<BPHYS_DATA_SMOKE_LOW);
- if (sds->wt)
- pid->data_types |= (1<<BPHYS_DATA_SMOKE_HIGH);
-
- pid->default_step = 1;
- pid->max_step = 1;
- pid->file_type = smd->domain->cache_file_format;
-}
-
-void BKE_ptcache_id_from_dynamicpaint(PTCacheID *pid, Object *ob, DynamicPaintSurface *surface)
-{
-
- memset(pid, 0, sizeof(PTCacheID));
-
- pid->ob= ob;
- pid->calldata= surface;
- pid->type= PTCACHE_TYPE_DYNAMICPAINT;
- pid->cache= surface->pointcache;
- pid->cache_ptr= &surface->pointcache;
- pid->ptcaches= &surface->ptcaches;
- pid->totpoint= pid->totwrite= ptcache_dynamicpaint_totpoint;
- pid->error = ptcache_dynamicpaint_error;
-
- pid->write_point = NULL;
- pid->read_point = NULL;
- pid->interpolate_point = NULL;
-
- pid->write_stream = ptcache_dynamicpaint_write;
- pid->read_stream = ptcache_dynamicpaint_read;
-
- pid->write_openvdb_stream = NULL;
- pid->read_openvdb_stream = NULL;
-
- pid->write_extra_data = NULL;
- pid->read_extra_data = NULL;
- pid->interpolate_extra_data = NULL;
-
- pid->write_header = ptcache_basic_header_write;
- pid->read_header = ptcache_basic_header_read;
-
- pid->data_types= BPHYS_DATA_DYNAMICPAINT;
- pid->info_types= 0;
-
- pid->stack_index = pid->cache->index;
-
- pid->default_step = 1;
- pid->max_step = 1;
- pid->file_type = PTCACHE_FILE_PTCACHE;
-}
-
-void BKE_ptcache_id_from_rigidbody(PTCacheID *pid, Object *ob, RigidBodyWorld *rbw)
-{
-
- memset(pid, 0, sizeof(PTCacheID));
-
- pid->ob= ob;
- pid->calldata= rbw;
- pid->type= PTCACHE_TYPE_RIGIDBODY;
- pid->cache= rbw->pointcache;
- pid->cache_ptr= &rbw->pointcache;
- pid->ptcaches= &rbw->ptcaches;
- pid->totpoint= pid->totwrite= ptcache_rigidbody_totpoint;
- pid->error = ptcache_rigidbody_error;
-
- pid->write_point = ptcache_rigidbody_write;
- pid->read_point = ptcache_rigidbody_read;
- pid->interpolate_point = ptcache_rigidbody_interpolate;
-
- pid->write_stream = NULL;
- pid->read_stream = NULL;
-
- pid->write_openvdb_stream = NULL;
- pid->read_openvdb_stream = NULL;
-
- pid->write_extra_data = NULL;
- pid->read_extra_data = NULL;
- pid->interpolate_extra_data = NULL;
-
- pid->write_header = ptcache_basic_header_write;
- pid->read_header = ptcache_basic_header_read;
-
- pid->data_types= (1<<BPHYS_DATA_LOCATION) | (1<<BPHYS_DATA_ROTATION);
- pid->info_types= 0;
-
- pid->stack_index = pid->cache->index;
-
- pid->default_step = 1;
- pid->max_step = 1;
- pid->file_type = PTCACHE_FILE_PTCACHE;
-}
-
-void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int duplis)
-{
- PTCacheID *pid;
- ModifierData *md;
-
- lb->first= lb->last= NULL;
-
- if (ob->soft) {
- pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID");
- BKE_ptcache_id_from_softbody(pid, ob, ob->soft);
- BLI_addtail(lb, pid);
- }
-
- for (md=ob->modifiers.first; md; md=md->next) {
- if (md->type == eModifierType_Cloth) {
- pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID");
- BKE_ptcache_id_from_cloth(pid, ob, (ClothModifierData*)md);
- BLI_addtail(lb, pid);
- }
- else if (md->type == eModifierType_Smoke) {
- SmokeModifierData *smd = (SmokeModifierData *)md;
- if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
- pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID");
- BKE_ptcache_id_from_smoke(pid, ob, (SmokeModifierData*)md);
- BLI_addtail(lb, pid);
- }
- }
- else if (md->type == eModifierType_DynamicPaint) {
- DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
- if (pmd->canvas) {
- DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
-
- for (; surface; surface=surface->next) {
- pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID");
- BKE_ptcache_id_from_dynamicpaint(pid, ob, surface);
- BLI_addtail(lb, pid);
- }
- }
- }
- }
-
- if (scene && ob->rigidbody_object && scene->rigidbody_world) {
- pid = MEM_callocN(sizeof(PTCacheID), "PTCacheID");
- BKE_ptcache_id_from_rigidbody(pid, ob, scene->rigidbody_world);
- BLI_addtail(lb, pid);
- }
-
- if (scene && (duplis-- > 0) && (ob->transflag & OB_DUPLI)) {
- ListBase *lb_dupli_ob;
- /* don't update the dupli groups, we only want their pid's */
- if ((lb_dupli_ob = object_duplilist_ex(G.main->eval_ctx, scene, ob, false))) {
- DupliObject *dob;
- for (dob= lb_dupli_ob->first; dob; dob= dob->next) {
- if (dob->ob != ob) { /* avoids recursive loops with dupliframes: bug 22988 */
- ListBase lb_dupli_pid;
- BKE_ptcache_ids_from_object(&lb_dupli_pid, dob->ob, scene, duplis);
- BLI_movelisttolist(lb, &lb_dupli_pid);
- if (lb_dupli_pid.first)
- printf("Adding Dupli\n");
- }
- }
-
- free_object_duplilist(lb_dupli_ob); /* does restore */
- }
- }
-}
-
-/* File handling */
-
-static const char *ptcache_file_extension(const PTCacheID *pid)
-{
- switch (pid->file_type) {
- default:
- case PTCACHE_FILE_PTCACHE:
- return PTCACHE_EXT;
- case PTCACHE_FILE_OPENVDB:
- return ".vdb";
- }
-}
-
-/**
- * Similar to #BLI_path_frame_get, but takes into account the stack-index which is after the frame.
- */
-static int ptcache_frame_from_filename(const char *filename, const char *ext)
-{
- const int frame_len = 6;
- const int ext_len = frame_len + strlen(ext);
- const int len = strlen(filename);
-
- /* could crash if trying to copy a string out of this range */
- if (len > ext_len) {
- /* using frame_len here gives compile error (vla) */
- char num[/* frame_len */6 + 1];
- BLI_strncpy(num, filename + len - ext_len, sizeof(num));
-
- return atoi(num);
- }
-
- return -1;
-}
-
-/* Takes an Object ID and returns a unique name
- * - id: object id
- * - cfra: frame for the cache, can be negative
- * - stack_index: index in the modifier stack. we can have cache for more than one stack_index
- */
-
-#define MAX_PTCACHE_PATH FILE_MAX
-#define MAX_PTCACHE_FILE (FILE_MAX * 2)
-
-static int ptcache_path(PTCacheID *pid, char *filename)
-{
- Library *lib = (pid->ob) ? pid->ob->id.lib : NULL;
- const char *blendfilename= (lib && (pid->cache->flag & PTCACHE_IGNORE_LIBPATH)==0) ? lib->filepath: G.main->name;
- size_t i;
-
- if (pid->cache->flag & PTCACHE_EXTERNAL) {
- strcpy(filename, pid->cache->path);
-
- if (BLI_path_is_rel(filename)) {
- BLI_path_abs(filename, blendfilename);
- }
-
- return BLI_add_slash(filename); /* new strlen() */
- }
- else if (G.relbase_valid || lib) {
- char file[MAX_PTCACHE_PATH]; /* we don't want the dir, only the file */
-
- BLI_split_file_part(blendfilename, file, sizeof(file));
- i = strlen(file);
-
- /* remove .blend */
- if (i > 6)
- file[i-6] = '\0';
-
- BLI_snprintf(filename, MAX_PTCACHE_PATH, "//"PTCACHE_PATH"%s", file); /* add blend file name to pointcache dir */
- BLI_path_abs(filename, blendfilename);
- return BLI_add_slash(filename); /* new strlen() */
- }
-
- /* use the temp path. this is weak but better then not using point cache at all */
- /* temporary directory is assumed to exist and ALWAYS has a trailing slash */
- BLI_snprintf(filename, MAX_PTCACHE_PATH, "%s"PTCACHE_PATH, BKE_tempdir_session());
-
- return BLI_add_slash(filename); /* new strlen() */
-}
-
-static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_path, short do_ext)
-{
- int len=0;
- char *idname;
- char *newname;
- filename[0] = '\0';
- newname = filename;
-
- if (!G.relbase_valid && (pid->cache->flag & PTCACHE_EXTERNAL)==0) return 0; /* save blend file before using disk pointcache */
-
- /* start with temp dir */
- if (do_path) {
- len = ptcache_path(pid, filename);
- newname += len;
- }
- if (pid->cache->name[0] == '\0' && (pid->cache->flag & PTCACHE_EXTERNAL)==0) {
- idname = (pid->ob->id.name + 2);
- /* convert chars to hex so they are always a valid filename */
- while ('\0' != *idname) {
- BLI_snprintf(newname, MAX_PTCACHE_FILE, "%02X", (unsigned int)(*idname++));
- newname+=2;
- len += 2;
- }
- }
- else {
- int temp = (int)strlen(pid->cache->name);
- strcpy(newname, pid->cache->name);
- newname+=temp;
- len += temp;
- }
-
- if (do_ext) {
- if (pid->cache->index < 0)
- pid->cache->index = pid->stack_index = BKE_object_insert_ptcache(pid->ob);
-
- const char *ext = ptcache_file_extension(pid);
-
- if (pid->cache->flag & PTCACHE_EXTERNAL) {
- if (pid->cache->index >= 0)
- BLI_snprintf(newname, MAX_PTCACHE_FILE, "_%06d_%02u%s", cfra, pid->stack_index, ext); /* always 6 chars */
- else
- BLI_snprintf(newname, MAX_PTCACHE_FILE, "_%06d%s", cfra, ext); /* always 6 chars */
- }
- else {
- BLI_snprintf(newname, MAX_PTCACHE_FILE, "_%06d_%02u%s", cfra, pid->stack_index, ext); /* always 6 chars */
- }
- len += 16;
- }
-
- return len; /* make sure the above string is always 16 chars */
-}
-
-/* youll need to close yourself after! */
-static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra)
-{
- PTCacheFile *pf;
- FILE *fp = NULL;
- char filename[FILE_MAX * 2];
-
-#ifndef DURIAN_POINTCACHE_LIB_OK
- /* don't allow writing for linked objects */
- if (pid->ob->id.lib && mode == PTCACHE_FILE_WRITE)
- return NULL;
-#endif
- if (!G.relbase_valid && (pid->cache->flag & PTCACHE_EXTERNAL)==0) return NULL; /* save blend file before using disk pointcache */
-
- ptcache_filename(pid, filename, cfra, 1, 1);
-
- if (mode==PTCACHE_FILE_READ) {
- fp = BLI_fopen(filename, "rb");
- }
- else if (mode==PTCACHE_FILE_WRITE) {
- BLI_make_existing_file(filename); /* will create the dir if needs be, same as //textures is created */
- fp = BLI_fopen(filename, "wb");
- }
- else if (mode==PTCACHE_FILE_UPDATE) {
- BLI_make_existing_file(filename);
- fp = BLI_fopen(filename, "rb+");
- }
-
- if (!fp)
- return NULL;
-
- pf= MEM_mallocN(sizeof(PTCacheFile), "PTCacheFile");
- pf->fp= fp;
- pf->old_format = 0;
- pf->frame = cfra;
-
- return pf;
-}
-static void ptcache_file_close(PTCacheFile *pf)
-{
- if (pf) {
- fclose(pf->fp);
- MEM_freeN(pf);
- }
-}
-
-static int ptcache_file_compressed_read(PTCacheFile *pf, unsigned char *result, unsigned int len)
-{
- int r = 0;
- unsigned char compressed = 0;
- size_t in_len;
-#ifdef WITH_LZO
- size_t out_len = len;
-#endif
- unsigned char *in;
- unsigned char *props = MEM_callocN(16 * sizeof(char), "tmp");
-
- ptcache_file_read(pf, &compressed, 1, sizeof(unsigned char));
- if (compressed) {
- unsigned int size;
- ptcache_file_read(pf, &size, 1, sizeof(unsigned int));
- in_len = (size_t)size;
- if (in_len==0) {
- /* do nothing */
- }
- else {
- in = (unsigned char *)MEM_callocN(sizeof(unsigned char)*in_len, "pointcache_compressed_buffer");
- ptcache_file_read(pf, in, in_len, sizeof(unsigned char));
-#ifdef WITH_LZO
- if (compressed == 1)
- r = lzo1x_decompress_safe(in, (lzo_uint)in_len, result, (lzo_uint *)&out_len, NULL);
-#endif
-#ifdef WITH_LZMA
- if (compressed == 2) {
- size_t sizeOfIt;
- size_t leni = in_len, leno = len;
- ptcache_file_read(pf, &size, 1, sizeof(unsigned int));
- sizeOfIt = (size_t)size;
- ptcache_file_read(pf, props, sizeOfIt, sizeof(unsigned char));
- r = LzmaUncompress(result, &leno, in, &leni, props, sizeOfIt);
- }
-#endif
- MEM_freeN(in);
- }
- }
- else {
- ptcache_file_read(pf, result, len, sizeof(unsigned char));
- }
-
- MEM_freeN(props);
-
- return r;
-}
-static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, unsigned int in_len, unsigned char *out, int mode)
-{
- int r = 0;
- unsigned char compressed = 0;
- size_t out_len= 0;
- unsigned char *props = MEM_callocN(16 * sizeof(char), "tmp");
- size_t sizeOfIt = 5;
-
- (void)mode; /* unused when building w/o compression */
-
-#ifdef WITH_LZO
- out_len= LZO_OUT_LEN(in_len);
- if (mode == 1) {
- LZO_HEAP_ALLOC(wrkmem, LZO1X_MEM_COMPRESS);
-
- r = lzo1x_1_compress(in, (lzo_uint)in_len, out, (lzo_uint *)&out_len, wrkmem);
- if (!(r == LZO_E_OK) || (out_len >= in_len))
- compressed = 0;
- else
- compressed = 1;
- }
-#endif
-#ifdef WITH_LZMA
- if (mode == 2) {
-
- r = LzmaCompress(out, &out_len, in, in_len, //assume sizeof(char)==1....
- props, &sizeOfIt, 5, 1 << 24, 3, 0, 2, 32, 2);
-
- if (!(r == SZ_OK) || (out_len >= in_len))
- compressed = 0;
- else
- compressed = 2;
- }
-#endif
-
- ptcache_file_write(pf, &compressed, 1, sizeof(unsigned char));
- if (compressed) {
- unsigned int size = out_len;
- ptcache_file_write(pf, &size, 1, sizeof(unsigned int));
- ptcache_file_write(pf, out, out_len, sizeof(unsigned char));
- }
- else
- ptcache_file_write(pf, in, in_len, sizeof(unsigned char));
-
- if (compressed == 2) {
- unsigned int size = sizeOfIt;
- ptcache_file_write(pf, &sizeOfIt, 1, sizeof(unsigned int));
- ptcache_file_write(pf, props, size, sizeof(unsigned char));
- }
-
- MEM_freeN(props);
-
- return r;
-}
-static int ptcache_file_read(PTCacheFile *pf, void *f, unsigned int tot, unsigned int size)
-{
- return (fread(f, size, tot, pf->fp) == tot);
-}
-static int ptcache_file_write(PTCacheFile *pf, const void *f, unsigned int tot, unsigned int size)
-{
- return (fwrite(f, size, tot, pf->fp) == tot);
-}
-static int ptcache_file_data_read(PTCacheFile *pf)
-{
- int i;
-
- for (i=0; i<BPHYS_TOT_DATA; i++) {
- if ((pf->data_types & (1<<i)) && !ptcache_file_read(pf, pf->cur[i], 1, ptcache_data_size[i]))
- return 0;
- }
-
- return 1;
-}
-static int ptcache_file_data_write(PTCacheFile *pf)
-{
- int i;
-
- for (i=0; i<BPHYS_TOT_DATA; i++) {
- if ((pf->data_types & (1<<i)) && !ptcache_file_write(pf, pf->cur[i], 1, ptcache_data_size[i]))
- return 0;
- }
-
- return 1;
-}
-static int ptcache_file_header_begin_read(PTCacheFile *pf)
-{
- unsigned int typeflag=0;
- int error=0;
- char bphysics[8];
-
- pf->data_types = 0;
-
- if (fread(bphysics, sizeof(char), 8, pf->fp) != 8)
- error = 1;
-
- if (!error && !STREQLEN(bphysics, "BPHYSICS", 8))
- error = 1;
-
- if (!error && !fread(&typeflag, sizeof(unsigned int), 1, pf->fp))
- error = 1;
-
- pf->type = (typeflag & PTCACHE_TYPEFLAG_TYPEMASK);
- pf->flag = (typeflag & PTCACHE_TYPEFLAG_FLAGMASK);
-
- /* if there was an error set file as it was */
- if (error)
- fseek(pf->fp, 0, SEEK_SET);
-
- return !error;
-}
-static int ptcache_file_header_begin_write(PTCacheFile *pf)
-{
- const char *bphysics = "BPHYSICS";
- unsigned int typeflag = pf->type + pf->flag;
-
- if (fwrite(bphysics, sizeof(char), 8, pf->fp) != 8)
- return 0;
-
- if (!fwrite(&typeflag, sizeof(unsigned int), 1, pf->fp))
- return 0;
-
- return 1;
-}
-
-/* Data pointer handling */
-int BKE_ptcache_data_size(int data_type)
-{
- return ptcache_data_size[data_type];
-}
-
-static void ptcache_file_pointers_init(PTCacheFile *pf)
-{
- int data_types = pf->data_types;
-
- pf->cur[BPHYS_DATA_INDEX] = (data_types & (1<<BPHYS_DATA_INDEX)) ? &pf->data.index : NULL;
- pf->cur[BPHYS_DATA_LOCATION] = (data_types & (1<<BPHYS_DATA_LOCATION)) ? &pf->data.loc : NULL;
- pf->cur[BPHYS_DATA_VELOCITY] = (data_types & (1<<BPHYS_DATA_VELOCITY)) ? &pf->data.vel : NULL;
- pf->cur[BPHYS_DATA_ROTATION] = (data_types & (1<<BPHYS_DATA_ROTATION)) ? &pf->data.rot : NULL;
- pf->cur[BPHYS_DATA_AVELOCITY] = (data_types & (1<<BPHYS_DATA_AVELOCITY))? &pf->data.ave : NULL;
- pf->cur[BPHYS_DATA_SIZE] = (data_types & (1<<BPHYS_DATA_SIZE)) ? &pf->data.size : NULL;
- pf->cur[BPHYS_DATA_TIMES] = (data_types & (1<<BPHYS_DATA_TIMES)) ? &pf->data.times : NULL;
-}
-
-/* Check to see if point number "index" is in pm, uses binary search for index data. */
-int BKE_ptcache_mem_index_find(PTCacheMem *pm, unsigned int index)
-{
- if (pm->totpoint > 0 && pm->data[BPHYS_DATA_INDEX]) {
- unsigned int *data = pm->data[BPHYS_DATA_INDEX];
- unsigned int mid, low = 0, high = pm->totpoint - 1;
-
- if (index < *data || index > *(data+high))
- return -1;
-
- /* check simple case for continuous indexes first */
- if (index-*data < high && data[index-*data] == index)
- return index-*data;
-
- while (low <= high) {
- mid= (low + high)/2;
-
- if (data[mid] > index)
- high = mid - 1;
- else if (data[mid] < index)
- low = mid + 1;
- else
- return mid;
- }
-
- return -1;
- }
- else {
- return (index < pm->totpoint ? index : -1);
- }
-}
-
-void BKE_ptcache_mem_pointers_init(PTCacheMem *pm)
-{
- int data_types = pm->data_types;
- int i;
-
- for (i=0; i<BPHYS_TOT_DATA; i++)
- pm->cur[i] = ((data_types & (1<<i)) ? pm->data[i] : NULL);
-}
-
-void BKE_ptcache_mem_pointers_incr(PTCacheMem *pm)
-{
- int i;
-
- for (i=0; i<BPHYS_TOT_DATA; i++) {
- if (pm->cur[i])
- pm->cur[i] = (char *)pm->cur[i] + ptcache_data_size[i];
- }
-}
-int BKE_ptcache_mem_pointers_seek(int point_index, PTCacheMem *pm)
-{
- int data_types = pm->data_types;
- int i, index = BKE_ptcache_mem_index_find(pm, point_index);
-
- if (index < 0) {
- /* Can't give proper location without reallocation, so don't give any location.
- * Some points will be cached improperly, but this only happens with simulation
- * steps bigger than cache->step, so the cache has to be recalculated anyways
- * at some point.
- */
- return 0;
- }
-
- for (i=0; i<BPHYS_TOT_DATA; i++)
- pm->cur[i] = data_types & (1<<i) ? (char *)pm->data[i] + index * ptcache_data_size[i] : NULL;
-
- return 1;
-}
-static void ptcache_data_alloc(PTCacheMem *pm)
-{
- int data_types = pm->data_types;
- int totpoint = pm->totpoint;
- int i;
-
- for (i=0; i<BPHYS_TOT_DATA; i++) {
- if (data_types & (1<<i))
- pm->data[i] = MEM_callocN(totpoint * ptcache_data_size[i], "PTCache Data");
- }
-}
-static void ptcache_data_free(PTCacheMem *pm)
-{
- void **data = pm->data;
- int i;
-
- for (i=0; i<BPHYS_TOT_DATA; i++) {
- if (data[i])
- MEM_freeN(data[i]);
- }
-}
-static void ptcache_data_copy(void *from[], void *to[])
-{
- int i;
- for (i=0; i<BPHYS_TOT_DATA; i++) {
- /* note, durian file 03.4b_comp crashes if to[i] is not tested
- * its NULL, not sure if this should be fixed elsewhere but for now its needed */
- if (from[i] && to[i])
- memcpy(to[i], from[i], ptcache_data_size[i]);
- }
-}
-
-static void ptcache_extra_free(PTCacheMem *pm)
-{
- PTCacheExtra *extra = pm->extradata.first;
-
- if (extra) {
- for (; extra; extra=extra->next) {
- if (extra->data)
- MEM_freeN(extra->data);
- }
-
- BLI_freelistN(&pm->extradata);
- }
-}
-static int ptcache_old_elemsize(PTCacheID *pid)
-{
- if (pid->type==PTCACHE_TYPE_SOFTBODY)
- return 6 * sizeof(float);
- else if (pid->type==PTCACHE_TYPE_CLOTH)
- return 9 * sizeof(float);
-
- return 0;
-}
-
-static void ptcache_find_frames_around(PTCacheID *pid, unsigned int frame, int *fra1, int *fra2)
-{
- if (pid->cache->flag & PTCACHE_DISK_CACHE) {
- int cfra1=frame, cfra2=frame+1;
-
- while (cfra1 >= pid->cache->startframe && !BKE_ptcache_id_exist(pid, cfra1))
- cfra1--;
-
- if (cfra1 < pid->cache->startframe)
- cfra1 = 0;
-
- while (cfra2 <= pid->cache->endframe && !BKE_ptcache_id_exist(pid, cfra2))
- cfra2++;
-
- if (cfra2 > pid->cache->endframe)
- cfra2 = 0;
-
- if (cfra1 && !cfra2) {
- *fra1 = 0;
- *fra2 = cfra1;
- }
- else {
- *fra1 = cfra1;
- *fra2 = cfra2;
- }
- }
- else if (pid->cache->mem_cache.first) {
- PTCacheMem *pm = pid->cache->mem_cache.first;
- PTCacheMem *pm2 = pid->cache->mem_cache.last;
-
- while (pm->next && pm->next->frame <= frame)
- pm= pm->next;
-
- if (pm2->frame < frame) {
- pm2 = NULL;
- }
- else {
- while (pm2->prev && pm2->prev->frame > frame) {
- pm2= pm2->prev;
- }
- }
-
- if (!pm2) {
- *fra1 = 0;
- *fra2 = pm->frame;
- }
- else {
- *fra1 = pm->frame;
- *fra2 = pm2->frame;
- }
- }
-}
-
-static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra)
-{
- PTCacheFile *pf = ptcache_file_open(pid, PTCACHE_FILE_READ, cfra);
- PTCacheMem *pm = NULL;
- unsigned int i, error = 0;
-
- if (pf == NULL)
- return NULL;
-
- if (!ptcache_file_header_begin_read(pf))
- error = 1;
-
- if (!error && (pf->type != pid->type || !pid->read_header(pf)))
- error = 1;
-
- if (!error) {
- pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache mem");
-
- pm->totpoint = pf->totpoint;
- pm->data_types = pf->data_types;
- pm->frame = pf->frame;
-
- ptcache_data_alloc(pm);
-
- if (pf->flag & PTCACHE_TYPEFLAG_COMPRESS) {
- for (i=0; i<BPHYS_TOT_DATA; i++) {
- unsigned int out_len = pm->totpoint*ptcache_data_size[i];
- if (pf->data_types & (1<<i))
- ptcache_file_compressed_read(pf, (unsigned char *)(pm->data[i]), out_len);
- }
- }
- else {
- BKE_ptcache_mem_pointers_init(pm);
- ptcache_file_pointers_init(pf);
-
- for (i=0; i<pm->totpoint; i++) {
- if (!ptcache_file_data_read(pf)) {
- error = 1;
- break;
- }
- ptcache_data_copy(pf->cur, pm->cur);
- BKE_ptcache_mem_pointers_incr(pm);
- }
- }
- }
-
- if (!error && pf->flag & PTCACHE_TYPEFLAG_EXTRADATA) {
- unsigned int extratype = 0;
-
- while (ptcache_file_read(pf, &extratype, 1, sizeof(unsigned int))) {
- PTCacheExtra *extra = MEM_callocN(sizeof(PTCacheExtra), "Pointcache extradata");
-
- extra->type = extratype;
-
- ptcache_file_read(pf, &extra->totdata, 1, sizeof(unsigned int));
-
- extra->data = MEM_callocN(extra->totdata * ptcache_extra_datasize[extra->type], "Pointcache extradata->data");
-
- if (pf->flag & PTCACHE_TYPEFLAG_COMPRESS)
- ptcache_file_compressed_read(pf, (unsigned char *)(extra->data), extra->totdata*ptcache_extra_datasize[extra->type]);
- else
- ptcache_file_read(pf, extra->data, extra->totdata, ptcache_extra_datasize[extra->type]);
-
- BLI_addtail(&pm->extradata, extra);
- }
- }
-
- if (error && pm) {
- ptcache_data_free(pm);
- ptcache_extra_free(pm);
- MEM_freeN(pm);
- pm = NULL;
- }
-
- ptcache_file_close(pf);
-
- if (error && G.debug & G_DEBUG)
- printf("Error reading from disk cache\n");
-
- return pm;
-}
-static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm)
-{
- PTCacheFile *pf = NULL;
- unsigned int i, error = 0;
-
- BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, pm->frame);
-
- pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, pm->frame);
-
- if (pf==NULL) {
- if (G.debug & G_DEBUG)
- printf("Error opening disk cache file for writing\n");
- return 0;
- }
-
- pf->data_types = pm->data_types;
- pf->totpoint = pm->totpoint;
- pf->type = pid->type;
- pf->flag = 0;
-
- if (pm->extradata.first)
- pf->flag |= PTCACHE_TYPEFLAG_EXTRADATA;
-
- if (pid->cache->compression)
- pf->flag |= PTCACHE_TYPEFLAG_COMPRESS;
-
- if (!ptcache_file_header_begin_write(pf) || !pid->write_header(pf))
- error = 1;
-
- if (!error) {
- if (pid->cache->compression) {
- for (i=0; i<BPHYS_TOT_DATA; i++) {
- if (pm->data[i]) {
- unsigned int in_len = pm->totpoint*ptcache_data_size[i];
- unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len) * 4, "pointcache_lzo_buffer");
- ptcache_file_compressed_write(pf, (unsigned char *)(pm->data[i]), in_len, out, pid->cache->compression);
- MEM_freeN(out);
- }
- }
- }
- else {
- BKE_ptcache_mem_pointers_init(pm);
- ptcache_file_pointers_init(pf);
-
- for (i=0; i<pm->totpoint; i++) {
- ptcache_data_copy(pm->cur, pf->cur);
- if (!ptcache_file_data_write(pf)) {
- error = 1;
- break;
- }
- BKE_ptcache_mem_pointers_incr(pm);
- }
- }
- }
-
- if (!error && pm->extradata.first) {
- PTCacheExtra *extra = pm->extradata.first;
-
- for (; extra; extra=extra->next) {
- if (extra->data == NULL || extra->totdata == 0)
- continue;
-
- ptcache_file_write(pf, &extra->type, 1, sizeof(unsigned int));
- ptcache_file_write(pf, &extra->totdata, 1, sizeof(unsigned int));
-
- if (pid->cache->compression) {
- unsigned int in_len = extra->totdata * ptcache_extra_datasize[extra->type];
- unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len) * 4, "pointcache_lzo_buffer");
- ptcache_file_compressed_write(pf, (unsigned char *)(extra->data), in_len, out, pid->cache->compression);
- MEM_freeN(out);
- }
- else {
- ptcache_file_write(pf, extra->data, extra->totdata, ptcache_extra_datasize[extra->type]);
- }
- }
- }
-
- ptcache_file_close(pf);
-
- if (error && G.debug & G_DEBUG)
- printf("Error writing to disk cache\n");
-
- return error==0;
-}
-
-static int ptcache_read_stream(PTCacheID *pid, int cfra)
-{
- PTCacheFile *pf = ptcache_file_open(pid, PTCACHE_FILE_READ, cfra);
- int error = 0;
-
- if (pid->read_stream == NULL)
- return 0;
-
- if (pf == NULL) {
- if (G.debug & G_DEBUG)
- printf("Error opening disk cache file for reading\n");
- return 0;
- }
-
- if (!ptcache_file_header_begin_read(pf)) {
- pid->error(pid->calldata, "Failed to read point cache file");
- error = 1;
- }
- else if (pf->type != pid->type) {
- pid->error(pid->calldata, "Point cache file has wrong type");
- error = 1;
- }
- else if (!pid->read_header(pf)) {
- pid->error(pid->calldata, "Failed to read point cache file header");
- error = 1;
- }
- else if (pf->totpoint != pid->totpoint(pid->calldata, cfra)) {
- pid->error(pid->calldata, "Number of points in cache does not match mesh");
- error = 1;
- }
-
- if (!error) {
- ptcache_file_pointers_init(pf);
-
- // we have stream reading here
- if (!pid->read_stream(pf, pid->calldata)) {
- pid->error(pid->calldata, "Failed to read point cache file data");
- error = 1;
- }
- }
-
- ptcache_file_close(pf);
-
- return error == 0;
-}
-
-static int ptcache_read_openvdb_stream(PTCacheID *pid, int cfra)
-{
-#ifdef WITH_OPENVDB
- char filename[FILE_MAX * 2];
-
- /* save blend file before using disk pointcache */
- if (!G.relbase_valid && (pid->cache->flag & PTCACHE_EXTERNAL) == 0)
- return 0;
-
- ptcache_filename(pid, filename, cfra, 1, 1);
-
- if (!BLI_exists(filename)) {
- return 0;
- }
-
- struct OpenVDBReader *reader = OpenVDBReader_create();
- OpenVDBReader_open(reader, filename);
-
- if (!pid->read_openvdb_stream(reader, pid->calldata)) {
- return 0;
- }
-
- return 1;
-#else
- UNUSED_VARS(pid, cfra);
- return 0;
-#endif
-}
-
-static int ptcache_read(PTCacheID *pid, int cfra)
-{
- PTCacheMem *pm = NULL;
- int i;
- int *index = &i;
-
- /* get a memory cache to read from */
- if (pid->cache->flag & PTCACHE_DISK_CACHE) {
- pm = ptcache_disk_frame_to_mem(pid, cfra);
- }
- else {
- pm = pid->cache->mem_cache.first;
-
- while (pm && pm->frame != cfra)
- pm = pm->next;
- }
-
- /* read the cache */
- if (pm) {
- int totpoint = pm->totpoint;
-
- if ((pid->data_types & (1<<BPHYS_DATA_INDEX)) == 0) {
- int pid_totpoint = pid->totpoint(pid->calldata, cfra);
-
- if (totpoint != pid_totpoint) {
- pid->error(pid->calldata, "Number of points in cache does not match mesh");
- totpoint = MIN2(totpoint, pid_totpoint);
- }
- }
-
- BKE_ptcache_mem_pointers_init(pm);
-
- for (i=0; i<totpoint; i++) {
- if (pm->data_types & (1<<BPHYS_DATA_INDEX))
- index = pm->cur[BPHYS_DATA_INDEX];
-
- pid->read_point(*index, pid->calldata, pm->cur, (float)pm->frame, NULL);
-
- BKE_ptcache_mem_pointers_incr(pm);
- }
-
- if (pid->read_extra_data && pm->extradata.first)
- pid->read_extra_data(pid->calldata, pm, (float)pm->frame);
-
- /* clean up temporary memory cache */
- if (pid->cache->flag & PTCACHE_DISK_CACHE) {
- ptcache_data_free(pm);
- ptcache_extra_free(pm);
- MEM_freeN(pm);
- }
- }
-
- return 1;
-}
-static int ptcache_interpolate(PTCacheID *pid, float cfra, int cfra1, int cfra2)
-{
- PTCacheMem *pm = NULL;
- int i;
- int *index = &i;
-
- /* get a memory cache to read from */
- if (pid->cache->flag & PTCACHE_DISK_CACHE) {
- pm = ptcache_disk_frame_to_mem(pid, cfra2);
- }
- else {
- pm = pid->cache->mem_cache.first;
-
- while (pm && pm->frame != cfra2)
- pm = pm->next;
- }
-
- /* read the cache */
- if (pm) {
- int totpoint = pm->totpoint;
-
- if ((pid->data_types & (1<<BPHYS_DATA_INDEX)) == 0) {
- int pid_totpoint = pid->totpoint(pid->calldata, (int)cfra);
-
- if (totpoint != pid_totpoint) {
- pid->error(pid->calldata, "Number of points in cache does not match mesh");
- totpoint = MIN2(totpoint, pid_totpoint);
- }
- }
-
- BKE_ptcache_mem_pointers_init(pm);
-
- for (i=0; i<totpoint; i++) {
- if (pm->data_types & (1<<BPHYS_DATA_INDEX))
- index = pm->cur[BPHYS_DATA_INDEX];
-
- pid->interpolate_point(*index, pid->calldata, pm->cur, cfra, (float)cfra1, (float)cfra2, NULL);
- BKE_ptcache_mem_pointers_incr(pm);
- }
-
- if (pid->interpolate_extra_data && pm->extradata.first)
- pid->interpolate_extra_data(pid->calldata, pm, cfra, (float)cfra1, (float)cfra2);
-
- /* clean up temporary memory cache */
- if (pid->cache->flag & PTCACHE_DISK_CACHE) {
- ptcache_data_free(pm);
- ptcache_extra_free(pm);
- MEM_freeN(pm);
- }
- }
-
- return 1;
-}
-/* reads cache from disk or memory */
-/* possible to get old or interpolated result */
-int BKE_ptcache_read(PTCacheID *pid, float cfra)
-{
- int cfrai = (int)floor(cfra), cfra1=0, cfra2=0;
- int ret = 0;
-
- /* nothing to read to */
- if (pid->totpoint(pid->calldata, cfrai) == 0)
- return 0;
-
- if (pid->cache->flag & PTCACHE_READ_INFO) {
- pid->cache->flag &= ~PTCACHE_READ_INFO;
- ptcache_read(pid, 0);
- }
-
- /* first check if we have the actual frame cached */
- if (cfra == (float)cfrai && BKE_ptcache_id_exist(pid, cfrai))
- cfra1 = cfrai;
-
- /* no exact cache frame found so try to find cached frames around cfra */
- if (cfra1 == 0)
- ptcache_find_frames_around(pid, cfrai, &cfra1, &cfra2);
-
- if (cfra1 == 0 && cfra2 == 0)
- return 0;
-
- /* don't read old cache if already simulated past cached frame */
- if (cfra1 == 0 && cfra2 && cfra2 <= pid->cache->simframe)
- return 0;
- if (cfra1 && cfra1 == cfra2)
- return 0;
-
- if (cfra1) {
- if (pid->file_type == PTCACHE_FILE_OPENVDB && pid->read_openvdb_stream) {
- if (!ptcache_read_openvdb_stream(pid, cfra1)) {
- return 0;
- }
- }
- else if (pid->read_stream) {
- if (!ptcache_read_stream(pid, cfra1))
- return 0;
- }
- else if (pid->read_point)
- ptcache_read(pid, cfra1);
- }
-
- if (cfra2) {
- if (pid->file_type == PTCACHE_FILE_OPENVDB && pid->read_openvdb_stream) {
- if (!ptcache_read_openvdb_stream(pid, cfra2)) {
- return 0;
- }
- }
- else if (pid->read_stream) {
- if (!ptcache_read_stream(pid, cfra2))
- return 0;
- }
- else if (pid->read_point) {
- if (cfra1 && cfra2 && pid->interpolate_point)
- ptcache_interpolate(pid, cfra, cfra1, cfra2);
- else
- ptcache_read(pid, cfra2);
- }
- }
-
- if (cfra1)
- ret = (cfra2 ? PTCACHE_READ_INTERPOLATED : PTCACHE_READ_EXACT);
- else if (cfra2) {
- ret = PTCACHE_READ_OLD;
- pid->cache->simframe = cfra2;
- }
-
- cfrai = (int)cfra;
- /* clear invalid cache frames so that better stuff can be simulated */
- if (pid->cache->flag & PTCACHE_OUTDATED) {
- BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, cfrai);
- }
- else if (pid->cache->flag & PTCACHE_FRAMES_SKIPPED) {
- if (cfra <= pid->cache->last_exact)
- pid->cache->flag &= ~PTCACHE_FRAMES_SKIPPED;
-
- BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, MAX2(cfrai, pid->cache->last_exact));
- }
-
- return ret;
-}
-static int ptcache_write_stream(PTCacheID *pid, int cfra, int totpoint)
-{
- PTCacheFile *pf = NULL;
- int error = 0;
-
- BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, cfra);
-
- pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, cfra);
-
- if (pf==NULL) {
- if (G.debug & G_DEBUG)
- printf("Error opening disk cache file for writing\n");
- return 0;
- }
-
- pf->data_types = pid->data_types;
- pf->totpoint = totpoint;
- pf->type = pid->type;
- pf->flag = 0;
-
- if (!error && (!ptcache_file_header_begin_write(pf) || !pid->write_header(pf)))
- error = 1;
-
- if (!error && pid->write_stream)
- pid->write_stream(pf, pid->calldata);
-
- ptcache_file_close(pf);
-
- if (error && G.debug & G_DEBUG)
- printf("Error writing to disk cache\n");
-
- return error == 0;
-}
-static int ptcache_write_openvdb_stream(PTCacheID *pid, int cfra)
-{
-#ifdef WITH_OPENVDB
- struct OpenVDBWriter *writer = OpenVDBWriter_create();
- char filename[FILE_MAX * 2];
-
- BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, cfra);
-
- ptcache_filename(pid, filename, cfra, 1, 1);
- BLI_make_existing_file(filename);
-
- int error = pid->write_openvdb_stream(writer, pid->calldata);
-
- OpenVDBWriter_write(writer, filename);
- OpenVDBWriter_free(writer);
-
- return error == 0;
-#else
- UNUSED_VARS(pid, cfra);
- return 0;
-#endif
-}
-static int ptcache_write(PTCacheID *pid, int cfra, int overwrite)
-{
- PointCache *cache = pid->cache;
- PTCacheMem *pm=NULL, *pm2=NULL;
- int totpoint = pid->totpoint(pid->calldata, cfra);
- int i, error = 0;
-
- pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache mem");
-
- pm->totpoint = pid->totwrite(pid->calldata, cfra);
- pm->data_types = cfra ? pid->data_types : pid->info_types;
-
- ptcache_data_alloc(pm);
- BKE_ptcache_mem_pointers_init(pm);
-
- if (overwrite) {
- if (cache->flag & PTCACHE_DISK_CACHE) {
- int fra = cfra-1;
-
- while (fra >= cache->startframe && !BKE_ptcache_id_exist(pid, fra))
- fra--;
-
- pm2 = ptcache_disk_frame_to_mem(pid, fra);
- }
- else
- pm2 = cache->mem_cache.last;
- }
-
- if (pid->write_point) {
- for (i=0; i<totpoint; i++) {
- int write = pid->write_point(i, pid->calldata, pm->cur, cfra);
- if (write) {
- BKE_ptcache_mem_pointers_incr(pm);
-
- /* newly born particles have to be copied to previous cached frame */
- if (overwrite && write == 2 && pm2 && BKE_ptcache_mem_pointers_seek(i, pm2))
- pid->write_point(i, pid->calldata, pm2->cur, cfra);
- }
- }
- }
-
- if (pid->write_extra_data)
- pid->write_extra_data(pid->calldata, pm, cfra);
-
- pm->frame = cfra;
-
- if (cache->flag & PTCACHE_DISK_CACHE) {
- error += !ptcache_mem_frame_to_disk(pid, pm);
-
- // if (pm) /* pm is always set */
- {
- ptcache_data_free(pm);
- ptcache_extra_free(pm);
- MEM_freeN(pm);
- }
-
- if (pm2) {
- error += !ptcache_mem_frame_to_disk(pid, pm2);
- ptcache_data_free(pm2);
- ptcache_extra_free(pm2);
- MEM_freeN(pm2);
- }
- }
- else {
- BLI_addtail(&cache->mem_cache, pm);
- }
-
- return error;
-}
-static int ptcache_write_needed(PTCacheID *pid, int cfra, int *overwrite)
-{
- PointCache *cache = pid->cache;
- int ofra = 0, efra = cache->endframe;
-
- /* always start from scratch on the first frame */
- if (cfra && cfra == cache->startframe) {
- BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, cfra);
- cache->flag &= ~PTCACHE_REDO_NEEDED;
- return 1;
- }
-
- if (pid->cache->flag & PTCACHE_DISK_CACHE) {
- if (cfra==0 && cache->startframe > 0)
- return 1;
-
- /* find last cached frame */
- while (efra > cache->startframe && !BKE_ptcache_id_exist(pid, efra))
- efra--;
-
- /* find second last cached frame */
- ofra = efra-1;
- while (ofra > cache->startframe && !BKE_ptcache_id_exist(pid, ofra))
- ofra--;
- }
- else {
- PTCacheMem *pm = cache->mem_cache.last;
- /* don't write info file in memory */
- if (cfra == 0)
- return 0;
-
- if (pm == NULL)
- return 1;
-
- efra = pm->frame;
- ofra = (pm->prev ? pm->prev->frame : efra - cache->step);
- }
-
- if (efra >= cache->startframe && cfra > efra) {
- if (ofra >= cache->startframe && efra - ofra < cache->step) {
- /* overwrite previous frame */
- BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, efra);
- *overwrite = 1;
- }
- return 1;
- }
-
- return 0;
-}
-/* writes cache to disk or memory */
-int BKE_ptcache_write(PTCacheID *pid, unsigned int cfra)
-{
- PointCache *cache = pid->cache;
- int totpoint = pid->totpoint(pid->calldata, cfra);
- int overwrite = 0, error = 0;
-
- if (totpoint == 0 || (cfra ? pid->data_types == 0 : pid->info_types == 0))
- return 0;
-
- if (ptcache_write_needed(pid, cfra, &overwrite)==0)
- return 0;
-
- if (pid->file_type == PTCACHE_FILE_OPENVDB && pid->write_openvdb_stream) {
- ptcache_write_openvdb_stream(pid, cfra);
- }
- else if (pid->write_stream) {
- ptcache_write_stream(pid, cfra, totpoint);
- }
- else if (pid->write_point) {
- error += ptcache_write(pid, cfra, overwrite);
- }
-
- /* Mark frames skipped if more than 1 frame forwards since last non-skipped frame. */
- if (cfra - cache->last_exact == 1 || cfra == cache->startframe) {
- cache->last_exact = cfra;
- cache->flag &= ~PTCACHE_FRAMES_SKIPPED;
- }
- /* Don't mark skipped when writing info file (frame 0) */
- else if (cfra)
- cache->flag |= PTCACHE_FRAMES_SKIPPED;
-
- /* Update timeline cache display */
- if (cfra && cache->cached_frames)
- cache->cached_frames[cfra-cache->startframe] = 1;
-
- BKE_ptcache_update_info(pid);
-
- return !error;
-}
-/* youll need to close yourself after!
- * mode - PTCACHE_CLEAR_ALL,
- */
-
-/* Clears & resets */
-void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
-{
- unsigned int len; /* store the length of the string */
- unsigned int sta, end;
-
- /* mode is same as fopen's modes */
- DIR *dir;
- struct dirent *de;
- char path[MAX_PTCACHE_PATH];
- char filename[MAX_PTCACHE_FILE];
- char path_full[MAX_PTCACHE_FILE];
- char ext[MAX_PTCACHE_PATH];
-
- if (!pid || !pid->cache || pid->cache->flag & PTCACHE_BAKED)
- return;
-
- if (pid->cache->flag & PTCACHE_IGNORE_CLEAR)
- return;
-
- sta = pid->cache->startframe;
- end = pid->cache->endframe;
-
-#ifndef DURIAN_POINTCACHE_LIB_OK
- /* don't allow clearing for linked objects */
- if (pid->ob->id.lib)
- return;
-#endif
-
- /*if (!G.relbase_valid) return; *//* save blend file before using pointcache */
-
- const char *fext = ptcache_file_extension(pid);
-
- /* clear all files in the temp dir with the prefix of the ID and the ".bphys" suffix */
- switch (mode) {
- case PTCACHE_CLEAR_ALL:
- case PTCACHE_CLEAR_BEFORE:
- case PTCACHE_CLEAR_AFTER:
- if (pid->cache->flag & PTCACHE_DISK_CACHE) {
- ptcache_path(pid, path);
-
- dir = opendir(path);
- if (dir==NULL)
- return;
-
- len = ptcache_filename(pid, filename, cfra, 0, 0); /* no path */
- /* append underscore terminator to ensure we don't match similar names
- * from objects whose names start with the same prefix
- */
- if (len < sizeof(filename) - 2) {
- BLI_strncpy(filename + len, "_", sizeof(filename) - 2 - len);
- len += 1;
- }
-
- BLI_snprintf(ext, sizeof(ext), "_%02u%s", pid->stack_index, fext);
-
- while ((de = readdir(dir)) != NULL) {
- if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
- if (STREQLEN(filename, de->d_name, len)) { /* do we have the right prefix */
- if (mode == PTCACHE_CLEAR_ALL) {
- pid->cache->last_exact = MIN2(pid->cache->startframe, 0);
- BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name);
- BLI_delete(path_full, false, false);
- }
- else {
- /* read the number of the file */
- const int frame = ptcache_frame_from_filename(de->d_name, ext);
-
- if (frame != -1) {
- if ((mode == PTCACHE_CLEAR_BEFORE && frame < cfra) ||
- (mode == PTCACHE_CLEAR_AFTER && frame > cfra))
- {
-
- BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name);
- BLI_delete(path_full, false, false);
- if (pid->cache->cached_frames && frame >=sta && frame <= end)
- pid->cache->cached_frames[frame-sta] = 0;
- }
- }
- }
- }
- }
- }
- closedir(dir);
-
- if (mode == PTCACHE_CLEAR_ALL && pid->cache->cached_frames)
- memset(pid->cache->cached_frames, 0, MEM_allocN_len(pid->cache->cached_frames));
- }
- else {
- PTCacheMem *pm= pid->cache->mem_cache.first;
- PTCacheMem *link= NULL;
-
- if (mode == PTCACHE_CLEAR_ALL) {
- /*we want startframe if the cache starts before zero*/
- pid->cache->last_exact = MIN2(pid->cache->startframe, 0);
- for (; pm; pm=pm->next) {
- ptcache_data_free(pm);
- ptcache_extra_free(pm);
- }
- BLI_freelistN(&pid->cache->mem_cache);
-
- if (pid->cache->cached_frames)
- memset(pid->cache->cached_frames, 0, MEM_allocN_len(pid->cache->cached_frames));
- }
- else {
- while (pm) {
- if ((mode == PTCACHE_CLEAR_BEFORE && pm->frame < cfra) ||
- (mode == PTCACHE_CLEAR_AFTER && pm->frame > cfra))
- {
- link = pm;
- if (pid->cache->cached_frames && pm->frame >=sta && pm->frame <= end)
- pid->cache->cached_frames[pm->frame-sta] = 0;
- ptcache_data_free(pm);
- ptcache_extra_free(pm);
- pm = pm->next;
- BLI_freelinkN(&pid->cache->mem_cache, link);
- }
- else
- pm = pm->next;
- }
- }
- }
- break;
-
- case PTCACHE_CLEAR_FRAME:
- if (pid->cache->flag & PTCACHE_DISK_CACHE) {
- if (BKE_ptcache_id_exist(pid, cfra)) {
- ptcache_filename(pid, filename, cfra, 1, 1); /* no path */
- BLI_delete(filename, false, false);
- }
- }
- else {
- PTCacheMem *pm = pid->cache->mem_cache.first;
-
- for (; pm; pm=pm->next) {
- if (pm->frame == cfra) {
- ptcache_data_free(pm);
- ptcache_extra_free(pm);
- BLI_freelinkN(&pid->cache->mem_cache, pm);
- break;
- }
- }
- }
- if (pid->cache->cached_frames && cfra >= sta && cfra <= end)
- pid->cache->cached_frames[cfra-sta] = 0;
- break;
- }
-
- BKE_ptcache_update_info(pid);
-}
-int BKE_ptcache_id_exist(PTCacheID *pid, int cfra)
-{
- if (!pid->cache)
- return 0;
-
- if (cfra<pid->cache->startframe || cfra > pid->cache->endframe)
- return 0;
-
- if (pid->cache->cached_frames && pid->cache->cached_frames[cfra-pid->cache->startframe]==0)
- return 0;
-
- if (pid->cache->flag & PTCACHE_DISK_CACHE) {
- char filename[MAX_PTCACHE_FILE];
-
- ptcache_filename(pid, filename, cfra, 1, 1);
-
- return BLI_exists(filename);
- }
- else {
- PTCacheMem *pm = pid->cache->mem_cache.first;
-
- for (; pm; pm=pm->next) {
- if (pm->frame==cfra)
- return 1;
- }
- return 0;
- }
-}
-void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startframe, int *endframe, float *timescale)
-{
- /* Object *ob; */ /* UNUSED */
- PointCache *cache;
- /* float offset; unused for now */
- float time, nexttime;
-
- /* TODO: this has to be sorted out once bsystem_time gets redone, */
- /* now caches can handle interpolating etc. too - jahka */
-
- /* time handling for point cache:
- * - simulation time is scaled by result of bsystem_time
- * - for offsetting time only time offset is taken into account, since
- * that's always the same and can't be animated. a timeoffset which
- * varies over time is not simple to support.
- * - field and motion blur offsets are currently ignored, proper solution
- * is probably to interpolate results from two frames for that ..
- */
-
- /* ob= pid->ob; */ /* UNUSED */
- cache= pid->cache;
-
- if (timescale) {
- time= BKE_scene_frame_get(scene);
- nexttime = BKE_scene_frame_get_from_ctime(scene, CFRA + 1.0f);
-
- *timescale= MAX2(nexttime - time, 0.0f);
- }
-
- if (startframe && endframe) {
- *startframe= cache->startframe;
- *endframe= cache->endframe;
-
- /* TODO: time handling with object offsets and simulated vs. cached
- * particles isn't particularly easy, so for now what you see is what
- * you get. In the future point cache could handle the whole particle
- * system timing. */
-#if 0
- if ((ob->partype & PARSLOW)==0) {
- offset= ob->sf;
-
- *startframe += (int)(offset+0.5f);
- *endframe += (int)(offset+0.5f);
- }
-#endif
- }
-
- /* verify cached_frames array is up to date */
- if (cache->cached_frames) {
- if (MEM_allocN_len(cache->cached_frames) != sizeof(char) * (cache->endframe-cache->startframe+1)) {
- MEM_freeN(cache->cached_frames);
- cache->cached_frames = NULL;
- }
- }
-
- if (cache->cached_frames==NULL && cache->endframe > cache->startframe) {
- unsigned int sta=cache->startframe;
- unsigned int end=cache->endframe;
-
- cache->cached_frames = MEM_callocN(sizeof(char) * (cache->endframe-cache->startframe+1), "cached frames array");
-
- if (pid->cache->flag & PTCACHE_DISK_CACHE) {
- /* mode is same as fopen's modes */
- DIR *dir;
- struct dirent *de;
- char path[MAX_PTCACHE_PATH];
- char filename[MAX_PTCACHE_FILE];
- char ext[MAX_PTCACHE_PATH];
- unsigned int len; /* store the length of the string */
-
- ptcache_path(pid, path);
-
- len = ptcache_filename(pid, filename, (int)cfra, 0, 0); /* no path */
-
- dir = opendir(path);
- if (dir==NULL)
- return;
-
- const char *fext = ptcache_file_extension(pid);
-
- BLI_snprintf(ext, sizeof(ext), "_%02u%s", pid->stack_index, fext);
-
- while ((de = readdir(dir)) != NULL) {
- if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
- if (STREQLEN(filename, de->d_name, len)) { /* do we have the right prefix */
- /* read the number of the file */
- const int frame = ptcache_frame_from_filename(de->d_name, ext);
-
- if ((frame != -1) && (frame >= sta && frame <= end)) {
- cache->cached_frames[frame-sta] = 1;
- }
- }
- }
- }
- closedir(dir);
- }
- else {
- PTCacheMem *pm= pid->cache->mem_cache.first;
-
- while (pm) {
- if (pm->frame >= sta && pm->frame <= end)
- cache->cached_frames[pm->frame-sta] = 1;
- pm = pm->next;
- }
- }
- }
-}
-int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode)
-{
- PointCache *cache;
- int reset, clear, after;
-
- if (!pid->cache)
- return 0;
-
- cache= pid->cache;
- reset= 0;
- clear= 0;
- after= 0;
-
- if (mode == PTCACHE_RESET_DEPSGRAPH) {
- if (!(cache->flag & PTCACHE_BAKED)) {
-
- after= 1;
- }
-
- cache->flag |= PTCACHE_OUTDATED;
- }
- else if (mode == PTCACHE_RESET_BAKED) {
- cache->flag |= PTCACHE_OUTDATED;
- }
- else if (mode == PTCACHE_RESET_OUTDATED) {
- reset = 1;
-
- if (cache->flag & PTCACHE_OUTDATED && !(cache->flag & PTCACHE_BAKED)) {
- clear= 1;
- cache->flag &= ~PTCACHE_OUTDATED;
- }
- }
-
- if (reset) {
- BKE_ptcache_invalidate(cache);
- cache->flag &= ~PTCACHE_REDO_NEEDED;
-
- if (pid->type == PTCACHE_TYPE_CLOTH)
- cloth_free_modifier(pid->calldata);
- else if (pid->type == PTCACHE_TYPE_SOFTBODY)
- sbFreeSimulation(pid->calldata);
-#if 0
- else if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN)
- smokeModifier_reset(pid->calldata);
- else if (pid->type == PTCACHE_TYPE_SMOKE_HIGHRES)
- smokeModifier_reset_turbulence(pid->calldata);
-#endif
- else if (pid->type == PTCACHE_TYPE_DYNAMICPAINT)
- dynamicPaint_clearSurface(scene, (DynamicPaintSurface*)pid->calldata);
- }
- if (clear)
- BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
- else if (after)
- BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, CFRA);
-
- return (reset || clear || after);
-}
-int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
-{
- PTCacheID pid;
- ModifierData *md;
- int reset;
-
- reset= 0;
-
- if (ob->soft) {
- BKE_ptcache_id_from_softbody(&pid, ob, ob->soft);
- reset |= BKE_ptcache_id_reset(scene, &pid, mode);
- }
-
- for (md=ob->modifiers.first; md; md=md->next) {
- if (md->type == eModifierType_Cloth) {
- BKE_ptcache_id_from_cloth(&pid, ob, (ClothModifierData*)md);
- reset |= BKE_ptcache_id_reset(scene, &pid, mode);
- }
- if (md->type == eModifierType_Smoke) {
- SmokeModifierData *smd = (SmokeModifierData *)md;
- if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
- BKE_ptcache_id_from_smoke(&pid, ob, (SmokeModifierData*)md);
- reset |= BKE_ptcache_id_reset(scene, &pid, mode);
- }
- }
- if (md->type == eModifierType_DynamicPaint) {
- DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
- if (pmd->canvas) {
- DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
-
- for (; surface; surface=surface->next) {
- BKE_ptcache_id_from_dynamicpaint(&pid, ob, surface);
- reset |= BKE_ptcache_id_reset(scene, &pid, mode);
- }
- }
- }
- }
-
- if (scene->rigidbody_world && (ob->rigidbody_object || ob->rigidbody_constraint)) {
- if (ob->rigidbody_object)
- ob->rigidbody_object->flag |= RBO_FLAG_NEEDS_RESHAPE;
- BKE_ptcache_id_from_rigidbody(&pid, ob, scene->rigidbody_world);
- /* only flag as outdated, resetting should happen on start frame */
- pid.cache->flag |= PTCACHE_OUTDATED;
- }
-
- if (ob->type == OB_ARMATURE)
- BIK_clear_cache(ob->pose);
-
- return reset;
-}
-
-/* Use this when quitting blender, with unsaved files */
-void BKE_ptcache_remove(void)
-{
- char path[MAX_PTCACHE_PATH];
- char path_full[MAX_PTCACHE_PATH];
- int rmdir = 1;
-
- ptcache_path(NULL, path);
-
- if (BLI_exists(path)) {
- /* The pointcache dir exists? - remove all pointcache */
-
- DIR *dir;
- struct dirent *de;
-
- dir = opendir(path);
- if (dir==NULL)
- return;
-
- while ((de = readdir(dir)) != NULL) {
- if (FILENAME_IS_CURRPAR(de->d_name)) {
- /* do nothing */
- }
- else if (strstr(de->d_name, PTCACHE_EXT)) { /* do we have the right extension?*/
- BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name);
- BLI_delete(path_full, false, false);
- }
- else {
- rmdir = 0; /* unknown file, don't remove the dir */
- }
- }
-
- closedir(dir);
- }
- else {
- rmdir = 0; /* path dosnt exist */
- }
-
- if (rmdir) {
- BLI_delete(path, true, false);
- }
-}
-
-/* Point Cache handling */
-
-PointCache *BKE_ptcache_add(ListBase *ptcaches)
-{
- PointCache *cache;
-
- cache= MEM_callocN(sizeof(PointCache), "PointCache");
- cache->startframe= 1;
- cache->endframe= 250;
- cache->step = 1;
- cache->index = -1;
-
- BLI_addtail(ptcaches, cache);
-
- return cache;
-}
-
-void BKE_ptcache_free_mem(ListBase *mem_cache)
-{
- PTCacheMem *pm = mem_cache->first;
-
- if (pm) {
- for (; pm; pm=pm->next) {
- ptcache_data_free(pm);
- ptcache_extra_free(pm);
- }
-
- BLI_freelistN(mem_cache);
- }
-}
-void BKE_ptcache_free(PointCache *cache)
-{
- BKE_ptcache_free_mem(&cache->mem_cache);
- if (cache->edit && cache->free_edit)
- cache->free_edit(cache->edit);
- if (cache->cached_frames)
- MEM_freeN(cache->cached_frames);
- MEM_freeN(cache);
-}
-void BKE_ptcache_free_list(ListBase *ptcaches)
-{
- PointCache *cache;
-
- while ((cache = BLI_pophead(ptcaches))) {
- BKE_ptcache_free(cache);
- }
-}
-
-static PointCache *ptcache_copy(PointCache *cache, bool copy_data)
-{
- PointCache *ncache;
-
- ncache= MEM_dupallocN(cache);
-
- BLI_listbase_clear(&ncache->mem_cache);
-
- if (copy_data == false) {
- ncache->cached_frames = NULL;
-
- /* flag is a mix of user settings and simulator/baking state */
- ncache->flag= ncache->flag & (PTCACHE_DISK_CACHE|PTCACHE_EXTERNAL|PTCACHE_IGNORE_LIBPATH);
- ncache->simframe= 0;
- }
- else {
- PTCacheMem *pm;
-
- for (pm = cache->mem_cache.first; pm; pm = pm->next) {
- PTCacheMem *pmn = MEM_dupallocN(pm);
- int i;
-
- for (i = 0; i < BPHYS_TOT_DATA; i++) {
- if (pmn->data[i])
- pmn->data[i] = MEM_dupallocN(pm->data[i]);
- }
-
- BKE_ptcache_mem_pointers_init(pm);
-
- BLI_addtail(&ncache->mem_cache, pmn);
- }
-
- if (ncache->cached_frames)
- ncache->cached_frames = MEM_dupallocN(cache->cached_frames);
- }
-
- /* hmm, should these be copied over instead? */
- ncache->edit = NULL;
-
- return ncache;
-}
-
-/* returns first point cache */
-PointCache *BKE_ptcache_copy_list(ListBase *ptcaches_new, const ListBase *ptcaches_old, bool copy_data)
-{
- PointCache *cache = ptcaches_old->first;
-
- BLI_listbase_clear(ptcaches_new);
-
- for (; cache; cache=cache->next)
- BLI_addtail(ptcaches_new, ptcache_copy(cache, copy_data));
-
- return ptcaches_new->first;
-}
-
-/* Disabled this code; this is being called on scene_update_tagged, and that in turn gets called on
- * every user action changing stuff, and then it runs a complete bake??? (ton) */
-
-/* Baking */
-void BKE_ptcache_quick_cache_all(Main *bmain, Scene *scene)
-{
- PTCacheBaker baker;
-
- memset(&baker, 0, sizeof(baker));
- baker.main = bmain;
- baker.scene = scene;
- baker.bake = 0;
- baker.render = 0;
- baker.anim_init = 0;
- baker.quick_step = scene->physics_settings.quick_cache_step;
-
- BKE_ptcache_bake(&baker);
-}
-
-static void ptcache_dt_to_str(char *str, double dtime)
-{
- if (dtime > 60.0) {
- if (dtime > 3600.0)
- sprintf(str, "%ih %im %is", (int)(dtime/3600), ((int)(dtime/60))%60, ((int)dtime) % 60);
- else
- sprintf(str, "%im %is", ((int)(dtime/60))%60, ((int)dtime) % 60);
- }
- else
- sprintf(str, "%is", ((int)dtime) % 60);
-}
-
-/* if bake is not given run simulations to current frame */
-void BKE_ptcache_bake(PTCacheBaker *baker)
-{
- Main *bmain = baker->main;
- Scene *scene = baker->scene;
- Scene *sce_iter; /* SETLOOPER macro only */
- Base *base;
- ListBase pidlist;
- PTCacheID *pid = &baker->pid;
- PointCache *cache = NULL;
- float frameleno = scene->r.framelen;
- int cfrao = CFRA;
- int startframe = MAXFRAME, endframe = baker->anim_init ? scene->r.sfra : CFRA;
- int bake = baker->bake;
- int render = baker->render;
-
- G.is_break = false;
-
- /* set caches to baking mode and figure out start frame */
- if (pid->ob) {
- /* cache/bake a single object */
- cache = pid->cache;
- if ((cache->flag & PTCACHE_BAKED)==0) {
- if (pid->type == PTCACHE_TYPE_SMOKE_HIGHRES) {
- /* get all pids from the object and search for smoke low res */
- ListBase pidlist2;
- PTCacheID *pid2;
- BKE_ptcache_ids_from_object(&pidlist2, pid->ob, scene, MAX_DUPLI_RECUR);
- for (pid2=pidlist2.first; pid2; pid2=pid2->next) {
- if (pid2->type == PTCACHE_TYPE_SMOKE_DOMAIN) {
- if (pid2->cache && !(pid2->cache->flag & PTCACHE_BAKED)) {
- if (bake || pid2->cache->flag & PTCACHE_REDO_NEEDED)
- BKE_ptcache_id_clear(pid2, PTCACHE_CLEAR_ALL, 0);
- if (bake) {
- pid2->cache->flag |= PTCACHE_BAKING;
- pid2->cache->flag &= ~PTCACHE_BAKED;
- }
- }
- }
- }
- BLI_freelistN(&pidlist2);
- }
-
- if (bake || cache->flag & PTCACHE_REDO_NEEDED)
- BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
-
- startframe = MAX2(cache->last_exact, cache->startframe);
-
- if (bake) {
- endframe = cache->endframe;
- cache->flag |= PTCACHE_BAKING;
- }
- else {
- endframe = MIN2(endframe, cache->endframe);
- }
-
- cache->flag &= ~PTCACHE_BAKED;
- }
- }
- else {
- for (SETLOOPER(scene, sce_iter, base)) {
- /* cache/bake everything in the scene */
- BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR);
-
- for (pid=pidlist.first; pid; pid=pid->next) {
- cache = pid->cache;
- if ((cache->flag & PTCACHE_BAKED)==0) {
- if ((cache->flag & PTCACHE_REDO_NEEDED || (cache->flag & PTCACHE_SIMULATION_VALID)==0) &&
- (render || bake))
- {
- BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
- }
-
- startframe = MIN2(startframe, cache->startframe);
-
- if (bake || render) {
- cache->flag |= PTCACHE_BAKING;
-
- if (bake)
- endframe = MAX2(endframe, cache->endframe);
- }
-
- cache->flag &= ~PTCACHE_BAKED;
-
- }
- }
- BLI_freelistN(&pidlist);
- }
- }
-
- CFRA = startframe;
- scene->r.framelen = 1.0;
-
- /* bake */
-
- bool use_timer = false;
- double stime, ptime, ctime, fetd;
- char run[32], cur[32], etd[32];
- int cancel = 0;
-
- stime = ptime = PIL_check_seconds_timer();
-
- for (int fr = CFRA; fr <= endframe; fr += baker->quick_step, CFRA = fr) {
- BKE_scene_update_for_newframe(G.main->eval_ctx, bmain, scene, scene->lay);
-
- if (baker->update_progress) {
- float progress = ((float)(CFRA - startframe)/(float)(endframe - startframe));
- baker->update_progress(baker->bake_job, progress, &cancel);
- }
-
- if (G.background) {
- printf("bake: frame %d :: %d\n", CFRA, endframe);
- }
- else {
- ctime = PIL_check_seconds_timer();
-
- fetd = (ctime - ptime) * (endframe - CFRA) / baker->quick_step;
-
- if (use_timer || fetd > 60.0) {
- use_timer = true;
-
- ptcache_dt_to_str(cur, ctime - ptime);
- ptcache_dt_to_str(run, ctime - stime);
- ptcache_dt_to_str(etd, fetd);
-
- printf("Baked for %s, current frame: %i/%i (%.3fs), ETC: %s\r",
- run, CFRA - startframe + 1, endframe - startframe + 1, ctime - ptime, etd);
- }
-
- ptime = ctime;
- }
-
- /* NOTE: breaking baking should leave calculated frames in cache, not clear it */
- if ((cancel || G.is_break)) {
- break;
- }
-
- CFRA += 1;
- }
-
- if (use_timer) {
- /* start with newline because of \r above */
- ptcache_dt_to_str(run, PIL_check_seconds_timer()-stime);
- printf("\nBake %s %s (%i frames simulated).\n", (cancel ? "canceled after" : "finished in"), run, CFRA - startframe);
- }
-
- /* clear baking flag */
- if (pid) {
- cache->flag &= ~(PTCACHE_BAKING|PTCACHE_REDO_NEEDED);
- cache->flag |= PTCACHE_SIMULATION_VALID;
- if (bake) {
- cache->flag |= PTCACHE_BAKED;
- /* write info file */
- if (cache->flag & PTCACHE_DISK_CACHE)
- BKE_ptcache_write(pid, 0);
- }
- }
- else {
- for (SETLOOPER(scene, sce_iter, base)) {
- BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR);
-
- for (pid=pidlist.first; pid; pid=pid->next) {
- cache = pid->cache;
-
- if (baker->quick_step > 1)
- cache->flag &= ~(PTCACHE_BAKING|PTCACHE_OUTDATED);
- else
- cache->flag &= ~(PTCACHE_BAKING|PTCACHE_REDO_NEEDED);
-
- cache->flag |= PTCACHE_SIMULATION_VALID;
-
- if (bake) {
- cache->flag |= PTCACHE_BAKED;
- if (cache->flag & PTCACHE_DISK_CACHE)
- BKE_ptcache_write(pid, 0);
- }
- }
- BLI_freelistN(&pidlist);
- }
- }
-
- scene->r.framelen = frameleno;
- CFRA = cfrao;
-
- if (bake) { /* already on cfra unless baking */
- BKE_scene_update_for_newframe(bmain->eval_ctx, bmain, scene, scene->lay);
- }
-
- /* TODO: call redraw all windows somehow */
-}
-/* Helpers */
-void BKE_ptcache_disk_to_mem(PTCacheID *pid)
-{
- PointCache *cache = pid->cache;
- PTCacheMem *pm = NULL;
- int baked = cache->flag & PTCACHE_BAKED;
- int cfra, sfra = cache->startframe, efra = cache->endframe;
-
- /* Remove possible bake flag to allow clear */
- cache->flag &= ~PTCACHE_BAKED;
-
- /* PTCACHE_DISK_CACHE flag was cleared already */
- BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
-
- /* restore possible bake flag */
- cache->flag |= baked;
-
- for (cfra=sfra; cfra <= efra; cfra++) {
- pm = ptcache_disk_frame_to_mem(pid, cfra);
-
- if (pm)
- BLI_addtail(&pid->cache->mem_cache, pm);
- }
-}
-void BKE_ptcache_mem_to_disk(PTCacheID *pid)
-{
- PointCache *cache = pid->cache;
- PTCacheMem *pm = cache->mem_cache.first;
- int baked = cache->flag & PTCACHE_BAKED;
-
- /* Remove possible bake flag to allow clear */
- cache->flag &= ~PTCACHE_BAKED;
-
- /* PTCACHE_DISK_CACHE flag was set already */
- BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
-
- /* restore possible bake flag */
- cache->flag |= baked;
-
- for (; pm; pm=pm->next) {
- if (ptcache_mem_frame_to_disk(pid, pm)==0) {
- cache->flag &= ~PTCACHE_DISK_CACHE;
- break;
- }
- }
-
- /* write info file */
- if (cache->flag & PTCACHE_BAKED)
- BKE_ptcache_write(pid, 0);
-}
-void BKE_ptcache_toggle_disk_cache(PTCacheID *pid)
-{
- PointCache *cache = pid->cache;
- int last_exact = cache->last_exact;
-
- if (!G.relbase_valid) {
- cache->flag &= ~PTCACHE_DISK_CACHE;
- if (G.debug & G_DEBUG)
- printf("File must be saved before using disk cache!\n");
- return;
- }
-
- if (cache->cached_frames) {
- MEM_freeN(cache->cached_frames);
- cache->cached_frames=NULL;
- }
-
- if (cache->flag & PTCACHE_DISK_CACHE)
- BKE_ptcache_mem_to_disk(pid);
- else
- BKE_ptcache_disk_to_mem(pid);
-
- cache->flag ^= PTCACHE_DISK_CACHE;
- BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
- cache->flag ^= PTCACHE_DISK_CACHE;
-
- cache->last_exact = last_exact;
-
- BKE_ptcache_id_time(pid, NULL, 0.0f, NULL, NULL, NULL);
-
- BKE_ptcache_update_info(pid);
-
- if ((cache->flag & PTCACHE_DISK_CACHE) == 0) {
- if (cache->index) {
- BKE_object_delete_ptcache(pid->ob, cache->index);
- cache->index = -1;
- }
- }
-}
-
-void BKE_ptcache_disk_cache_rename(PTCacheID *pid, const char *name_src, const char *name_dst)
-{
- char old_name[80];
- int len; /* store the length of the string */
- /* mode is same as fopen's modes */
- DIR *dir;
- struct dirent *de;
- char path[MAX_PTCACHE_PATH];
- char old_filename[MAX_PTCACHE_FILE];
- char new_path_full[MAX_PTCACHE_FILE];
- char old_path_full[MAX_PTCACHE_FILE];
- char ext[MAX_PTCACHE_PATH];
-
- /* save old name */
- BLI_strncpy(old_name, pid->cache->name, sizeof(old_name));
-
- /* get "from" filename */
- BLI_strncpy(pid->cache->name, name_src, sizeof(pid->cache->name));
-
- len = ptcache_filename(pid, old_filename, 0, 0, 0); /* no path */
-
- ptcache_path(pid, path);
- dir = opendir(path);
- if (dir==NULL) {
- BLI_strncpy(pid->cache->name, old_name, sizeof(pid->cache->name));
- return;
- }
-
- const char *fext = ptcache_file_extension(pid);
-
- BLI_snprintf(ext, sizeof(ext), "_%02u%s", pid->stack_index, fext);
-
- /* put new name into cache */
- BLI_strncpy(pid->cache->name, name_dst, sizeof(pid->cache->name));
-
- while ((de = readdir(dir)) != NULL) {
- if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
- if (STREQLEN(old_filename, de->d_name, len)) { /* do we have the right prefix */
- /* read the number of the file */
- const int frame = ptcache_frame_from_filename(de->d_name, ext);
-
- if (frame != -1) {
- BLI_join_dirfile(old_path_full, sizeof(old_path_full), path, de->d_name);
- ptcache_filename(pid, new_path_full, frame, 1, 1);
- BLI_rename(old_path_full, new_path_full);
- }
- }
- }
- }
- closedir(dir);
-
- BLI_strncpy(pid->cache->name, old_name, sizeof(pid->cache->name));
-}
-
-void BKE_ptcache_load_external(PTCacheID *pid)
-{
- /*todo*/
- PointCache *cache = pid->cache;
- int len; /* store the length of the string */
- int info = 0;
- int start = MAXFRAME;
- int end = -1;
-
- /* mode is same as fopen's modes */
- DIR *dir;
- struct dirent *de;
- char path[MAX_PTCACHE_PATH];
- char filename[MAX_PTCACHE_FILE];
- char ext[MAX_PTCACHE_PATH];
-
- if (!cache)
- return;
-
- ptcache_path(pid, path);
-
- len = ptcache_filename(pid, filename, 1, 0, 0); /* no path */
-
- dir = opendir(path);
- if (dir==NULL)
- return;
-
- const char *fext = ptcache_file_extension(pid);
-
- if (cache->index >= 0)
- BLI_snprintf(ext, sizeof(ext), "_%02d%s", cache->index, fext);
- else
- BLI_strncpy(ext, fext, sizeof(ext));
-
- while ((de = readdir(dir)) != NULL) {
- if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
- if (STREQLEN(filename, de->d_name, len)) { /* do we have the right prefix */
- /* read the number of the file */
- const int frame = ptcache_frame_from_filename(de->d_name, ext);
-
- if (frame != -1) {
- if (frame) {
- start = MIN2(start, frame);
- end = MAX2(end, frame);
- }
- else
- info = 1;
- }
- }
- }
- }
- closedir(dir);
-
- if (start != MAXFRAME) {
- PTCacheFile *pf;
-
- cache->startframe = start;
- cache->endframe = end;
- cache->totpoint = 0;
-
- if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN) {
- /* necessary info in every file */
- }
- /* read totpoint from info file (frame 0) */
- else if (info) {
- pf= ptcache_file_open(pid, PTCACHE_FILE_READ, 0);
-
- if (pf) {
- if (ptcache_file_header_begin_read(pf)) {
- if (pf->type == pid->type && pid->read_header(pf)) {
- cache->totpoint = pf->totpoint;
- cache->flag |= PTCACHE_READ_INFO;
- }
- else {
- cache->totpoint = 0;
- }
- }
- ptcache_file_close(pf);
- }
- }
- /* or from any old format cache file */
- else {
- float old_data[14];
- int elemsize = ptcache_old_elemsize(pid);
- pf= ptcache_file_open(pid, PTCACHE_FILE_READ, cache->startframe);
-
- if (pf) {
- while (ptcache_file_read(pf, old_data, 1, elemsize))
- cache->totpoint++;
-
- ptcache_file_close(pf);
- }
- }
- cache->flag |= (PTCACHE_BAKED|PTCACHE_DISK_CACHE|PTCACHE_SIMULATION_VALID);
- cache->flag &= ~(PTCACHE_OUTDATED|PTCACHE_FRAMES_SKIPPED);
- }
-
- /* make sure all new frames are loaded */
- if (cache->cached_frames) {
- MEM_freeN(cache->cached_frames);
- cache->cached_frames=NULL;
- }
- BKE_ptcache_update_info(pid);
-}
-
-void BKE_ptcache_update_info(PTCacheID *pid)
-{
- PointCache *cache = pid->cache;
- PTCacheExtra *extra = NULL;
- int totframes = 0;
- char mem_info[64];
-
- if (cache->flag & PTCACHE_EXTERNAL) {
- int cfra = cache->startframe;
-
- for (; cfra <= cache->endframe; cfra++) {
- if (BKE_ptcache_id_exist(pid, cfra))
- totframes++;
- }
-
- /* smoke doesn't use frame 0 as info frame so can't check based on totpoint */
- if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN && totframes)
- BLI_snprintf(cache->info, sizeof(cache->info), IFACE_("%i frames found!"), totframes);
- else if (totframes && cache->totpoint)
- BLI_snprintf(cache->info, sizeof(cache->info), IFACE_("%i points found!"), cache->totpoint);
- else
- BLI_strncpy(cache->info, IFACE_("No valid data to read!"), sizeof(cache->info));
- return;
- }
-
- if (cache->flag & PTCACHE_DISK_CACHE) {
- if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN) {
- int totpoint = pid->totpoint(pid->calldata, 0);
-
- if (cache->totpoint > totpoint)
- BLI_snprintf(mem_info, sizeof(mem_info), IFACE_("%i cells + High Resolution cached"), totpoint);
- else
- BLI_snprintf(mem_info, sizeof(mem_info), IFACE_("%i cells cached"), totpoint);
- }
- else {
- int cfra = cache->startframe;
-
- for (; cfra <= cache->endframe; cfra++) {
- if (BKE_ptcache_id_exist(pid, cfra))
- totframes++;
- }
-
- BLI_snprintf(mem_info, sizeof(mem_info), IFACE_("%i frames on disk"), totframes);
- }
- }
- else {
- PTCacheMem *pm = cache->mem_cache.first;
- float bytes = 0.0f;
- int i, mb;
-
- for (; pm; pm=pm->next) {
- for (i=0; i<BPHYS_TOT_DATA; i++)
- bytes += MEM_allocN_len(pm->data[i]);
-
- for (extra=pm->extradata.first; extra; extra=extra->next) {
- bytes += MEM_allocN_len(extra->data);
- bytes += sizeof(PTCacheExtra);
- }
-
- bytes += sizeof(PTCacheMem);
-
- totframes++;
- }
-
- mb = (bytes > 1024.0f * 1024.0f);
-
- BLI_snprintf(mem_info, sizeof(mem_info), IFACE_("%i frames in memory (%.1f %s)"),
- totframes,
- bytes / (mb ? 1024.0f * 1024.0f : 1024.0f),
- mb ? IFACE_("Mb") : IFACE_("kb"));
- }
-
- if (cache->flag & PTCACHE_OUTDATED) {
- BLI_snprintf(cache->info, sizeof(cache->info), IFACE_("%s, cache is outdated!"), mem_info);
- }
- else if (cache->flag & PTCACHE_FRAMES_SKIPPED) {
- BLI_snprintf(cache->info, sizeof(cache->info), IFACE_("%s, not exact since frame %i"),
- mem_info, cache->last_exact);
- }
- else {
- BLI_snprintf(cache->info, sizeof(cache->info), "%s.", mem_info);
- }
-}
-
-void BKE_ptcache_validate(PointCache *cache, int framenr)
-{
- if (cache) {
- cache->flag |= PTCACHE_SIMULATION_VALID;
- cache->simframe = framenr;
- }
-}
-void BKE_ptcache_invalidate(PointCache *cache)
-{
- if (cache) {
- cache->flag &= ~PTCACHE_SIMULATION_VALID;
- cache->simframe = 0;
- cache->last_exact = MIN2(cache->startframe, 0);
- }
-}
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index d6fe4c3cad1..9eefcbe4885 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -61,7 +61,6 @@
#include "BKE_library_query.h"
#include "BKE_mesh.h"
#include "BKE_object.h"
-#include "BKE_pointcache.h"
#include "BKE_rigidbody.h"
#include "BKE_scene.h"
@@ -108,10 +107,6 @@ void BKE_rigidbody_free_world(RigidBodyWorld *rbw)
if (rbw->objects)
free(rbw->objects);
- /* free cache */
- BKE_ptcache_free_list(&(rbw->ptcaches));
- rbw->pointcache = NULL;
-
/* free effector weights */
if (rbw->effector_weights)
MEM_freeN(rbw->effector_weights);
@@ -921,9 +916,6 @@ RigidBodyWorld *BKE_rigidbody_create_world(Scene *scene)
rbw->steps_per_second = 60; /* Bullet default (60 Hz) */
rbw->num_solver_iterations = 10; /* 10 is bullet default */
- rbw->pointcache = BKE_ptcache_add(&(rbw->ptcaches));
- rbw->pointcache->step = 1;
-
/* return this sim world */
return rbw;
}
@@ -939,8 +931,6 @@ RigidBodyWorld *BKE_rigidbody_world_copy(RigidBodyWorld *rbw)
if (rbwn->constraints)
id_us_plus(&rbwn->constraints->id);
- rbwn->pointcache = BKE_ptcache_copy_list(&rbwn->ptcaches, &rbw->ptcaches, false);
-
rbwn->objects = NULL;
rbwn->physics_world = NULL;
rbwn->numbodies = 0;
@@ -973,10 +963,9 @@ void BKE_rigidbody_world_id_loop(RigidBodyWorld *rbw, RigidbodyWorldIDFunc func,
}
/* Add rigid body settings to the specified object */
-RigidBodyOb *BKE_rigidbody_create_object(Scene *scene, Object *ob, short type)
+RigidBodyOb *BKE_rigidbody_create_object(Scene *UNUSED(scene), Object *ob, short type)
{
RigidBodyOb *rbo;
- RigidBodyWorld *rbw = scene->rigidbody_world;
/* sanity checks
* - rigidbody world must exist
@@ -1020,18 +1009,14 @@ RigidBodyOb *BKE_rigidbody_create_object(Scene *scene, Object *ob, short type)
/* set initial transform */
mat4_to_loc_quat(rbo->pos, rbo->orn, ob->obmat);
- /* flag cache as outdated */
- BKE_rigidbody_cache_reset(rbw);
-
/* return this object */
return rbo;
}
/* Add rigid body constraint to the specified object */
-RigidBodyCon *BKE_rigidbody_create_constraint(Scene *scene, Object *ob, short type)
+RigidBodyCon *BKE_rigidbody_create_constraint(Scene *UNUSED(scene), Object *ob, short type)
{
RigidBodyCon *rbc;
- RigidBodyWorld *rbw = scene->rigidbody_world;
/* sanity checks
* - rigidbody world must exist
@@ -1081,9 +1066,6 @@ RigidBodyCon *BKE_rigidbody_create_constraint(Scene *scene, Object *ob, short ty
rbc->motor_ang_max_impulse = 1.0f;
rbc->motor_ang_target_velocity = 1.0f;
- /* flag cache as outdated */
- BKE_rigidbody_cache_reset(rbw);
-
/* return this object */
return rbc;
}
@@ -1143,9 +1125,6 @@ void BKE_rigidbody_remove_object(Scene *scene, Object *ob)
/* remove object's settings */
BKE_rigidbody_free_object(ob);
-
- /* flag cache as outdated */
- BKE_rigidbody_cache_reset(rbw);
}
void BKE_rigidbody_remove_constraint(Scene *scene, Object *ob)
@@ -1159,9 +1138,6 @@ void BKE_rigidbody_remove_constraint(Scene *scene, Object *ob)
}
/* remove object's settings */
BKE_rigidbody_free_constraint(ob);
-
- /* flag cache as outdated */
- BKE_rigidbody_cache_reset(rbw);
}
@@ -1428,9 +1404,9 @@ static void rigidbody_update_simulation_post_step(RigidBodyWorld *rbw)
}
}
-bool BKE_rigidbody_check_sim_running(RigidBodyWorld *rbw, float ctime)
+bool BKE_rigidbody_check_sim_running(RigidBodyWorld *rbw, float UNUSED(ctime))
{
- return (rbw && (rbw->flag & RBW_FLAG_MUTED) == 0 && ctime > rbw->pointcache->startframe);
+ return (rbw && (rbw->flag & RBW_FLAG_MUTED) == 0);
}
/* Sync rigid body and object transformations */
@@ -1493,12 +1469,6 @@ void BKE_rigidbody_aftertrans_update(Object *ob, float loc[3], float rot[3], flo
// RB_TODO update rigid body physics object's loc/rot for dynamic objects here as well (needs to be done outside bullet's update loop)
}
-void BKE_rigidbody_cache_reset(RigidBodyWorld *rbw)
-{
- if (rbw)
- rbw->pointcache->flag |= PTCACHE_OUTDATED;
-}
-
/* ------------------ */
/* Rebuild rigid body world */
@@ -1506,27 +1476,10 @@ void BKE_rigidbody_cache_reset(RigidBodyWorld *rbw)
void BKE_rigidbody_rebuild_world(Scene *scene, float ctime)
{
RigidBodyWorld *rbw = scene->rigidbody_world;
- PointCache *cache;
- PTCacheID pid;
- int startframe, endframe;
-
- BKE_ptcache_id_from_rigidbody(&pid, NULL, rbw);
- BKE_ptcache_id_time(&pid, scene, ctime, &startframe, &endframe, NULL);
- cache = rbw->pointcache;
-
- /* flag cache as outdated if we don't have a world or number of objects in the simulation has changed */
- if (rbw->physics_world == NULL || rbw->numbodies != BLI_listbase_count(&rbw->group->gobject)) {
- cache->flag |= PTCACHE_OUTDATED;
- }
+ int startframe = scene->r.sfra;
if (ctime == startframe + 1 && rbw->ltime == startframe) {
- if (cache->flag & PTCACHE_OUTDATED) {
- BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
- rigidbody_update_simulation(scene, rbw, true);
- BKE_ptcache_validate(cache, (int)ctime);
- cache->last_exact = 0;
- cache->flag &= ~PTCACHE_REDO_NEEDED;
- }
+ rigidbody_update_simulation(scene, rbw, true);
}
}
@@ -1535,13 +1488,7 @@ void BKE_rigidbody_do_simulation(Scene *scene, float ctime)
{
float timestep;
RigidBodyWorld *rbw = scene->rigidbody_world;
- PointCache *cache;
- PTCacheID pid;
- int startframe, endframe;
-
- BKE_ptcache_id_from_rigidbody(&pid, NULL, rbw);
- BKE_ptcache_id_time(&pid, scene, ctime, &startframe, &endframe, NULL);
- cache = rbw->pointcache;
+ int startframe = scene->r.sfra, endframe = scene->r.efra;
if (ctime <= startframe) {
rbw->ltime = startframe;
@@ -1552,27 +1499,14 @@ void BKE_rigidbody_do_simulation(Scene *scene, float ctime)
ctime = endframe;
}
- /* don't try to run the simulation if we don't have a world yet but allow reading baked cache */
- if (rbw->physics_world == NULL && !(cache->flag & PTCACHE_BAKED))
+ /* don't try to run the simulation if we don't have a world yet */
+ if (rbw->physics_world == NULL)
return;
else if (rbw->objects == NULL)
rigidbody_update_ob_array(rbw);
- /* try to read from cache */
- // RB_TODO deal with interpolated, old and baked results
- if (BKE_ptcache_read(&pid, ctime)) {
- BKE_ptcache_validate(cache, (int)ctime);
- rbw->ltime = ctime;
- return;
- }
-
/* advance simulation, we can only step one frame forward */
- if (ctime == rbw->ltime + 1 && !(cache->flag & PTCACHE_BAKED)) {
- /* write cache for first frame when on second frame */
- if (rbw->ltime == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact == 0)) {
- BKE_ptcache_write(&pid, startframe);
- }
-
+ if (ctime == rbw->ltime + 1) {
/* update and validate simulation */
rigidbody_update_simulation(scene, rbw, false);
@@ -1583,10 +1517,6 @@ void BKE_rigidbody_do_simulation(Scene *scene, float ctime)
rigidbody_update_simulation_post_step(rbw);
- /* write cache for current frame */
- BKE_ptcache_validate(cache, (int)ctime);
- BKE_ptcache_write(&pid, (unsigned int)ctime);
-
rbw->ltime = ctime;
}
}
@@ -1621,7 +1551,6 @@ void BKE_rigidbody_remove_constraint(Scene *scene, Object *ob) {}
void BKE_rigidbody_sync_transforms(RigidBodyWorld *rbw, Object *ob, float ctime) {}
void BKE_rigidbody_aftertrans_update(Object *ob, float loc[3], float rot[3], float quat[4], float rotAxis[3], float rotAngle) {}
bool BKE_rigidbody_check_sim_running(RigidBodyWorld *rbw, float ctime) { return false; }
-void BKE_rigidbody_cache_reset(RigidBodyWorld *rbw) {}
void BKE_rigidbody_rebuild_world(Scene *scene, float ctime) {}
void BKE_rigidbody_do_simulation(Scene *scene, float ctime) {}
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 0e95516ffc7..4996f98379e 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -56,6 +56,7 @@
#include "DNA_lamp_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
+#include "DNA_object_force.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_smoke_types.h"
@@ -76,7 +77,6 @@
#include "BKE_main.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
-#include "BKE_pointcache.h"
#include "BKE_scene.h"
#include "BKE_smoke.h"
#include "BKE_texture.h"
@@ -355,9 +355,6 @@ static void smokeModifier_freeDomain(SmokeModifierData *smd)
MEM_freeN(smd->domain->effector_weights);
smd->domain->effector_weights = NULL;
- BKE_ptcache_free_list(&(smd->domain->ptcaches[0]));
- smd->domain->point_cache[0] = NULL;
-
MEM_freeN(smd->domain);
smd->domain = NULL;
}
@@ -482,13 +479,6 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
smd->domain->smd = smd;
- smd->domain->point_cache[0] = BKE_ptcache_add(&(smd->domain->ptcaches[0]));
- smd->domain->point_cache[0]->flag |= PTCACHE_DISK_CACHE;
- smd->domain->point_cache[0]->step = 1;
-
- /* Deprecated */
- smd->domain->point_cache[1] = NULL;
- BLI_listbase_clear(&smd->domain->ptcaches[1]);
/* set some standard values */
smd->domain->fluid = NULL;
smd->domain->fluid_mutex = BLI_rw_mutex_alloc();
@@ -533,7 +523,6 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
smd->domain->openvdb_comp = VDB_COMPRESSION_ZIP;
#endif
smd->domain->data_depth = 0;
- smd->domain->cache_file_format = PTCACHE_FILE_PTCACHE;
}
else if (smd->type & MOD_SMOKE_TYPE_FLOW)
{
@@ -2429,28 +2418,16 @@ static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, Object *
else if (smd->type & MOD_SMOKE_TYPE_DOMAIN)
{
SmokeDomainSettings *sds = smd->domain;
- PointCache *cache = NULL;
- PTCacheID pid;
- int startframe, endframe, framenr;
- float timescale;
-
- framenr = scene->r.cfra;
+ int startframe = scene->r.sfra, endframe = scene->r.efra, framenr = scene->r.cfra;
//printf("time: %d\n", scene->r.cfra);
- cache = sds->point_cache[0];
- BKE_ptcache_id_from_smoke(&pid, ob, smd);
- BKE_ptcache_id_time(&pid, scene, framenr, &startframe, &endframe, &timescale);
-
if (!smd->domain->fluid || framenr == startframe)
{
- BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
smokeModifier_reset_ex(smd, false);
- BKE_ptcache_validate(cache, framenr);
- cache->flag &= ~PTCACHE_REDO_NEEDED;
}
- if (!smd->domain->fluid && (framenr != startframe) && (smd->domain->flags & MOD_SMOKE_FILE_LOAD) == 0 && (cache->flag & PTCACHE_BAKED) == 0)
+ if (!smd->domain->fluid && (framenr != startframe) && (smd->domain->flags & MOD_SMOKE_FILE_LOAD) == 0)
return;
smd->domain->flags &= ~MOD_SMOKE_FILE_LOAD;
@@ -2466,13 +2443,6 @@ static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, Object *
return;
}
- /* try to read from cache */
- if (BKE_ptcache_read(&pid, (float)framenr) == PTCACHE_READ_EXACT) {
- BKE_ptcache_validate(cache, framenr);
- smd->time = framenr;
- return;
- }
-
/* only calculate something when we advanced a single frame */
if (framenr != (int)smd->time + 1)
return;
@@ -2485,11 +2455,6 @@ static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, Object *
double start = PIL_check_seconds_timer();
#endif
- /* if on second frame, write cache for first frame */
- if ((int)smd->time == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact == 0)) {
- BKE_ptcache_write(&pid, startframe);
- }
-
// set new time
smd->time = scene->r.cfra;
@@ -2520,10 +2485,6 @@ static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, Object *
smoke_turbulence_step(sds->wt, sds->fluid);
}
- BKE_ptcache_validate(cache, framenr);
- if (framenr != startframe)
- BKE_ptcache_write(&pid, framenr);
-
#ifdef DEBUG_TIME
double end = PIL_check_seconds_timer();
printf("Frame: %d, Time: %f\n\n", (int)smd->time, (float)(end - start));
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index e5673637c23..25b32cc40aa 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -63,6 +63,7 @@ variables on the UI for now
#include "DNA_curve_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
+#include "DNA_object_force.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
@@ -75,7 +76,6 @@ variables on the UI for now
#include "BKE_global.h"
#include "BKE_modifier.h"
#include "BKE_softbody.h"
-#include "BKE_pointcache.h"
#include "BKE_deform.h"
#include "BKE_mesh.h"
#include "BKE_scene.h"
@@ -3273,8 +3273,6 @@ SoftBody *sbNew(Scene *scene)
sb->shearstiff = 1.0f;
sb->solverflags |= SBSO_OLDERR;
- sb->pointcache = BKE_ptcache_add(&sb->ptcaches);
-
if (!sb->effector_weights)
sb->effector_weights = BKE_add_effector_weights(NULL);
@@ -3287,8 +3285,6 @@ SoftBody *sbNew(Scene *scene)
void sbFree(SoftBody *sb)
{
free_softbody_intern(sb);
- BKE_ptcache_free_list(&sb->ptcaches);
- sb->pointcache = NULL;
if (sb->effector_weights)
MEM_freeN(sb->effector_weights);
MEM_freeN(sb);
@@ -3595,30 +3591,19 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime)
void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], int numVerts)
{
SoftBody *sb= ob->soft;
- PointCache *cache;
- PTCacheID pid;
- float dtime, timescale;
- int framedelta, framenr, startframe, endframe;
- int cache_result;
-
- cache= sb->pointcache;
-
- framenr= (int)cfra;
- framedelta= framenr - cache->simframe;
+ float dtime, timescale = 1.0f;
+ int framedelta, framenr = (int)cfra, startframe = scene->r.sfra, endframe = scene->r.efra;
- BKE_ptcache_id_from_softbody(&pid, ob, sb);
- BKE_ptcache_id_time(&pid, scene, framenr, &startframe, &endframe, &timescale);
+ framedelta = 1;
/* check for changes in mesh, should only happen in case the mesh
* structure changes during an animation */
if (sb->bpoint && numVerts != sb->totpoint) {
- BKE_ptcache_invalidate(cache);
return;
}
/* clamp frame ranges */
if (framenr < startframe) {
- BKE_ptcache_invalidate(cache);
return;
}
else if (framenr > endframe) {
@@ -3655,50 +3640,17 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
return;
}
if (framenr == startframe) {
- BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
-
/* first frame, no simulation to do, just set the positions */
softbody_update_positions(ob, sb, vertexCos, numVerts);
- BKE_ptcache_validate(cache, framenr);
- cache->flag &= ~PTCACHE_REDO_NEEDED;
-
sb->last_frame = framenr;
return;
}
- /* try to read from cache */
- cache_result = BKE_ptcache_read(&pid, (float)framenr+scene->r.subframe);
-
- if (cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) {
- softbody_to_object(ob, vertexCos, numVerts, sb->local);
-
- BKE_ptcache_validate(cache, framenr);
-
- if (cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED)
- BKE_ptcache_write(&pid, framenr);
-
- sb->last_frame = framenr;
-
- return;
- }
- else if (cache_result==PTCACHE_READ_OLD) {
- ; /* do nothing */
- }
- else if (/*ob->id.lib || */(cache->flag & PTCACHE_BAKED)) { /* "library linking & pointcaches" has to be solved properly at some point */
- /* if baked and nothing in cache, do nothing */
- BKE_ptcache_invalidate(cache);
- return;
- }
-
if (framenr!=sb->last_frame+1)
return;
- /* if on second frame, write cache for first frame */
- if (cache->simframe == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0))
- BKE_ptcache_write(&pid, startframe);
-
softbody_update_positions(ob, sb, vertexCos, numVerts);
/* checking time: */
@@ -3709,9 +3661,6 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
softbody_to_object(ob, vertexCos, numVerts, 0);
- BKE_ptcache_validate(cache, framenr);
- BKE_ptcache_write(&pid, framenr);
-
sb->last_frame = framenr;
}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 4369c6dad2f..5682570b45b 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -80,6 +80,7 @@
#include "DNA_nla_types.h"
#include "DNA_node_types.h"
#include "DNA_object_fluidsim.h" // NT
+#include "DNA_object_force.h"
#include "DNA_object_types.h"
#include "DNA_packedFile_types.h"
#include "DNA_property_types.h"
@@ -133,7 +134,6 @@
#include "BKE_node.h" // for tree type defines
#include "BKE_object.h"
#include "BKE_paint.h"
-#include "BKE_pointcache.h"
#include "BKE_report.h"
#include "BKE_sca.h" // for init_actuator
#include "BKE_scene.h"
@@ -3926,83 +3926,6 @@ static void direct_link_material(FileData *fd, Material *ma)
}
/* ************ READ PARTICLE SETTINGS ***************** */
-/* update this also to writefile.c */
-static const char *ptcache_data_struct[] = {
- "", // BPHYS_DATA_INDEX
- "", // BPHYS_DATA_LOCATION
- "", // BPHYS_DATA_VELOCITY
- "", // BPHYS_DATA_ROTATION
- "", // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST */
- "", // BPHYS_DATA_SIZE:
- "", // BPHYS_DATA_TIMES:
- "BoidData" // case BPHYS_DATA_BOIDS:
-};
-
-static void direct_link_pointcache_cb(FileData *fd, void *data)
-{
- PTCacheMem *pm = data;
- PTCacheExtra *extra;
- int i;
- for (i = 0; i < BPHYS_TOT_DATA; i++) {
- pm->data[i] = newdataadr(fd, pm->data[i]);
-
- /* the cache saves non-struct data without DNA */
- if (pm->data[i] && ptcache_data_struct[i][0]=='\0' && (fd->flags & FD_FLAGS_SWITCH_ENDIAN)) {
- int tot = (BKE_ptcache_data_size (i) * pm->totpoint) / sizeof(int); /* data_size returns bytes */
- int *poin = pm->data[i];
-
- BLI_endian_switch_int32_array(poin, tot);
- }
- }
-
- link_list(fd, &pm->extradata);
-
- for (extra=pm->extradata.first; extra; extra=extra->next)
- extra->data = newdataadr(fd, extra->data);
-}
-
-static void direct_link_pointcache(FileData *fd, PointCache *cache)
-{
- if ((cache->flag & PTCACHE_DISK_CACHE)==0) {
- link_list_ex(fd, &cache->mem_cache, direct_link_pointcache_cb);
- }
- else
- BLI_listbase_clear(&cache->mem_cache);
-
- cache->flag &= ~PTCACHE_SIMULATION_VALID;
- cache->simframe = 0;
- cache->edit = NULL;
- cache->free_edit = NULL;
- cache->cached_frames = NULL;
-}
-
-static void direct_link_pointcache_list(FileData *fd, ListBase *ptcaches, PointCache **ocache, int force_disk)
-{
- if (ptcaches->first) {
- PointCache *cache= NULL;
- link_list(fd, ptcaches);
- for (cache=ptcaches->first; cache; cache=cache->next) {
- direct_link_pointcache(fd, cache);
- if (force_disk) {
- cache->flag |= PTCACHE_DISK_CACHE;
- cache->step = 1;
- }
- }
-
- *ocache = newdataadr(fd, *ocache);
- }
- else if (*ocache) {
- /* old "single" caches need to be linked too */
- *ocache = newdataadr(fd, *ocache);
- direct_link_pointcache(fd, *ocache);
- if (force_disk) {
- (*ocache)->flag |= PTCACHE_DISK_CACHE;
- (*ocache)->step = 1;
- }
-
- ptcaches->first = ptcaches->last = *ocache;
- }
-}
static void lib_link_partdeflect(FileData *fd, ID *id, PartDeflect *pd)
{
@@ -4723,8 +4646,6 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
clmd->sim_parms= newdataadr(fd, clmd->sim_parms);
clmd->coll_parms= newdataadr(fd, clmd->coll_parms);
- direct_link_pointcache_list(fd, &clmd->ptcaches, &clmd->point_cache, 0);
-
if (clmd->sim_parms) {
if (clmd->sim_parms->presets > 10)
clmd->sim_parms->presets = 0;
@@ -4769,24 +4690,6 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
smd->domain->effector_weights = newdataadr(fd, smd->domain->effector_weights);
if (!smd->domain->effector_weights)
smd->domain->effector_weights = BKE_add_effector_weights(NULL);
-
- direct_link_pointcache_list(fd, &(smd->domain->ptcaches[0]), &(smd->domain->point_cache[0]), 1);
-
- /* Smoke uses only one cache from now on, so store pointer convert */
- if (smd->domain->ptcaches[1].first || smd->domain->point_cache[1]) {
- if (smd->domain->point_cache[1]) {
- PointCache *cache = newdataadr(fd, smd->domain->point_cache[1]);
- if (cache->flag & PTCACHE_FAKE_SMOKE) {
- /* Smoke was already saved in "new format" and this cache is a fake one. */
- }
- else {
- printf("High resolution smoke cache not available due to pointcache update. Please reset the simulation.\n");
- }
- BKE_ptcache_free(cache);
- }
- BLI_listbase_clear(&smd->domain->ptcaches[1]);
- smd->domain->point_cache[1] = NULL;
- }
}
else if (smd->type == MOD_SMOKE_TYPE_FLOW) {
smd->domain = NULL;
@@ -4831,7 +4734,6 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
for (surface=pmd->canvas->surfaces.first; surface; surface=surface->next) {
surface->canvas = pmd->canvas;
surface->data = NULL;
- direct_link_pointcache_list(fd, &(surface->ptcaches), &(surface->pointcache), 1);
if (!(surface->effector_weights = newdataadr(fd, surface->effector_weights)))
surface->effector_weights = BKE_add_effector_weights(NULL);
@@ -5092,8 +4994,6 @@ static void direct_link_object(FileData *fd, Object *ob)
sb->effector_weights = newdataadr(fd, sb->effector_weights);
if (!sb->effector_weights)
sb->effector_weights = BKE_add_effector_weights(NULL);
-
- direct_link_pointcache_list(fd, &sb->ptcaches, &sb->pointcache, 0);
}
ob->bsoft = newdataadr(fd, ob->bsoft);
ob->fluidsimSettings= newdataadr(fd, ob->fluidsimSettings); /* NT */
@@ -5744,13 +5644,6 @@ static void direct_link_scene(FileData *fd, Scene *sce)
rbw->effector_weights = newdataadr(fd, rbw->effector_weights);
if (!rbw->effector_weights)
rbw->effector_weights = BKE_add_effector_weights(NULL);
-
- /* link cache */
- direct_link_pointcache_list(fd, &rbw->ptcaches, &rbw->pointcache, false);
- /* make sure simulation starts from the beginning after loading file */
- if (rbw->pointcache) {
- rbw->ltime = (float)rbw->pointcache->startframe;
- }
}
sce->preview = direct_link_preview_image(fd, sce->preview);
diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c
index 5d8f31be9be..119754fe567 100644
--- a/source/blender/blenloader/intern/versioning_250.c
+++ b/source/blender/blenloader/intern/versioning_250.c
@@ -53,6 +53,7 @@
#include "DNA_meshdata_types.h"
#include "DNA_node_types.h"
#include "DNA_object_fluidsim.h" // NT
+#include "DNA_object_force.h"
#include "DNA_object_types.h"
#include "DNA_view3d_types.h"
#include "DNA_screen_types.h"
@@ -78,7 +79,6 @@
#include "BKE_mesh.h" // for ME_ defines (patching)
#include "BKE_modifier.h"
#include "BKE_multires.h"
-#include "BKE_pointcache.h"
#include "BKE_screen.h"
#include "BKE_sequencer.h"
#include "BKE_texture.h"
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index cc8939f6991..3e4b6534ad8 100644
--- a/source/blender/blenloader/intern/versioning_260.c
+++ b/source/blender/blenloader/intern/versioning_260.c
@@ -36,12 +36,14 @@
#include "DNA_camera_types.h"
#include "DNA_cloth_types.h"
#include "DNA_constraint_types.h"
+#include "DNA_dynamicpaint_types.h"
#include "DNA_genfile.h"
#include "DNA_key_types.h"
#include "DNA_linestyle_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_fluidsim.h" // NT
+#include "DNA_object_force.h"
#include "DNA_object_types.h"
#include "DNA_property_types.h"
#include "DNA_text_types.h"
@@ -64,7 +66,6 @@
#include "BKE_main.h" // for Main
#include "BKE_mesh.h" // for ME_ defines (patching)
#include "BKE_modifier.h"
-#include "BKE_pointcache.h"
#include "BKE_property.h" // for BKE_bproperty_object_get
#include "BKE_scene.h"
#include "BKE_screen.h"
diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c
index 353b8befd71..f5e9fb240dc 100644
--- a/source/blender/blenloader/intern/versioning_legacy.c
+++ b/source/blender/blenloader/intern/versioning_legacy.c
@@ -59,6 +59,7 @@
#include "DNA_nla_types.h"
#include "DNA_node_types.h"
#include "DNA_object_fluidsim.h" // NT
+#include "DNA_object_force.h"
#include "DNA_object_types.h"
#include "DNA_property_types.h"
#include "DNA_view3d_types.h"
@@ -88,7 +89,6 @@
#include "BKE_main.h" // for Main
#include "BKE_mesh.h" // for ME_ defines (patching)
#include "BKE_modifier.h"
-#include "BKE_pointcache.h"
#include "BKE_property.h" // for BKE_bproperty_object_get
#include "BKE_scene.h"
#include "BKE_sequencer.h"
@@ -2669,7 +2669,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
Mesh *me;
bNodeTree *ntree;
Tex *tex;
- ModifierData *md;
/* unless the file was created 2.44.3 but not 2.45, update the constraints */
if (!(main->versionfile == 244 && main->subversionfile == 3) &&
@@ -2750,22 +2749,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
}
}
- /* add point caches */
- for (ob = main->object.first; ob; ob = ob->id.next) {
- if (ob->soft && !ob->soft->pointcache)
- ob->soft->pointcache = BKE_ptcache_add(&ob->soft->ptcaches);
-
- for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Cloth) {
- ClothModifierData *clmd = (ClothModifierData*) md;
- if (!clmd->point_cache) {
- clmd->point_cache = BKE_ptcache_add(&clmd->ptcaches);
- clmd->point_cache->step = 1;
- }
- }
- }
- }
-
/* Copy over old per-level multires vertex data
* into a single vertex array in struct Multires */
for (me = main->mesh.first; me; me = me->id.next) {
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index de709538e42..e1a4e255743 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -158,7 +158,6 @@
#include "BKE_subsurf.h"
#include "BKE_modifier.h"
#include "BKE_fcurve.h"
-#include "BKE_pointcache.h"
#include "BKE_mesh.h"
#ifdef USE_NODE_COMPAT_CUSTOMNODES
@@ -1058,57 +1057,6 @@ static void write_userdef(WriteData *wd)
}
}
-/* update this also to readfile.c */
-static const char *ptcache_data_struct[] = {
- "", // BPHYS_DATA_INDEX
- "", // BPHYS_DATA_LOCATION
- "", // BPHYS_DATA_VELOCITY
- "", // BPHYS_DATA_ROTATION
- "", // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST */
- "", // BPHYS_DATA_SIZE:
- "", // BPHYS_DATA_TIMES:
- "BoidData" // case BPHYS_DATA_BOIDS:
-};
-static const char *ptcache_extra_struct[] = {
- "",
- "ParticleSpring"
-};
-static void write_pointcaches(WriteData *wd, ListBase *ptcaches)
-{
- PointCache *cache = ptcaches->first;
- int i;
-
- for (; cache; cache=cache->next) {
- writestruct(wd, DATA, "PointCache", 1, cache);
-
- if ((cache->flag & PTCACHE_DISK_CACHE)==0) {
- PTCacheMem *pm = cache->mem_cache.first;
-
- for (; pm; pm=pm->next) {
- PTCacheExtra *extra = pm->extradata.first;
-
- writestruct(wd, DATA, "PTCacheMem", 1, pm);
-
- for (i=0; i<BPHYS_TOT_DATA; i++) {
- if (pm->data[i] && pm->data_types & (1<<i)) {
- if (ptcache_data_struct[i][0] == '\0')
- writedata(wd, DATA, MEM_allocN_len(pm->data[i]), pm->data[i]);
- else
- writestruct(wd, DATA, ptcache_data_struct[i], pm->totpoint, pm->data[i]);
- }
- }
-
- for (; extra; extra=extra->next) {
- if (ptcache_extra_struct[extra->type][0] == '\0')
- continue;
- writestruct(wd, DATA, "PTCacheExtra", 1, extra);
- writestruct(wd, DATA, ptcache_extra_struct[extra->type], extra->totdata, extra->data);
- }
- }
- }
- }
-}
-
static void write_properties(WriteData *wd, ListBase *lb)
{
bProperty *prop;
@@ -1418,30 +1366,14 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
writestruct(wd, DATA, "ClothSimSettings", 1, clmd->sim_parms);
writestruct(wd, DATA, "ClothCollSettings", 1, clmd->coll_parms);
writestruct(wd, DATA, "EffectorWeights", 1, clmd->sim_parms->effector_weights);
- write_pointcaches(wd, &clmd->ptcaches);
}
else if (md->type==eModifierType_Smoke) {
SmokeModifierData *smd = (SmokeModifierData*) md;
if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
- if (smd->domain) {
- write_pointcaches(wd, &(smd->domain->ptcaches[0]));
-
- /* create fake pointcache so that old blender versions can read it */
- smd->domain->point_cache[1] = BKE_ptcache_add(&smd->domain->ptcaches[1]);
- smd->domain->point_cache[1]->flag |= PTCACHE_DISK_CACHE|PTCACHE_FAKE_SMOKE;
- smd->domain->point_cache[1]->step = 1;
-
- write_pointcaches(wd, &(smd->domain->ptcaches[1]));
- }
-
writestruct(wd, DATA, "SmokeDomainSettings", 1, smd->domain);
if (smd->domain) {
- /* cleanup the fake pointcache */
- BKE_ptcache_free_list(&smd->domain->ptcaches[1]);
- smd->domain->point_cache[1] = NULL;
-
writestruct(wd, DATA, "EffectorWeights", 1, smd->domain->effector_weights);
}
}
@@ -1467,8 +1399,6 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
writestruct(wd, DATA, "DynamicPaintSurface", 1, surface);
/* write caches and effector weights */
for (surface=pmd->canvas->surfaces.first; surface; surface=surface->next) {
- write_pointcaches(wd, &(surface->ptcaches));
-
writestruct(wd, DATA, "EffectorWeights", 1, surface->effector_weights);
}
}
@@ -1568,7 +1498,6 @@ static void write_objects(WriteData *wd, ListBase *idbase)
writestruct(wd, DATA, "PartDeflect", 1, ob->pd);
writestruct(wd, DATA, "SoftBody", 1, ob->soft);
if (ob->soft) {
- write_pointcaches(wd, &ob->soft->ptcaches);
writestruct(wd, DATA, "EffectorWeights", 1, ob->soft->effector_weights);
}
writestruct(wd, DATA, "BulletSoftBody", 1, ob->bsoft);
@@ -2438,7 +2367,6 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
if (sce->rigidbody_world) {
writestruct(wd, DATA, "RigidBodyWorld", 1, sce->rigidbody_world);
writestruct(wd, DATA, "EffectorWeights", 1, sce->rigidbody_world->effector_weights);
- write_pointcaches(wd, &(sce->rigidbody_world->ptcaches));
}
write_previews(wd, sce->preview);
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 5b4364076f2..936d5da8f4f 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -75,7 +75,6 @@
#include "BKE_mball.h"
#include "BKE_mesh.h"
#include "BKE_object.h"
-#include "BKE_pointcache.h"
#include "BKE_property.h"
#include "BKE_sca.h"
#include "BKE_softbody.h"
@@ -430,21 +429,9 @@ void ED_object_editmode_exit(bContext *C, int flag)
/* freedata only 0 now on file saves and render */
if (freedata) {
- ListBase pidlist;
- PTCacheID *pid;
-
/* for example; displist make is different in editmode */
scene->obedit = NULL; // XXX for context
- /* flag object caches as outdated */
- BKE_ptcache_ids_from_object(&pidlist, obedit, scene, 0);
- for (pid = pidlist.first; pid; pid = pid->next) {
- pid->cache->flag |= PTCACHE_OUTDATED;
- }
- BLI_freelistN(&pidlist);
-
- BKE_ptcache_object_reset(scene, obedit, PTCACHE_RESET_OUTDATED);
-
/* also flush ob recalc, doesn't take much overhead, but used for particles */
DAG_id_tag_update(&obedit->id, OB_RECALC_OB | OB_RECALC_DATA);
diff --git a/source/blender/editors/physics/CMakeLists.txt b/source/blender/editors/physics/CMakeLists.txt
index b4f36d43567..e4513c14413 100644
--- a/source/blender/editors/physics/CMakeLists.txt
+++ b/source/blender/editors/physics/CMakeLists.txt
@@ -40,7 +40,6 @@ set(SRC
dynamicpaint_ops.c
physics_fluid.c
physics_ops.c
- physics_pointcache.c
rigidbody_constraint.c
rigidbody_object.c
rigidbody_world.c
diff --git a/source/blender/editors/physics/physics_intern.h b/source/blender/editors/physics/physics_intern.h
index 98d192af1aa..a5b59feba6b 100644
--- a/source/blender/editors/physics/physics_intern.h
+++ b/source/blender/editors/physics/physics_intern.h
@@ -45,15 +45,6 @@ void DPAINT_OT_surface_slot_remove(struct wmOperatorType *ot);
void DPAINT_OT_type_toggle(struct wmOperatorType *ot);
void DPAINT_OT_output_toggle(struct wmOperatorType *ot);
-/* physics_pointcache.c */
-void PTCACHE_OT_bake_all(struct wmOperatorType *ot);
-void PTCACHE_OT_free_bake_all(struct wmOperatorType *ot);
-void PTCACHE_OT_bake(struct wmOperatorType *ot);
-void PTCACHE_OT_free_bake(struct wmOperatorType *ot);
-void PTCACHE_OT_bake_from_cache(struct wmOperatorType *ot);
-void PTCACHE_OT_add(struct wmOperatorType *ot);
-void PTCACHE_OT_remove(struct wmOperatorType *ot);
-
/* rigidbody_object.c */
void RIGIDBODY_OT_object_add(struct wmOperatorType *ot);
void RIGIDBODY_OT_object_remove(struct wmOperatorType *ot);
diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c
index 5a6e9db47c9..357259731d2 100644
--- a/source/blender/editors/physics/physics_ops.c
+++ b/source/blender/editors/physics/physics_ops.c
@@ -68,19 +68,6 @@ static void operatortypes_fluid(void)
WM_operatortype_append(FLUID_OT_bake);
}
-/**************************** point cache **********************************/
-
-static void operatortypes_pointcache(void)
-{
- WM_operatortype_append(PTCACHE_OT_bake_all);
- WM_operatortype_append(PTCACHE_OT_free_bake_all);
- WM_operatortype_append(PTCACHE_OT_bake);
- WM_operatortype_append(PTCACHE_OT_free_bake);
- WM_operatortype_append(PTCACHE_OT_bake_from_cache);
- WM_operatortype_append(PTCACHE_OT_add);
- WM_operatortype_append(PTCACHE_OT_remove);
-}
-
/********************************* dynamic paint ***********************************/
static void operatortypes_dynamicpaint(void)
@@ -92,30 +79,15 @@ static void operatortypes_dynamicpaint(void)
WM_operatortype_append(DPAINT_OT_output_toggle);
}
-//static void keymap_pointcache(wmWindowManager *wm)
-//{
-// wmKeyMap *keymap = WM_keymap_find(wm, "Pointcache", 0, 0);
-//
-// WM_keymap_add_item(keymap, "PHYSICS_OT_bake_all", AKEY, KM_PRESS, 0, 0);
-// WM_keymap_add_item(keymap, "PHYSICS_OT_free_all", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
-// WM_keymap_add_item(keymap, "PHYSICS_OT_bake_particle_system", PADMINUS, KM_PRESS, KM_CTRL, 0);
-// WM_keymap_add_item(keymap, "PHYSICS_OT_free_particle_system", LKEY, KM_PRESS, 0, 0);
-//}
-
/****************************** general ************************************/
void ED_operatortypes_physics(void)
{
operatortypes_rigidbody();
operatortypes_fluid();
- operatortypes_pointcache();
operatortypes_dynamicpaint();
}
void ED_keymap_physics(wmKeyConfig *UNUSED(keyconf))
{
- //keymap_pointcache(keyconf);
}
-
-
-
diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c
deleted file mode 100644
index faceaadefe6..00000000000
--- a/source/blender/editors/physics/physics_pointcache.c
+++ /dev/null
@@ -1,464 +0,0 @@
-/*
- * ***** 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) 2007 by Janne Karhu.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/physics/physics_pointcache.c
- * \ingroup edphys
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_utildefines.h"
-
-#include "DNA_object_types.h"
-#include "DNA_scene_types.h"
-
-#include "BKE_context.h"
-#include "BKE_screen.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_pointcache.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "RNA_access.h"
-#include "RNA_define.h"
-
-#include "physics_intern.h"
-
-static int ptcache_bake_all_poll(bContext *C)
-{
- return CTX_data_scene(C) != NULL;
-}
-
-static int ptcache_poll(bContext *C)
-{
- PointerRNA ptr= CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
- return (ptr.data && ptr.id.data);
-}
-
-typedef struct PointCacheJob {
- void *owner;
- short *stop, *do_update;
- float *progress;
-
- PTCacheBaker *baker;
-} PointCacheJob;
-
-static void ptcache_job_free(void *customdata)
-{
- PointCacheJob *job = customdata;
- MEM_freeN(job->baker);
- MEM_freeN(job);
-}
-
-static int ptcache_job_break(void *customdata)
-{
- PointCacheJob *job = customdata;
-
- if (G.is_break) {
- return 1;
- }
-
- if (job->stop && *(job->stop)) {
- return 1;
- }
-
- return 0;
-}
-
-static void ptcache_job_update(void *customdata, float progress, int *cancel)
-{
- PointCacheJob *job = customdata;
-
- if (ptcache_job_break(job)) {
- *cancel = 1;
- }
-
- *(job->do_update) = true;
- *(job->progress) = progress;
-}
-
-static void ptcache_job_startjob(void *customdata, short *stop, short *do_update, float *progress)
-{
- PointCacheJob *job = customdata;
-
- job->stop = stop;
- job->do_update = do_update;
- job->progress = progress;
-
- G.is_break = false;
-
- /* XXX annoying hack: needed to prevent data corruption when changing
- * scene frame in separate threads
- */
- G.is_rendering = true;
- BKE_spacedata_draw_locks(true);
-
- BKE_ptcache_bake(job->baker);
-
- *do_update = true;
- *stop = 0;
-}
-
-static void ptcache_job_endjob(void *customdata)
-{
- PointCacheJob *job = customdata;
- Scene *scene = job->baker->scene;
-
- G.is_rendering = false;
- BKE_spacedata_draw_locks(false);
-
- WM_set_locked_interface(G.main->wm.first, false);
-
- WM_main_add_notifier(NC_SCENE | ND_FRAME, scene);
- WM_main_add_notifier(NC_OBJECT | ND_POINTCACHE, job->baker->pid.ob);
-}
-
-static void ptcache_free_bake(PointCache *cache)
-{
- if (cache->edit) {
- cache->edit = NULL;
- cache->flag &= ~PTCACHE_BAKED;
- }
- else {
- cache->flag &= ~PTCACHE_BAKED;
- }
-}
-
-static PTCacheBaker *ptcache_baker_create(bContext *C, wmOperator *op, bool all)
-{
- PTCacheBaker *baker = MEM_callocN(sizeof(PTCacheBaker), "PTCacheBaker");
-
- baker->main = CTX_data_main(C);
- baker->scene = CTX_data_scene(C);
- baker->bake = RNA_boolean_get(op->ptr, "bake");
- baker->render = 0;
- baker->anim_init = 0;
- baker->quick_step = 1;
-
- if (!all) {
- PointerRNA ptr = CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
- Object *ob = ptr.id.data;
- PointCache *cache = ptr.data;
-
- ListBase pidlist;
- BKE_ptcache_ids_from_object(&pidlist, ob, baker->scene, MAX_DUPLI_RECUR);
-
- for (PTCacheID *pid = pidlist.first; pid; pid = pid->next) {
- if (pid->cache == cache) {
- baker->pid = *pid;
- break;
- }
- }
-
- BLI_freelistN(&pidlist);
- }
-
- return baker;
-}
-
-static int ptcache_bake_exec(bContext *C, wmOperator *op)
-{
- bool all = STREQ(op->type->idname, "PTCACHE_OT_bake_all");
-
- PTCacheBaker *baker = ptcache_baker_create(C, op, all);
- BKE_ptcache_bake(baker);
- MEM_freeN(baker);
-
- return OPERATOR_FINISHED;
-}
-
-static int ptcache_bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
-{
- bool all = STREQ(op->type->idname, "PTCACHE_OT_bake_all");
-
- PointCacheJob *job = MEM_mallocN(sizeof(PointCacheJob), "PointCacheJob");
- job->baker = ptcache_baker_create(C, op, all);
- job->baker->bake_job = job;
- job->baker->update_progress = ptcache_job_update;
-
- wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), CTX_data_scene(C),
- "Point Cache", WM_JOB_PROGRESS, WM_JOB_TYPE_POINTCACHE);
-
- WM_jobs_customdata_set(wm_job, job, ptcache_job_free);
- WM_jobs_timer(wm_job, 0.1, NC_OBJECT | ND_POINTCACHE, NC_OBJECT | ND_POINTCACHE);
- WM_jobs_callbacks(wm_job, ptcache_job_startjob, NULL, NULL, ptcache_job_endjob);
-
- WM_set_locked_interface(CTX_wm_manager(C), true);
-
- WM_jobs_start(CTX_wm_manager(C), wm_job);
-
- WM_event_add_modal_handler(C, op);
-
- /* we must run modal until the bake job is done, otherwise the undo push
- * happens before the job ends, which can lead to race conditions between
- * the baking and file writing code */
- return OPERATOR_RUNNING_MODAL;
-}
-
-static int ptcache_bake_modal(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
-{
- Scene *scene = (Scene *) op->customdata;
-
- /* no running blender, remove handler and pass through */
- if (0 == WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_POINTCACHE)) {
- return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
- }
-
- return OPERATOR_PASS_THROUGH;
-}
-
-static void ptcache_bake_cancel(bContext *C, wmOperator *op)
-{
- wmWindowManager *wm = CTX_wm_manager(C);
- Scene *scene = (Scene *) op->customdata;
-
- /* kill on cancel, because job is using op->reports */
- WM_jobs_kill_type(wm, scene, WM_JOB_TYPE_POINTCACHE);
-}
-
-static int ptcache_free_bake_all_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Scene *scene= CTX_data_scene(C);
- Base *base;
- PTCacheID *pid;
- ListBase pidlist;
-
- for (base=scene->base.first; base; base= base->next) {
- BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR);
-
- for (pid=pidlist.first; pid; pid=pid->next) {
- ptcache_free_bake(pid->cache);
- }
-
- BLI_freelistN(&pidlist);
-
- WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, base->object);
- }
-
- WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
-
- return OPERATOR_FINISHED;
-}
-
-void PTCACHE_OT_bake_all(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Bake All Physics";
- ot->description = "Bake all physics";
- ot->idname = "PTCACHE_OT_bake_all";
-
- /* api callbacks */
- ot->exec = ptcache_bake_exec;
- ot->invoke = ptcache_bake_invoke;
- ot->modal = ptcache_bake_modal;
- ot->cancel = ptcache_bake_cancel;
- ot->poll = ptcache_bake_all_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
-
- RNA_def_boolean(ot->srna, "bake", 1, "Bake", "");
-}
-void PTCACHE_OT_free_bake_all(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Free All Physics Bakes";
- ot->idname = "PTCACHE_OT_free_bake_all";
- ot->description = "Free all baked caches of all objects in the current scene";
-
- /* api callbacks */
- ot->exec = ptcache_free_bake_all_exec;
- ot->poll = ptcache_bake_all_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
-}
-
-static int ptcache_free_bake_exec(bContext *C, wmOperator *UNUSED(op))
-{
- PointerRNA ptr= CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
- PointCache *cache= ptr.data;
- Object *ob= ptr.id.data;
-
- ptcache_free_bake(cache);
-
- WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob);
-
- return OPERATOR_FINISHED;
-}
-static int ptcache_bake_from_cache_exec(bContext *C, wmOperator *UNUSED(op))
-{
- PointerRNA ptr= CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
- PointCache *cache= ptr.data;
- Object *ob= ptr.id.data;
-
- cache->flag |= PTCACHE_BAKED;
-
- WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob);
-
- return OPERATOR_FINISHED;
-}
-void PTCACHE_OT_bake(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Bake Physics";
- ot->description = "Bake physics";
- ot->idname = "PTCACHE_OT_bake";
-
- /* api callbacks */
- ot->exec = ptcache_bake_exec;
- ot->invoke = ptcache_bake_invoke;
- ot->modal = ptcache_bake_modal;
- ot->cancel = ptcache_bake_cancel;
- ot->poll = ptcache_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
-
- RNA_def_boolean(ot->srna, "bake", 0, "Bake", "");
-}
-void PTCACHE_OT_free_bake(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Free Physics Bake";
- ot->description = "Free physics bake";
- ot->idname = "PTCACHE_OT_free_bake";
-
- /* api callbacks */
- ot->exec = ptcache_free_bake_exec;
- ot->poll = ptcache_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
-}
-void PTCACHE_OT_bake_from_cache(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Bake From Cache";
- ot->description = "Bake from cache";
- ot->idname = "PTCACHE_OT_bake_from_cache";
-
- /* api callbacks */
- ot->exec = ptcache_bake_from_cache_exec;
- ot->poll = ptcache_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
-}
-
-static int ptcache_add_new_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Scene *scene = CTX_data_scene(C);
- PointerRNA ptr= CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
- Object *ob= ptr.id.data;
- PointCache *cache= ptr.data;
- PTCacheID *pid;
- ListBase pidlist;
-
- BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR);
-
- for (pid=pidlist.first; pid; pid=pid->next) {
- if (pid->cache == cache) {
- PointCache *cache_new = BKE_ptcache_add(pid->ptcaches);
- cache_new->step = pid->default_step;
- *(pid->cache_ptr) = cache_new;
- break;
- }
- }
-
- BLI_freelistN(&pidlist);
-
- WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
- WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob);
-
- return OPERATOR_FINISHED;
-}
-static int ptcache_remove_exec(bContext *C, wmOperator *UNUSED(op))
-{
- PointerRNA ptr= CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
- Scene *scene= CTX_data_scene(C);
- Object *ob= ptr.id.data;
- PointCache *cache= ptr.data;
- PTCacheID *pid;
- ListBase pidlist;
-
- BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR);
-
- for (pid=pidlist.first; pid; pid=pid->next) {
- if (pid->cache == cache) {
- if (pid->ptcaches->first == pid->ptcaches->last)
- continue; /* don't delete last cache */
-
- BLI_remlink(pid->ptcaches, pid->cache);
- BKE_ptcache_free(pid->cache);
- *(pid->cache_ptr) = pid->ptcaches->first;
-
- break;
- }
- }
-
- BLI_freelistN(&pidlist);
-
- WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob);
-
- return OPERATOR_FINISHED;
-}
-void PTCACHE_OT_add(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Add New Cache";
- ot->description = "Add new cache";
- ot->idname = "PTCACHE_OT_add";
-
- /* api callbacks */
- ot->exec = ptcache_add_new_exec;
- ot->poll = ptcache_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
-}
-void PTCACHE_OT_remove(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Delete Current Cache";
- ot->description = "Delete current cache";
- ot->idname = "PTCACHE_OT_remove";
-
- /* api callbacks */
- ot->exec = ptcache_remove_exec;
- ot->poll = ptcache_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
-}
-
diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c
index 9872ffad043..ff9136f3554 100644
--- a/source/blender/editors/space_time/space_time.c
+++ b/source/blender/editors/space_time/space_time.c
@@ -44,7 +44,6 @@
#include "BKE_context.h"
#include "BKE_screen.h"
-#include "BKE_pointcache.h"
#include "ED_anim_api.h"
#include "ED_keyframes_draw.h"
@@ -91,155 +90,6 @@ static void time_draw_sfra_efra(Scene *scene, View2D *v2d)
fdrawline((float)PEFRA, v2d->cur.ymin, (float)PEFRA, v2d->cur.ymax);
}
-static void time_draw_cache(SpaceTime *stime, Object *ob, Scene *scene)
-{
- PTCacheID *pid;
- ListBase pidlist;
- SpaceTimeCache *stc = stime->caches.first;
- const float cache_draw_height = (4.0f * UI_DPI_FAC * U.pixelsize);
- float yoffs = 0.f;
-
- if (!(stime->cache_display & TIME_CACHE_DISPLAY) || (!ob))
- return;
-
- BKE_ptcache_ids_from_object(&pidlist, ob, scene, 0);
-
- /* iterate over pointcaches on the active object,
- * add spacetimecache and vertex array for each */
- for (pid = pidlist.first; pid; pid = pid->next) {
- float col[4], *fp;
- int i, sta = pid->cache->startframe, end = pid->cache->endframe;
- int len = (end - sta + 1) * 4;
-
- switch (pid->type) {
- case PTCACHE_TYPE_SOFTBODY:
- if (!(stime->cache_display & TIME_CACHE_SOFTBODY)) continue;
- break;
- case PTCACHE_TYPE_CLOTH:
- if (!(stime->cache_display & TIME_CACHE_CLOTH)) continue;
- break;
- case PTCACHE_TYPE_SMOKE_DOMAIN:
- case PTCACHE_TYPE_SMOKE_HIGHRES:
- if (!(stime->cache_display & TIME_CACHE_SMOKE)) continue;
- break;
- case PTCACHE_TYPE_DYNAMICPAINT:
- if (!(stime->cache_display & TIME_CACHE_DYNAMICPAINT)) continue;
- break;
- case PTCACHE_TYPE_RIGIDBODY:
- if (!(stime->cache_display & TIME_CACHE_RIGIDBODY)) continue;
- break;
- }
-
- if (pid->cache->cached_frames == NULL)
- continue;
-
- /* make sure we have stc with correct array length */
- if (stc == NULL || MEM_allocN_len(stc->array) != len * 2 * sizeof(float)) {
- if (stc) {
- MEM_freeN(stc->array);
- }
- else {
- stc = MEM_callocN(sizeof(SpaceTimeCache), "spacetimecache");
- BLI_addtail(&stime->caches, stc);
- }
-
- stc->array = MEM_callocN(len * 2 * sizeof(float), "SpaceTimeCache array");
- }
-
- /* fill the vertex array with a quad for each cached frame */
- for (i = sta, fp = stc->array; i <= end; i++) {
- if (pid->cache->cached_frames[i - sta]) {
- fp[0] = (float)i - 0.5f;
- fp[1] = 0.0;
- fp += 2;
-
- fp[0] = (float)i - 0.5f;
- fp[1] = 1.0;
- fp += 2;
-
- fp[0] = (float)i + 0.5f;
- fp[1] = 1.0;
- fp += 2;
-
- fp[0] = (float)i + 0.5f;
- fp[1] = 0.0;
- fp += 2;
- }
- }
-
- glPushMatrix();
- glTranslatef(0.0, (float)V2D_SCROLL_HEIGHT + yoffs, 0.0);
- glScalef(1.0, cache_draw_height, 0.0);
-
- switch (pid->type) {
- case PTCACHE_TYPE_SOFTBODY:
- col[0] = 1.0; col[1] = 0.4; col[2] = 0.02;
- col[3] = 0.1;
- break;
- case PTCACHE_TYPE_CLOTH:
- col[0] = 0.1; col[1] = 0.1; col[2] = 0.75;
- col[3] = 0.1;
- break;
- case PTCACHE_TYPE_SMOKE_DOMAIN:
- case PTCACHE_TYPE_SMOKE_HIGHRES:
- col[0] = 0.2; col[1] = 0.2; col[2] = 0.2;
- col[3] = 0.1;
- break;
- case PTCACHE_TYPE_DYNAMICPAINT:
- col[0] = 1.0; col[1] = 0.1; col[2] = 0.75;
- col[3] = 0.1;
- break;
- case PTCACHE_TYPE_RIGIDBODY:
- col[0] = 1.0; col[1] = 0.6; col[2] = 0.0;
- col[3] = 0.1;
- break;
- default:
- col[0] = 1.0; col[1] = 0.0; col[2] = 1.0;
- col[3] = 0.1;
- BLI_assert(0);
- break;
- }
- glColor4fv(col);
-
- glEnable(GL_BLEND);
-
- glRectf((float)sta, 0.0, (float)end, 1.0);
-
- col[3] = 0.4f;
- if (pid->cache->flag & PTCACHE_BAKED) {
- col[0] -= 0.4f; col[1] -= 0.4f; col[2] -= 0.4f;
- }
- else if (pid->cache->flag & PTCACHE_OUTDATED) {
- col[0] += 0.4f; col[1] += 0.4f; col[2] += 0.4f;
- }
- glColor4fv(col);
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(2, GL_FLOAT, 0, stc->array);
- glDrawArrays(GL_QUADS, 0, (fp - stc->array) / 2);
- glDisableClientState(GL_VERTEX_ARRAY);
-
- glDisable(GL_BLEND);
-
- glPopMatrix();
-
- yoffs += cache_draw_height;
-
- stc = stc->next;
- }
-
- BLI_freelistN(&pidlist);
-
- /* free excessive caches */
- while (stc) {
- SpaceTimeCache *tmp = stc->next;
- BLI_remlink(&stime->caches, stc);
- MEM_freeN(stc->array);
- MEM_freeN(stc);
- stc = tmp;
- }
-}
-
static void time_cache_free(SpaceTime *stime)
{
SpaceTimeCache *stc;
@@ -498,7 +348,6 @@ static void time_main_region_draw(const bContext *C, ARegion *ar)
/* draw entirely, view changes should be handled here */
Scene *scene = CTX_data_scene(C);
SpaceTime *stime = CTX_wm_space_time(C);
- Object *obact = CTX_data_active_object(C);
View2D *v2d = &ar->v2d;
View2DGrid *grid;
View2DScrollers *scrollers;
@@ -536,9 +385,6 @@ static void time_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_orthoSpecial(ar, v2d, 1);
ED_markers_draw(C, 0);
- /* caches */
- time_draw_cache(stime, obact, scene);
-
/* callback */
UI_view2d_view_ortho(v2d);
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 0aa62c4467e..c5d4d8ecf7d 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -37,6 +37,7 @@
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
+#include "DNA_object_force.h"
#include "DNA_rigidbody_types.h"
#include "DNA_scene_types.h"
#include "DNA_smoke_types.h"
@@ -71,7 +72,6 @@
#include "BKE_movieclip.h"
#include "BKE_object.h"
#include "BKE_paint.h"
-#include "BKE_pointcache.h"
#include "BKE_scene.h"
#include "BKE_subsurf.h"
#include "BKE_unit.h"
@@ -6694,6 +6694,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
/* only draw domains */
if (smd->domain) {
SmokeDomainSettings *sds = smd->domain;
+ const bool show_smoke = true; /* XXX was checking cached frame range before */
float viewnormal[3];
glLoadMatrixf(rv3d->viewmat);
@@ -6734,7 +6735,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
}
/* don't show smoke before simulation starts, this could be made an option in the future */
- if (sds->fluid && CFRA >= sds->point_cache[0]->startframe) {
+ if (sds->fluid && show_smoke) {
float p0[3], p1[3];
/* get view vector */
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index b0174b5cbca..2139dba8a79 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -83,7 +83,6 @@
#include "BKE_node.h"
#include "BKE_object.h"
#include "BKE_paint.h"
-#include "BKE_pointcache.h"
#include "BKE_report.h"
#include "BKE_rigidbody.h"
#include "BKE_scene.h"
@@ -6127,8 +6126,6 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
for (i = 0; i < t->total; i++) {
TransData *td = t->data + i;
- ListBase pidlist;
- PTCacheID *pid;
ob = td->ob;
if (td->flag & TD_NOACTION)
@@ -6137,17 +6134,6 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
if (td->flag & TD_SKIP)
continue;
- /* flag object caches as outdated */
- BKE_ptcache_ids_from_object(&pidlist, ob, t->scene, MAX_DUPLI_RECUR);
- for (pid = pidlist.first; pid; pid = pid->next) {
- pid->cache->flag |= PTCACHE_OUTDATED;
- }
- BLI_freelistN(&pidlist);
-
- /* pointcache refresh */
- if (BKE_ptcache_object_reset(t->scene, ob, PTCACHE_RESET_OUTDATED))
- DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
-
/* Needed for proper updating of "quick cached" dynamics. */
/* Creates troubles for moving animated objects without */
/* autokey though, probably needed is an anim sys override? */
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index d420ddffda2..b81fc471515 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -55,7 +55,6 @@
#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_global.h"
-#include "BKE_pointcache.h"
#include "BKE_editmesh.h"
#include "BKE_lattice.h"
diff --git a/source/blender/makesdna/DNA_dynamicpaint_types.h b/source/blender/makesdna/DNA_dynamicpaint_types.h
index defc51c8802..071b576eda5 100644
--- a/source/blender/makesdna/DNA_dynamicpaint_types.h
+++ b/source/blender/makesdna/DNA_dynamicpaint_types.h
@@ -108,8 +108,6 @@ typedef struct DynamicPaintSurface {
struct EffectorWeights *effector_weights;
/* cache */
- struct PointCache *pointcache;
- struct ListBase ptcaches;
int current_frame;
/* surface */
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 9215606b0cc..1818aee5509 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -592,8 +592,6 @@ typedef struct ClothModifierData {
struct Cloth *clothObject; /* The internal data structure for cloth. */
struct ClothSimSettings *sim_parms; /* definition is in DNA_cloth_types.h */
struct ClothCollSettings *coll_parms; /* definition is in DNA_cloth_types.h */
- struct PointCache *point_cache; /* definition is in DNA_object_force.h */
- struct ListBase ptcaches;
/* XXX nasty hack, remove once hair can be separated from cloth modifier data */
struct ClothHairData *hairdata;
/* grid geometry values of hair continuum */
@@ -746,7 +744,6 @@ typedef struct FluidsimModifierData {
ModifierData modifier;
struct FluidsimSettings *fss; /* definition is in DNA_object_fluidsim.h */
- struct PointCache *point_cache; /* definition is in DNA_object_force.h */
} FluidsimModifierData;
typedef struct ShrinkwrapModifierData {
diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h
index cccee82cb51..94bf7e456cd 100644
--- a/source/blender/makesdna/DNA_object_force.h
+++ b/source/blender/makesdna/DNA_object_force.h
@@ -127,87 +127,6 @@ typedef struct EffectorWeights {
/* EffectorWeights->flag */
#define EFF_WEIGHT_DO_HAIR 1
-/* Point cache file data types:
- * - used as (1<<flag) so poke jahka if you reach the limit of 15
- * - to add new data types update:
- * * BKE_ptcache_data_size()
- * * ptcache_file_init_pointers()
- */
-#define BPHYS_DATA_INDEX 0
-#define BPHYS_DATA_LOCATION 1
-#define BPHYS_DATA_SMOKE_LOW 1
-#define BPHYS_DATA_VELOCITY 2
-#define BPHYS_DATA_SMOKE_HIGH 2
-#define BPHYS_DATA_ROTATION 3
-#define BPHYS_DATA_DYNAMICPAINT 3
-#define BPHYS_DATA_AVELOCITY 4 /* used for particles */
-#define BPHYS_DATA_XCONST 4 /* used for cloth */
-#define BPHYS_DATA_SIZE 5
-#define BPHYS_DATA_TIMES 6
-#define BPHYS_DATA_BOIDS 7
-
-#define BPHYS_TOT_DATA 8
-
-#define BPHYS_EXTRA_FLUID_SPRINGS 1
-
-typedef struct PTCacheExtra {
- struct PTCacheExtra *next, *prev;
- unsigned int type, totdata;
- void *data;
-} PTCacheExtra;
-
-typedef struct PTCacheMem {
- struct PTCacheMem *next, *prev;
- unsigned int frame, totpoint;
- unsigned int data_types, flag;
-
- void *data[8]; /* BPHYS_TOT_DATA */
- void *cur[8]; /* BPHYS_TOT_DATA */
-
- struct ListBase extradata;
-} PTCacheMem;
-
-typedef struct PointCache {
- struct PointCache *next, *prev;
- int flag; /* generic flag */
-
- int step; /* The number of frames between cached frames.
- * This should probably be an upper bound for a per point adaptive step in the future,
- * buf for now it's the same for all points. Without adaptivity this can effect the perceived
- * simulation quite a bit though. If for example particles are colliding with a horizontal
- * plane (with high damping) they quickly come to a stop on the plane, however there are still
- * forces acting on the particle (gravity and collisions), so the particle velocity isn't necessarily
- * zero for the whole duration of the frame even if the particle seems stationary. If all simulation
- * frames aren't cached (step > 1) these velocities are interpolated into movement for the non-cached
- * frames. The result will look like the point is oscillating around the collision location. So for
- * now cache step should be set to 1 for accurate reproduction of collisions.
- */
-
- int simframe; /* current frame of simulation (only if SIMULATION_VALID) */
- int startframe; /* simulation start frame */
- int endframe; /* simulation end frame */
- int editframe; /* frame being edited (runtime only) */
- int last_exact; /* last exact frame that's cached */
- int last_valid; /* used for editing cache - what is the last baked frame */
- int pad;
-
- /* for external cache files */
- int totpoint; /* number of cached points */
- int index; /* modifier stack index */
- short compression, rt;
-
- char name[64];
- char prev_name[64];
- char info[64];
- char path[1024]; /* file path, 1024 = FILE_MAX */
- char *cached_frames; /* array of length endframe-startframe+1 with flags to indicate cached frames */
- /* can be later used for other per frame flags too if needed */
- struct ListBase mem_cache;
-
- struct PTCacheEdit *edit;
- void (*free_edit)(struct PTCacheEdit *edit); /* free callback */
-} PointCache;
-
typedef struct SBVertex {
float vec[4];
} SBVertex;
@@ -336,9 +255,6 @@ typedef struct SoftBody {
float shearstiff;
float inpush;
- struct PointCache *pointcache;
- struct ListBase ptcaches;
-
struct EffectorWeights *effector_weights;
/* reverse esimated obmatrix .. no need to store in blend file .. how ever who cares */
float lcom[3];
@@ -392,31 +308,6 @@ typedef struct SoftBody {
#define PFIELD_Z_POS 1
#define PFIELD_Z_NEG 2
-/* pointcache->flag */
-#define PTCACHE_BAKED 1
-#define PTCACHE_OUTDATED 2
-#define PTCACHE_SIMULATION_VALID 4
-#define PTCACHE_BAKING 8
-//#define PTCACHE_BAKE_EDIT 16
-//#define PTCACHE_BAKE_EDIT_ACTIVE 32
-#define PTCACHE_DISK_CACHE 64
-//#define PTCACHE_QUICK_CACHE 128 /* removed since 2.64 - [#30974], could be added back in a more useful way */
-#define PTCACHE_FRAMES_SKIPPED 256
-#define PTCACHE_EXTERNAL 512
-#define PTCACHE_READ_INFO 1024
-/* don't use the filename of the blendfile the data is linked from (write a local cache) */
-#define PTCACHE_IGNORE_LIBPATH 2048
-/* high resolution cache is saved for smoke for backwards compatibility, so set this flag to know it's a "fake" cache */
-#define PTCACHE_FAKE_SMOKE (1<<12)
-#define PTCACHE_IGNORE_CLEAR (1<<13)
-
-/* PTCACHE_OUTDATED + PTCACHE_FRAMES_SKIPPED */
-#define PTCACHE_REDO_NEEDED 258
-
-#define PTCACHE_COMPRESS_NO 0
-#define PTCACHE_COMPRESS_LZO 1
-#define PTCACHE_COMPRESS_LZMA 2
-
/* ob->softflag */
#define OB_SB_ENABLE 1 /* deprecated, use modifier */
#define OB_SB_GOAL 2
diff --git a/source/blender/makesdna/DNA_rigidbody_types.h b/source/blender/makesdna/DNA_rigidbody_types.h
index 5d76ffe57b5..934028f2e5f 100644
--- a/source/blender/makesdna/DNA_rigidbody_types.h
+++ b/source/blender/makesdna/DNA_rigidbody_types.h
@@ -58,9 +58,6 @@ typedef struct RigidBodyWorld {
int pad;
float ltime; /* last frame world was evaluated for (internal) */
- /* cache */
- struct PointCache *pointcache;
- struct ListBase ptcaches;
int numbodies; /* number of objects in rigid body group */
short steps_per_second; /* number of simulation steps thaken per second */
diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h
index ff85c254215..71801ac4a5d 100644
--- a/source/blender/makesdna/DNA_smoke_types.h
+++ b/source/blender/makesdna/DNA_smoke_types.h
@@ -146,9 +146,6 @@ typedef struct SmokeDomainSettings {
char data_depth;
char pad[2];
- /* Smoke uses only one cache from now on (index [0]), but keeping the array for now for reading old files. */
- struct PointCache *point_cache[2]; /* definition is in DNA_object_force.h */
- struct ListBase ptcaches[2];
struct EffectorWeights *effector_weights;
int border_collisions; /* How domain border collisions are handled */
float time_scale;
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 0c7c3d4106c..09f4ea1cf02 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -445,7 +445,6 @@ extern StructRNA RNA_Palette;
extern StructRNA RNA_PaletteColor;
extern StructRNA RNA_Panel;
extern StructRNA RNA_PivotConstraint;
-extern StructRNA RNA_PointCache;
extern StructRNA RNA_PointDensity;
extern StructRNA RNA_PointDensityTexture;
extern StructRNA RNA_PointLamp;
diff --git a/source/blender/makesrna/intern/rna_dynamicpaint.c b/source/blender/makesrna/intern/rna_dynamicpaint.c
index f259e122906..70554bd603b 100644
--- a/source/blender/makesrna/intern/rna_dynamicpaint.c
+++ b/source/blender/makesrna/intern/rna_dynamicpaint.c
@@ -100,11 +100,6 @@ static void rna_DynamicPaint_redoModifier(Main *UNUSED(bmain), Scene *UNUSED(sce
DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
}
-static void rna_DynamicPaintSurfaces_updateFrames(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
-{
- dynamicPaint_cacheUpdateFrames((DynamicPaintSurface *)ptr->data);
-}
-
static void rna_DynamicPaintSurface_reset(Main *bmain, Scene *scene, PointerRNA *ptr)
{
dynamicPaint_resetSurface(scene, (DynamicPaintSurface *)ptr->data);
@@ -183,20 +178,20 @@ static void rna_DynamicPaint_surfaces_begin(CollectionPropertyIterator *iter, Po
rna_iterator_listbase_begin(iter, &canvas->surfaces, NULL);
}
-static int rna_Surface_active_point_index_get(PointerRNA *ptr)
+static int rna_Surface_active_index_get(PointerRNA *ptr)
{
DynamicPaintCanvasSettings *canvas = (DynamicPaintCanvasSettings *)ptr->data;
return canvas->active_sur;
}
-static void rna_Surface_active_point_index_set(struct PointerRNA *ptr, int value)
+static void rna_Surface_active_index_set(struct PointerRNA *ptr, int value)
{
DynamicPaintCanvasSettings *canvas = (DynamicPaintCanvasSettings *)ptr->data;
canvas->active_sur = value;
return;
}
-static void rna_Surface_active_point_range(PointerRNA *ptr, int *min, int *max,
+static void rna_Surface_active_range(PointerRNA *ptr, int *min, int *max,
int *UNUSED(softmin), int *UNUSED(softmax))
{
DynamicPaintCanvasSettings *canvas = (DynamicPaintCanvasSettings *)ptr->data;
@@ -221,7 +216,7 @@ static void rna_DynamicPaint_uvlayer_set(PointerRNA *ptr, const char *value)
}
}
-/* is point cache used */
+/* is cache used */
static int rna_DynamicPaint_is_cache_user_get(PointerRNA *ptr)
{
DynamicPaintSurface *surface = (DynamicPaintSurface *)ptr->data;
@@ -310,9 +305,9 @@ static void rna_def_canvas_surfaces(BlenderRNA *brna, PropertyRNA *cprop)
prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_int_funcs(prop, "rna_Surface_active_point_index_get", "rna_Surface_active_point_index_set",
- "rna_Surface_active_point_range");
- RNA_def_property_ui_text(prop, "Active Point Cache Index", "");
+ RNA_def_property_int_funcs(prop, "rna_Surface_active_index_get", "rna_Surface_active_index_set",
+ "rna_Surface_active_range");
+ RNA_def_property_ui_text(prop, "Active Surface Index", "");
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "DynamicPaintSurface");
@@ -472,7 +467,7 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
RNA_def_property_range(prop, 1.0, MAXFRAMEF);
RNA_def_property_ui_range(prop, 1.0, 9999, 1, -1);
RNA_def_property_ui_text(prop, "Start Frame", "Simulation start frame");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaintSurfaces_updateFrames");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "end_frame");
@@ -480,7 +475,7 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
RNA_def_property_range(prop, 1.0, MAXFRAMEF);
RNA_def_property_ui_range(prop, 1.0, 9999.0, 1, -1);
RNA_def_property_ui_text(prop, "End Frame", "Simulation end frame");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaintSurfaces_updateFrames");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
prop = RNA_def_property(srna, "frame_substeps", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "substeps");
@@ -721,13 +716,6 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_WAVE_OPEN_BORDERS);
RNA_def_property_ui_text(prop, "Open Borders", "Pass waves through mesh edges");
-
- /* cache */
- 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, "pointcache");
- RNA_def_property_ui_text(prop, "Point Cache", "");
-
/* is cache used */
prop = RNA_def_property(srna, "is_cache_user", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_DynamicPaint_is_cache_user_get", NULL);
diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c
index 35155687f85..95cb21e5858 100644
--- a/source/blender/makesrna/intern/rna_fluidsim.c
+++ b/source/blender/makesrna/intern/rna_fluidsim.c
@@ -51,7 +51,6 @@
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_modifier.h"
-#include "BKE_pointcache.h"
static StructRNA *rna_FluidSettings_refine(struct PointerRNA *ptr)
{
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 62676e26a84..105b7f1b283 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -690,12 +690,6 @@ static PointerRNA rna_SoftBodyModifier_settings_get(PointerRNA *ptr)
return rna_pointer_inherit_refine(ptr, &RNA_SoftBodySettings, ob->soft);
}
-static PointerRNA rna_SoftBodyModifier_point_cache_get(PointerRNA *ptr)
-{
- Object *ob = (Object *)ptr->id.data;
- return rna_pointer_inherit_refine(ptr, &RNA_PointCache, ob->soft->pointcache);
-}
-
static PointerRNA rna_CollisionModifier_settings_get(PointerRNA *ptr)
{
Object *ob = (Object *)ptr->id.data;
@@ -1858,12 +1852,6 @@ static void rna_def_modifier_softbody(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "SoftBodySettings");
RNA_def_property_pointer_funcs(prop, "rna_SoftBodyModifier_settings_get", NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Soft Body Settings", "");
-
- prop = RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NONE);
- RNA_def_property_flag(prop, PROP_NEVER_NULL);
- RNA_def_property_struct_type(prop, "PointCache");
- RNA_def_property_pointer_funcs(prop, "rna_SoftBodyModifier_point_cache_get", NULL, NULL, NULL);
- RNA_def_property_ui_text(prop, "Soft Body Point Cache", "");
}
static void rna_def_modifier_boolean(BlenderRNA *brna)
@@ -2612,10 +2600,6 @@ static void rna_def_modifier_cloth(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "ClothSolverResult");
RNA_def_property_pointer_sdna(prop, NULL, "solver_result");
RNA_def_property_ui_text(prop, "Solver Result", "");
-
- prop = RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NONE);
- RNA_def_property_flag(prop, PROP_NEVER_NULL);
- RNA_def_property_ui_text(prop, "Point Cache", "");
prop = RNA_def_property(srna, "hair_grid_min", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "hair_grid_min");
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index 7d880be5830..0531cd385b6 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -90,231 +90,16 @@ static EnumPropertyItem empty_vortex_shape_items[] = {
#include "MEM_guardedalloc.h"
+#include "DNA_dynamicpaint_types.h"
#include "DNA_modifier_types.h"
#include "DNA_texture_types.h"
#include "BKE_context.h"
#include "BKE_modifier.h"
-#include "BKE_pointcache.h"
#include "BKE_depsgraph.h"
#include "ED_object.h"
-static void rna_Cache_change(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
-{
- Object *ob = (Object *)ptr->id.data;
- PointCache *cache = (PointCache *)ptr->data;
- PTCacheID *pid = NULL;
- ListBase pidlist;
-
- if (!ob)
- return;
-
- cache->flag |= PTCACHE_OUTDATED;
-
- BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0);
-
- DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
-
- for (pid = pidlist.first; pid; pid = pid->next) {
- if (pid->cache == cache)
- break;
- }
-
- if (pid) {
- /* Just make sure this wasn't changed. */
- if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN)
- cache->step = 1;
- BKE_ptcache_update_info(pid);
- }
-
- BLI_freelistN(&pidlist);
-}
-
-static void rna_Cache_toggle_disk_cache(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
-{
- Object *ob = (Object *)ptr->id.data;
- PointCache *cache = (PointCache *)ptr->data;
- PTCacheID *pid = NULL;
- ListBase pidlist;
-
- if (!ob)
- return;
-
- BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0);
-
- for (pid = pidlist.first; pid; pid = pid->next) {
- if (pid->cache == cache)
- break;
- }
-
- /* smoke can only use disk cache */
- if (pid && pid->type != PTCACHE_TYPE_SMOKE_DOMAIN)
- BKE_ptcache_toggle_disk_cache(pid);
- else
- cache->flag ^= PTCACHE_DISK_CACHE;
-
- BLI_freelistN(&pidlist);
-}
-
-static void rna_Cache_idname_change(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
-{
- Object *ob = (Object *)ptr->id.data;
- PointCache *cache = (PointCache *)ptr->data;
- PTCacheID *pid = NULL, *pid2 = NULL;
- ListBase pidlist;
- bool use_new_name = true;
-
- if (!ob)
- return;
-
- /* TODO: check for proper characters */
-
- BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0);
-
- if (cache->flag & PTCACHE_EXTERNAL) {
- for (pid = pidlist.first; pid; pid = pid->next) {
- if (pid->cache == cache)
- break;
- }
-
- if (!pid)
- return;
-
- BKE_ptcache_load_external(pid);
-
- DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
- WM_main_add_notifier(NC_OBJECT | ND_POINTCACHE, ob);
- }
- else {
- for (pid = pidlist.first; pid; pid = pid->next) {
- if (pid->cache == cache)
- pid2 = pid;
- else if (cache->name[0] != '\0' && STREQ(cache->name, pid->cache->name)) {
- /*TODO: report "name exists" to user */
- BLI_strncpy(cache->name, cache->prev_name, sizeof(cache->name));
- use_new_name = false;
- }
- }
-
- if (use_new_name) {
- if (pid2 && cache->flag & PTCACHE_DISK_CACHE) {
- char old_name[80];
- char new_name[80];
-
- BLI_strncpy(old_name, cache->prev_name, sizeof(old_name));
- BLI_strncpy(new_name, cache->name, sizeof(new_name));
-
- BKE_ptcache_disk_cache_rename(pid2, old_name, new_name);
- }
-
- BLI_strncpy(cache->prev_name, cache->name, sizeof(cache->prev_name));
- }
- }
-
- BLI_freelistN(&pidlist);
-}
-
-static void rna_Cache_list_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
-{
- PointCache *cache = ptr->data;
- ListBase lb;
-
- while (cache->prev)
- cache = cache->prev;
-
- lb.first = cache;
- lb.last = NULL; /* not used by listbase_begin */
-
- rna_iterator_listbase_begin(iter, &lb, NULL);
-}
-static void rna_Cache_active_point_cache_index_range(PointerRNA *ptr, int *min, int *max,
- int *UNUSED(softmin), int *UNUSED(softmax))
-{
- Object *ob = ptr->id.data;
- PointCache *cache = ptr->data;
- PTCacheID *pid;
- ListBase pidlist;
-
- BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0);
-
- *min = 0;
- *max = 0;
-
- for (pid = pidlist.first; pid; pid = pid->next) {
- if (pid->cache == cache) {
- *max = max_ii(0, BLI_listbase_count(pid->ptcaches) - 1);
- break;
- }
- }
-
- BLI_freelistN(&pidlist);
-}
-
-static int rna_Cache_active_point_cache_index_get(PointerRNA *ptr)
-{
- Object *ob = ptr->id.data;
- PointCache *cache = ptr->data;
- PTCacheID *pid;
- ListBase pidlist;
- int num = 0;
-
- BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0);
-
- for (pid = pidlist.first; pid; pid = pid->next) {
- if (pid->cache == cache) {
- num = BLI_findindex(pid->ptcaches, cache);
- break;
- }
- }
-
- BLI_freelistN(&pidlist);
-
- return num;
-}
-
-static void rna_Cache_active_point_cache_index_set(struct PointerRNA *ptr, int value)
-{
- Object *ob = ptr->id.data;
- PointCache *cache = ptr->data;
- PTCacheID *pid;
- ListBase pidlist;
-
- BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0);
-
- for (pid = pidlist.first; pid; pid = pid->next) {
- if (pid->cache == cache) {
- *(pid->cache_ptr) = BLI_findlink(pid->ptcaches, value);
- break;
- }
- }
-
- BLI_freelistN(&pidlist);
-}
-
-static void rna_PointCache_frame_step_range(PointerRNA *ptr, int *min, int *max,
- int *UNUSED(softmin), int *UNUSED(softmax))
-{
- Object *ob = ptr->id.data;
- PointCache *cache = ptr->data;
- PTCacheID *pid;
- ListBase pidlist;
-
- *min = 1;
- *max = 20;
-
- BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0);
-
- for (pid = pidlist.first; pid; pid = pid->next) {
- if (pid->cache == cache) {
- *max = pid->max_step;
- break;
- }
- }
-
- BLI_freelistN(&pidlist);
-}
-
static char *rna_CollisionSettings_path(PointerRNA *UNUSED(ptr))
{
/* both methods work ok, but return the shorter path */
@@ -555,18 +340,8 @@ static void rna_EffectorWeight_update(Main *UNUSED(bmain), Scene *UNUSED(scene),
{
ID *id = ptr->id.data;
- if (id && GS(id->name) == ID_SCE) {
- Scene *scene = (Scene *)id;
- Base *base;
-
- for (base = scene->base.first; base; base = base->next) {
- BKE_ptcache_object_reset(scene, base->object, PTCACHE_RESET_DEPSGRAPH);
- }
- }
- else {
- DAG_id_tag_update(id, OB_RECALC_DATA);
- WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL);
- }
+ DAG_id_tag_update(id, OB_RECALC_DATA);
+ WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL);
}
static void rna_EffectorWeight_dependency_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
@@ -703,140 +478,6 @@ static EnumPropertyItem *rna_Effector_shape_itemf(bContext *UNUSED(C), PointerRN
#else
-/* ptcache.point_caches */
-static void rna_def_ptcache_point_caches(BlenderRNA *brna, PropertyRNA *cprop)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- /* FunctionRNA *func; */
- /* PropertyRNA *parm; */
-
- RNA_def_property_srna(cprop, "PointCaches");
- srna = RNA_def_struct(brna, "PointCaches", NULL);
- RNA_def_struct_sdna(srna, "PointCache");
- RNA_def_struct_ui_text(srna, "Point Caches", "Collection of point caches");
-
- prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
- RNA_def_property_int_funcs(prop, "rna_Cache_active_point_cache_index_get",
- "rna_Cache_active_point_cache_index_set",
- "rna_Cache_active_point_cache_index_range");
- RNA_def_property_ui_text(prop, "Active Point Cache Index", "");
- RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_change");
-}
-
-static void rna_def_pointcache(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- static EnumPropertyItem point_cache_compress_items[] = {
- {PTCACHE_COMPRESS_NO, "NO", 0, "No", "No compression"},
- {PTCACHE_COMPRESS_LZO, "LIGHT", 0, "Light", "Fast but not so effective compression"},
- {PTCACHE_COMPRESS_LZMA, "HEAVY", 0, "Heavy", "Effective but slow compression"},
- {0, NULL, 0, NULL, NULL}
- };
-
- srna = RNA_def_struct(brna, "PointCache", NULL);
- RNA_def_struct_ui_text(srna, "Point Cache", "Point cache for physics simulations");
- RNA_def_struct_ui_icon(srna, ICON_PHYSICS);
-
- prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
- RNA_def_property_int_sdna(prop, NULL, "startframe");
- RNA_def_property_range(prop, -MAXFRAME, MAXFRAME);
- RNA_def_property_ui_range(prop, 1, MAXFRAME, 1, 1);
- RNA_def_property_ui_text(prop, "Start", "Frame on which the simulation starts");
-
- prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_TIME);
- RNA_def_property_int_sdna(prop, NULL, "endframe");
- RNA_def_property_range(prop, 1, MAXFRAME);
- RNA_def_property_ui_text(prop, "End", "Frame on which the simulation stops");
-
- prop = RNA_def_property(srna, "frame_step", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "step");
- RNA_def_property_range(prop, 1, 20);
- RNA_def_property_int_funcs(prop, NULL, NULL, "rna_PointCache_frame_step_range");
- RNA_def_property_ui_text(prop, "Cache Step", "Number of frames between cached frames");
- RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_change");
-
- prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "index");
- RNA_def_property_range(prop, -1, 100);
- RNA_def_property_ui_text(prop, "Cache Index", "Index number of cache files");
- RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change");
-
- prop = RNA_def_property(srna, "compression", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_items(prop, point_cache_compress_items);
- RNA_def_property_ui_text(prop, "Cache Compression", "Compression method to be used");
-
- /* flags */
- prop = RNA_def_property(srna, "is_baked", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_BAKED);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
- prop = RNA_def_property(srna, "is_baking", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_BAKING);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
- prop = RNA_def_property(srna, "use_disk_cache", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_DISK_CACHE);
- RNA_def_property_ui_text(prop, "Disk Cache", "Save cache files to disk (.blend file must be saved first)");
- RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_toggle_disk_cache");
-
- prop = RNA_def_property(srna, "is_outdated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_OUTDATED);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Cache is outdated", "");
-
- prop = RNA_def_property(srna, "is_frame_skip", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_FRAMES_SKIPPED);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
- prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "name");
- RNA_def_property_ui_text(prop, "Name", "Cache name");
- RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change");
- RNA_def_struct_name_property(srna, prop);
-
- prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_DIRPATH);
- RNA_def_property_string_sdna(prop, NULL, "path");
- RNA_def_property_ui_text(prop, "File Path", "Cache file path");
- RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change");
-
- /* removed, see PTCACHE_QUICK_CACHE */
-#if 0
- prop = RNA_def_property(srna, "use_quick_cache", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_QUICK_CACHE);
- RNA_def_property_ui_text(prop, "Quick Cache", "Update simulation with cache steps");
- RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_change");
-#endif
-
- prop = RNA_def_property(srna, "info", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "info");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Cache Info", "Info on current cache status");
-
- prop = RNA_def_property(srna, "use_external", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_EXTERNAL);
- RNA_def_property_ui_text(prop, "External", "Read cache from an external location");
- RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change");
-
- prop = RNA_def_property(srna, "use_library_path", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", PTCACHE_IGNORE_LIBPATH);
- RNA_def_property_ui_text(prop, "Library Path",
- "Use this file's path for the disk cache when library linked into another file "
- "(for local bakes per scene file, disable this option)");
- RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change");
-
- prop = RNA_def_property(srna, "point_caches", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_collection_funcs(prop, "rna_Cache_list_begin", "rna_iterator_listbase_next",
- "rna_iterator_listbase_end", "rna_iterator_listbase_get",
- NULL, NULL, NULL, NULL);
- RNA_def_property_struct_type(prop, "PointCache");
- RNA_def_property_ui_text(prop, "Point Cache List", "Point cache list");
- rna_def_ptcache_point_caches(brna, prop);
-}
-
static void rna_def_collision(BlenderRNA *brna)
{
StructRNA *srna;
@@ -1801,7 +1442,6 @@ static void rna_def_softbody(BlenderRNA *brna)
void RNA_def_object_force(BlenderRNA *brna)
{
- rna_def_pointcache(brna);
rna_def_collision(brna);
rna_def_effector_weight(brna);
rna_def_field(brna);
diff --git a/source/blender/makesrna/intern/rna_rigidbody.c b/source/blender/makesrna/intern/rna_rigidbody.c
index bdf001ed0e1..074a24ad01f 100644
--- a/source/blender/makesrna/intern/rna_rigidbody.c
+++ b/source/blender/makesrna/intern/rna_rigidbody.c
@@ -109,8 +109,7 @@ static EnumPropertyItem rigidbody_mesh_source_items[] = {
static void rna_RigidBodyWorld_reset(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
RigidBodyWorld *rbw = (RigidBodyWorld *)ptr->data;
-
- BKE_rigidbody_cache_reset(rbw);
+ UNUSED_VARS(rbw);
}
static char *rna_RigidBodyWorld_path(PointerRNA *UNUSED(ptr))
@@ -149,10 +148,10 @@ static void rna_RigidBodyWorld_split_impulse_set(PointerRNA *ptr, int value)
static void rna_RigidBodyOb_reset(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
{
RigidBodyWorld *rbw = scene->rigidbody_world;
-
- BKE_rigidbody_cache_reset(rbw);
+ UNUSED_VARS(rbw);
}
+
static void rna_RigidBodyOb_shape_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
Object *ob = ptr->id.data;
@@ -162,12 +161,10 @@ static void rna_RigidBodyOb_shape_update(Main *bmain, Scene *scene, PointerRNA *
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
}
-static void rna_RigidBodyOb_shape_reset(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
+static void rna_RigidBodyOb_shape_reset(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
- RigidBodyWorld *rbw = scene->rigidbody_world;
RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
- BKE_rigidbody_cache_reset(rbw);
if (rbo->physics_shape)
rbo->flag |= RBO_FLAG_NEEDS_RESHAPE;
}
@@ -721,12 +718,6 @@ static void rna_def_rigidbody_world(BlenderRNA *brna)
"stability a little so use only when necessary)");
RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset");
- /* cache */
- 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, "pointcache");
- RNA_def_property_ui_text(prop, "Point Cache", "");
-
/* effector weights */
prop = RNA_def_property(srna, "effector_weights", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "EffectorWeights");
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index a32967ecca7..db1cf9bda89 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -422,7 +422,6 @@ EnumPropertyItem rna_enum_bake_pass_filter_type_items[] = {
#include "BKE_image.h"
#include "BKE_main.h"
#include "BKE_node.h"
-#include "BKE_pointcache.h"
#include "BKE_scene.h"
#include "BKE_depsgraph.h"
#include "BKE_mesh.h"
@@ -1511,15 +1510,6 @@ static void rna_Scene_use_nodes_update(bContext *C, PointerRNA *ptr)
ED_node_composit_default(C, scene);
}
-static void rna_Physics_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
-{
- Scene *scene = (Scene *)ptr->id.data;
- Base *base;
-
- for (base = scene->base.first; base; base = base->next)
- BKE_ptcache_object_reset(scene, base->object, PTCACHE_RESET_DEPSGRAPH);
-}
-
static void rna_Scene_editmesh_select_mode_set(PointerRNA *ptr, const int *value)
{
Scene *scene = (Scene *)ptr->id.data;
@@ -6668,12 +6658,10 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_array(prop, 3);
RNA_def_property_ui_range(prop, -200.0f, 200.0f, 1, 2);
RNA_def_property_ui_text(prop, "Gravity", "Constant acceleration in a given direction");
- RNA_def_property_update(prop, 0, "rna_Physics_update");
prop = RNA_def_property(srna, "use_gravity", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "physics_settings.flag", PHYS_GLOBAL_GRAVITY);
RNA_def_property_ui_text(prop, "Global Gravity", "Use global gravity for all dynamics");
- RNA_def_property_update(prop, 0, "rna_Physics_update");
/* Render Data */
prop = RNA_def_property(srna, "render", PROP_POINTER, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index 5e47f5c63be..68da2b6dedc 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -80,7 +80,6 @@ EnumPropertyItem rna_enum_symmetrize_direction_items[] = {
#include "BKE_context.h"
#include "BKE_DerivedMesh.h"
-#include "BKE_pointcache.h"
#include "BKE_depsgraph.h"
#include "BKE_pbvh.h"
diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c
index d2dca37d072..3f9bcde4ce2 100644
--- a/source/blender/makesrna/intern/rna_smoke.c
+++ b/source/blender/makesrna/intern/rna_smoke.c
@@ -35,7 +35,6 @@
#include "BKE_modifier.h"
#include "BKE_smoke.h"
-#include "BKE_pointcache.h"
#include "BLI_threads.h"
@@ -67,20 +66,11 @@ static void rna_Smoke_dependency_update(Main *bmain, Scene *scene, PointerRNA *p
DAG_relations_tag_update(bmain);
}
-static void rna_Smoke_resetCache(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
-{
- SmokeDomainSettings *settings = (SmokeDomainSettings *)ptr->data;
- if (settings->smd && settings->smd->domain)
- settings->point_cache[0]->flag |= PTCACHE_OUTDATED;
- DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
-}
-
static void rna_Smoke_reset(Main *bmain, Scene *scene, PointerRNA *ptr)
{
SmokeDomainSettings *settings = (SmokeDomainSettings *)ptr->data;
smokeModifier_reset(settings->smd);
- rna_Smoke_resetCache(bmain, scene, ptr);
rna_Smoke_update(bmain, scene, ptr);
}
@@ -91,9 +81,6 @@ static void rna_Smoke_reset_dependency(Main *bmain, Scene *scene, PointerRNA *pt
smokeModifier_reset(settings->smd);
- if (settings->smd && settings->smd->domain)
- settings->smd->domain->point_cache[0]->flag |= PTCACHE_OUTDATED;
-
rna_Smoke_dependency_update(bmain, scene, ptr);
}
@@ -392,12 +379,6 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
{ 0, NULL, 0, NULL, NULL }
};
- static EnumPropertyItem smoke_cache_comp_items[] = {
- {SM_CACHE_LIGHT, "CACHELIGHT", 0, "Light", "Fast but not so effective compression"},
- {SM_CACHE_HEAVY, "CACHEHEAVY", 0, "Heavy", "Effective but slow compression"},
- {0, NULL, 0, NULL, NULL}
- };
-
static EnumPropertyItem smoke_highres_sampling_items[] = {
{SM_HRES_FULLSAMPLE, "FULLSAMPLE", 0, "Full Sample", ""},
{SM_HRES_LINEAR, "LINEAR", 0, "Linear", ""},
@@ -419,14 +400,6 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
- static EnumPropertyItem cache_file_type_items[] = {
- {PTCACHE_FILE_PTCACHE, "POINTCACHE", 0, "Point Cache", "Blender specific point cache file format"},
-#ifdef WITH_OPENVDB
- {PTCACHE_FILE_OPENVDB, "OPENVDB", 0, "OpenVDB", "OpenVDB file format"},
-#endif
- {0, NULL, 0, NULL, NULL}
- };
-
srna = RNA_def_struct(brna, "SmokeDomainSettings", NULL);
RNA_def_struct_ui_text(srna, "Domain Settings", "Smoke domain settings");
RNA_def_struct_sdna(srna, "SmokeDomainSettings");
@@ -472,7 +445,7 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
RNA_def_property_ui_range(prop, -5.0, 5.0, 0.02, 5);
RNA_def_property_ui_text(prop, "Density",
"How much density affects smoke motion (higher value results in faster rising smoke)");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_update");
prop = RNA_def_property(srna, "beta", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "beta");
@@ -480,7 +453,7 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
RNA_def_property_ui_range(prop, -5.0, 5.0, 0.02, 5);
RNA_def_property_ui_text(prop, "Heat",
"How much heat affects smoke motion (higher value results in faster rising smoke)");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_update");
prop = RNA_def_property(srna, "collision_group", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "coll_group");
@@ -508,34 +481,24 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0, 10.0);
RNA_def_property_ui_range(prop, 0.0, 10.0, 1, 2);
RNA_def_property_ui_text(prop, "Strength", "Strength of noise");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_update");
prop = RNA_def_property(srna, "dissolve_speed", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "diss_speed");
RNA_def_property_range(prop, 1.0, 10000.0);
RNA_def_property_ui_range(prop, 1.0, 10000.0, 1, -1);
RNA_def_property_ui_text(prop, "Dissolve Speed", "Dissolve Speed");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_update");
prop = RNA_def_property(srna, "use_dissolve_smoke", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_DISSOLVE);
RNA_def_property_ui_text(prop, "Dissolve Smoke", "Enable smoke to disappear over time");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_update");
prop = RNA_def_property(srna, "use_dissolve_smoke_log", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_DISSOLVE_LOG);
RNA_def_property_ui_text(prop, "Logarithmic dissolve", "Using 1/x ");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
-
- 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[0]");
- RNA_def_property_ui_text(prop, "Point Cache", "");
-
- prop = RNA_def_property(srna, "point_cache_compress_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "cache_comp");
- RNA_def_property_enum_items(prop, smoke_cache_comp_items);
- RNA_def_property_ui_text(prop, "Cache Compression", "Compression method to be used");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_update");
prop = RNA_def_property(srna, "openvdb_cache_compress_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "openvdb_comp");
@@ -565,21 +528,21 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
prop = RNA_def_property(srna, "highres_sampling", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, smoke_highres_sampling_items);
RNA_def_property_ui_text(prop, "Emitter", "Method for sampling the high resolution flow");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_update");
prop = RNA_def_property(srna, "time_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "time_scale");
RNA_def_property_range(prop, 0.2, 1.5);
RNA_def_property_ui_range(prop, 0.2, 1.5, 0.02, 5);
RNA_def_property_ui_text(prop, "Time Scale", "Adjust simulation speed");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_update");
prop = RNA_def_property(srna, "vorticity", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "vorticity");
RNA_def_property_range(prop, 0.01, 4.0);
RNA_def_property_ui_range(prop, 0.01, 4.0, 0.02, 5);
RNA_def_property_ui_text(prop, "Vorticity", "Amount of turbulence/rotation in fluid");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_update");
prop = RNA_def_property(srna, "density_grid", PROP_FLOAT, PROP_NONE);
RNA_def_property_array(prop, 32);
@@ -639,36 +602,36 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
RNA_def_property_range(prop, 0.01, 4.0);
RNA_def_property_ui_range(prop, 0.01, 2.0, 1.0, 5);
RNA_def_property_ui_text(prop, "Speed", "Speed of the burning reaction (use larger values for smaller flame)");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_update");
prop = RNA_def_property(srna, "flame_smoke", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.0, 8.0);
RNA_def_property_ui_range(prop, 0.0, 4.0, 1.0, 5);
RNA_def_property_ui_text(prop, "Smoke", "Amount of smoke created by burning fuel");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_update");
prop = RNA_def_property(srna, "flame_vorticity", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.0, 2.0);
RNA_def_property_ui_range(prop, 0.0, 1.0, 1.0, 5);
RNA_def_property_ui_text(prop, "Vorticity", "Additional vorticity for the flames");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_update");
prop = RNA_def_property(srna, "flame_ignition", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.5, 5.0);
RNA_def_property_ui_range(prop, 0.5, 2.5, 1.0, 5);
RNA_def_property_ui_text(prop, "Ignition", "Minimum temperature of flames");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_update");
prop = RNA_def_property(srna, "flame_max_temp", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 1.0, 10.0);
RNA_def_property_ui_range(prop, 1.0, 5.0, 1.0, 5);
RNA_def_property_ui_text(prop, "Maximum", "Maximum temperature of flames");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_update");
prop = RNA_def_property(srna, "flame_smoke_color", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Smoke Color", "Color of smoke emitted from burning fuel");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_update");
prop = RNA_def_property(srna, "use_adaptive_domain", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_ADAPTIVE_DOMAIN);
@@ -681,27 +644,21 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
RNA_def_property_range(prop, 0, 512);
RNA_def_property_ui_range(prop, 0, 512, 2, -1);
RNA_def_property_ui_text(prop, "Additional", "Maximum number of additional cells");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_update");
prop = RNA_def_property(srna, "adapt_margin", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "adapt_margin");
RNA_def_property_range(prop, 2, 24);
RNA_def_property_ui_range(prop, 2, 24, 2, -1);
RNA_def_property_ui_text(prop, "Margin", "Margin added around fluid to minimize boundary interference");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_update");
prop = RNA_def_property(srna, "adapt_threshold", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.01, 0.5);
RNA_def_property_ui_range(prop, 0.01, 0.5, 1.0, 5);
RNA_def_property_ui_text(prop, "Threshold",
"Maximum amount of fluid cell can contain before it is considered empty");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
-
- prop = RNA_def_property(srna, "cache_file_format", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "cache_file_format");
- RNA_def_property_enum_items(prop, cache_file_type_items);
- RNA_def_property_ui_text(prop, "File Format", "Select the file format to be used for caching");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_update");
}
static void rna_def_smoke_flow_settings(BlenderRNA *brna)
diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c
index 6cc2f097be8..c2a84bb0ef2 100644
--- a/source/blender/modifiers/intern/MOD_cloth.c
+++ b/source/blender/modifiers/intern/MOD_cloth.c
@@ -37,6 +37,7 @@
#include "DNA_cloth_types.h"
#include "DNA_key_types.h"
#include "DNA_scene_types.h"
+#include "DNA_object_force.h"
#include "DNA_object_types.h"
#include "MEM_guardedalloc.h"
@@ -51,7 +52,6 @@
#include "BKE_key.h"
#include "BKE_library_query.h"
#include "BKE_modifier.h"
-#include "BKE_pointcache.h"
#include "depsgraph_private.h"
@@ -63,10 +63,9 @@ static void initData(ModifierData *md)
clmd->sim_parms = MEM_callocN(sizeof(ClothSimSettings), "cloth sim parms");
clmd->coll_parms = MEM_callocN(sizeof(ClothCollSettings), "cloth coll parms");
- clmd->point_cache = BKE_ptcache_add(&clmd->ptcaches);
/* check for alloc failing */
- if (!clmd->sim_parms || !clmd->coll_parms || !clmd->point_cache)
+ if (!clmd->sim_parms || !clmd->coll_parms)
return;
cloth_init(clmd);
@@ -188,15 +187,10 @@ static void copyData(ModifierData *md, ModifierData *target)
if (tclmd->coll_parms)
MEM_freeN(tclmd->coll_parms);
- BKE_ptcache_free_list(&tclmd->ptcaches);
- tclmd->point_cache = NULL;
-
tclmd->sim_parms = MEM_dupallocN(clmd->sim_parms);
if (clmd->sim_parms->effector_weights)
tclmd->sim_parms->effector_weights = MEM_dupallocN(clmd->sim_parms->effector_weights);
tclmd->coll_parms = MEM_dupallocN(clmd->coll_parms);
- tclmd->point_cache = BKE_ptcache_add(&tclmd->ptcaches);
- tclmd->point_cache->step = 1;
tclmd->clothObject = NULL;
tclmd->hairdata = NULL;
tclmd->solver_result = NULL;
@@ -225,9 +219,6 @@ static void freeData(ModifierData *md)
if (clmd->coll_parms)
MEM_freeN(clmd->coll_parms);
- BKE_ptcache_free_list(&clmd->ptcaches);
- clmd->point_cache = NULL;
-
if (clmd->hairdata)
MEM_freeN(clmd->hairdata);
diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c
index bebfbbe9a80..846e6747c1f 100644
--- a/source/blender/modifiers/intern/MOD_collision.c
+++ b/source/blender/modifiers/intern/MOD_collision.c
@@ -34,6 +34,7 @@
#include "DNA_object_types.h"
#include "DNA_meshdata_types.h"
+#include "DNA_object_force.h"
#include "MEM_guardedalloc.h"
@@ -45,7 +46,6 @@
#include "BKE_cdderivedmesh.h"
#include "BKE_global.h"
#include "BKE_modifier.h"
-#include "BKE_pointcache.h"
#include "BKE_scene.h"
static void initData(ModifierData *md)
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index 93666bd2a48..00aee47b5e6 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -69,7 +69,6 @@
#include "BKE_main.h"
#include "BKE_modifier.h"
#include "BKE_node.h"
-#include "BKE_pointcache.h"
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_sequencer.h"
@@ -3070,21 +3069,6 @@ static void validate_render_settings(Render *re)
}
}
-static void update_physics_cache(Render *re, Scene *scene, int UNUSED(anim_init))
-{
- PTCacheBaker baker;
-
- memset(&baker, 0, sizeof(baker));
- baker.main = re->main;
- baker.scene = scene;
- baker.bake = 0;
- baker.render = 1;
- baker.anim_init = 1;
- baker.quick_step = 1;
-
- BKE_ptcache_bake(&baker);
-}
-
void RE_SetActiveRenderView(Render *re, const char *viewname)
{
BLI_strncpy(re->viewname, viewname, sizeof(re->viewname));
@@ -3097,7 +3081,7 @@ const char *RE_GetActiveRenderView(Render *re)
/* evaluating scene options for general Blender render */
static int render_initialize_from_main(Render *re, RenderData *rd, Main *bmain, Scene *scene, SceneRenderLayer *srl,
- Object *camera_override, unsigned int lay_override, int anim, int anim_init)
+ Object *camera_override, unsigned int lay_override, int anim, int UNUSED(anim_init))
{
int winx, winy;
rcti disprect;
@@ -3141,16 +3125,6 @@ static int render_initialize_from_main(Render *re, RenderData *rd, Main *bmain,
/* check all scenes involved */
tag_scenes_for_render(re);
-
- /*
- * Disabled completely for now,
- * can be later set as render profile option
- * and default for background render.
- */
- if (0) {
- /* make sure dynamics are up to date */
- update_physics_cache(re, scene, anim_init);
- }
if (srl || scene->r.scemode & R_SINGLE_LAYER) {
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c
index 38044622aaa..3b7641ef9ce 100644
--- a/source/blender/render/intern/source/voxeldata.c
+++ b/source/blender/render/intern/source/voxeldata.c
@@ -225,7 +225,7 @@ static int read_voxeldata_header(FILE *fp, struct VoxelData *vd)
return 1;
}
-static void init_frame_smoke(VoxelData *vd, int cfra)
+static void init_frame_smoke(VoxelData *vd, int UNUSED(cfra))
{
#ifdef WITH_SMOKE
Object *ob;
@@ -248,9 +248,7 @@ static void init_frame_smoke(VoxelData *vd, int cfra)
return;
}
- if (cfra < sds->point_cache[0]->startframe)
- ; /* don't show smoke before simulation starts, this could be made an option in the future */
- else if (vd->smoked_type == TEX_VD_SMOKEHEAT) {
+ if (vd->smoked_type == TEX_VD_SMOKEHEAT) {
size_t totRes;
size_t i;
float *heat;