[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2810] trunk/py/scripts/addons/ netrender: netrender

Martin Poirier theeth at yahoo.com
Mon Dec 26 19:45:05 CET 2011


Revision: 2810
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2810
Author:   theeth
Date:     2011-12-26 18:44:56 +0000 (Mon, 26 Dec 2011)
Log Message:
-----------
netrender
- Support for dynamic painting point cache (patch by Philippe Van Hecke)
- Fix job log name generation to not exceed filename limits when using large chunks
- Cleaning up duplicated code for point caches, fluid and multires between client and repath module

Modified Paths:
--------------
    trunk/py/scripts/addons/netrender/client.py
    trunk/py/scripts/addons/netrender/master.py
    trunk/py/scripts/addons/netrender/repath.py
    trunk/py/scripts/addons/netrender/utils.py

Modified: trunk/py/scripts/addons/netrender/client.py
===================================================================
--- trunk/py/scripts/addons/netrender/client.py	2011-12-26 17:20:44 UTC (rev 2809)
+++ trunk/py/scripts/addons/netrender/client.py	2011-12-26 18:44:56 UTC (rev 2810)
@@ -218,26 +218,18 @@
     # FLUID + POINT CACHE
     ###########################
     default_path = cachePath(filename)
+    
+    def pointCacheFunc(object, point_cache):
+        addPointCache(job, object, point_cache, default_path)
+        
+    def fluidFunc(object, modifier, cache_path):
+        addFluidFiles(job, cache_path)
+        
+    def multiresFunc(object, modifier, cache_path):
+        job.addFile(cache_path)
+        
+    processObjectDependencies(pointCacheFunc, fluidFunc, multiresFunc)
 
-    for object in bpy.data.objects:
-        for modifier in object.modifiers:
-            if modifier.type == 'FLUID_SIMULATION' and modifier.settings.type == "DOMAIN":
-                addFluidFiles(job, bpy.path.abspath(modifier.settings.filepath))
-            elif modifier.type == "CLOTH":
-                addPointCache(job, object, modifier.point_cache, default_path)
-            elif modifier.type == "SOFT_BODY":
-                addPointCache(job, object, modifier.point_cache, default_path)
-            elif modifier.type == "SMOKE" and modifier.smoke_type == "DOMAIN":
-                addPointCache(job, object, modifier.domain_settings.point_cache, default_path)
-            elif modifier.type == "MULTIRES" and modifier.is_external:
-                file_path = bpy.path.abspath(modifier.filepath)
-                job.addFile(file_path)
-
-        # particles modifier are stupid and don't contain data
-        # we have to go through the object property
-        for psys in object.particle_systems:
-            addPointCache(job, object, psys.point_cache, default_path)
-
     #print(job.files)
 
     fillCommonJobSettings(job, job_name, netsettings)

Modified: trunk/py/scripts/addons/netrender/master.py
===================================================================
--- trunk/py/scripts/addons/netrender/master.py	2011-12-26 17:20:44 UTC (rev 2809)
+++ trunk/py/scripts/addons/netrender/master.py	2011-12-26 18:44:56 UTC (rev 2810)
@@ -154,7 +154,8 @@
         self.status = JOB_QUEUED
 
     def addLog(self, frames):
-        log_name = "_".join(("%06d" % f for f in frames)) + ".log"
+        frames = sorted(frames)
+        log_name = "%06d_%06d.log" % (frames[0], frames[-1])
         log_path = os.path.join(self.save_path, log_name)
 
         for number in frames:

Modified: trunk/py/scripts/addons/netrender/repath.py
===================================================================
--- trunk/py/scripts/addons/netrender/repath.py	2011-12-26 17:20:44 UTC (rev 2809)
+++ trunk/py/scripts/addons/netrender/repath.py	2011-12-26 18:44:56 UTC (rev 2810)
@@ -64,22 +64,6 @@
         os.renames(new_path, job_full_path)
 
 def process(paths):
-    def processPointCache(ob, point_cache):
-        if not point_cache.use_disk_cache:
-            return
-
-        cache_name = cacheName(ob, point_cache)
-        new_path = path_map.get(cache_name, None)
-        if new_path:
-            point_cache.use_external = True
-            point_cache.filepath = new_path
-            point_cache.name = cache_name
-
-    def processFluid(fluid):
-        new_path = path_map.get(fluid.filepath, None)
-        if new_path:
-            fluid.path = new_path
-    
     path_map = {}
     for i in range(0, len(paths), 2):
         # special case for point cache
@@ -119,28 +103,29 @@
     ###########################
     # FLUID + POINT CACHE
     ###########################
-    for object in bpy.data.objects:
-        for modifier in object.modifiers:
-            if modifier.type == 'FLUID_SIMULATION' and modifier.settings.type == "DOMAIN":
-                processFluid(object, modifier.settings)
-            elif modifier.type == "CLOTH":
-                processPointCache(object, modifier.point_cache)
-            elif modifier.type == "SOFT_BODY":
-                processPointCache(object, modifier.point_cache)
-            elif modifier.type == "SMOKE" and modifier.smoke_type == "DOMAIN":
-                processPointCache(modifier.domain_settings.point_cache_low)
-                if modifier.domain_settings.use_high_resolution:
-                    processPointCache(modifier.domain_settings.point_cache_high)
-            elif modifier.type == "MULTIRES" and modifier.is_external:
-                file_path = bpy.path.abspath(modifier.filepath)
-                new_path = path_map.get(file_path, None)
-                if new_path:
-                    modifier.filepath = new_path
+    def pointCacheFunc(object, point_cache):
+        if not point_cache.use_disk_cache:
+            return
 
-        # particles modifier are stupid and don't contain data
-        # we have to go through the object property
-        for psys in object.particle_systems:
-            processPointCache(psys.point_cache)
+        cache_name = cacheName(object, point_cache)
+        new_path = path_map.get(cache_name, None)
+        if new_path:
+            point_cache.use_external = True
+            point_cache.filepath = new_path
+            point_cache.name = cache_name
+        
+    def fluidFunc(object, modifier, cache_path):
+        fluid = modifier.settings
+        new_path = path_map.get(cache_path, None)
+        if new_path:
+            fluid.path = new_path
+        
+    def multiresFunc(object, modifier, cache_path):
+        new_path = path_map.get(cache_path, None)
+        if new_path:
+            modifier.filepath = new_path
+        
+    processObjectDependencies(pointCacheFunc, fluidFunc, multiresFunc)
                 
 
 if __name__ == "__main__":

Modified: trunk/py/scripts/addons/netrender/utils.py
===================================================================
--- trunk/py/scripts/addons/netrender/utils.py	2011-12-26 17:20:44 UTC (rev 2809)
+++ trunk/py/scripts/addons/netrender/utils.py	2011-12-26 18:44:56 UTC (rev 2810)
@@ -243,6 +243,33 @@
     root, ext = os.path.splitext(name)
     return path + os.sep + "blendcache_" + root # need an API call for that
 
+# Process dependencies of all objects with user defined functions
+#    pointCacheFunction(object, point_cache)
+#    fluidFunction(object, modifier, cache_path)
+#    multiresFunction(object, modifier, cache_path)
+def processObjectDependencies(pointCacheFunction, fluidFunction, multiresFunction):
+    for object in bpy.data.objects:
+        for modifier in object.modifiers:
+            if modifier.type == 'FLUID_SIMULATION' and modifier.settings.type == "DOMAIN":
+                fluidFunction(object, modifier, bpy.path.abspath(modifier.settings.filepath))
+            elif modifier.type == "CLOTH":
+                pointCacheFunction(object, modifier.point_cache)
+            elif modifier.type == "SOFT_BODY":
+                pointCacheFunction(object, modifier.point_cache)
+            elif modifier.type == "SMOKE" and modifier.smoke_type == "DOMAIN":
+                pointCacheFunction(object, modifier.domain_settings.point_cache)
+            elif modifier.type == "MULTIRES" and modifier.is_external:
+                multiresFunction(object, modifier, bpy.path.abspath(modifier.filepath))
+            elif modifier.type == "DYNAMIC_PAINT" and modifier.canvas_settings:
+                for surface in modifier.canvas_settings.canvas_surfaces:
+                    pointCacheFunction(object, surface.point_cache)
+    
+        # particles modifier are stupid and don't contain data
+        # we have to go through the object property
+        for psys in object.particle_systems:
+            pointCacheFunction(object, psys.point_cache)
+    
+
 def prefixPath(prefix_directory, file_path, prefix_path, force = False):
     if (os.path.isabs(file_path) or
         len(file_path) >= 3 and (file_path[1:3] == ":/" or file_path[1:3] == ":\\") or # Windows absolute path don't count as absolute on unix, have to handle them myself



More information about the Bf-extensions-cvs mailing list