[Bf-extensions-cvs] [9152da17] master: Some instantiation 2.8 API update fixing

Maurice Raybaud noreply at git.blender.org
Wed Aug 21 08:39:24 CEST 2019


Commit: 9152da178b89a8e7cbcca870acd63cfa8857935e
Author: Maurice Raybaud
Date:   Wed Aug 21 08:38:27 2019 +0200
Branches: master
https://developer.blender.org/rBA9152da178b89a8e7cbcca870acd63cfa8857935e

Some instantiation 2.8 API update fixing

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

M	render_povray/render.py

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

diff --git a/render_povray/render.py b/render_povray/render.py
index 62cd2426..828141ce 100644
--- a/render_povray/render.py
+++ b/render_povray/render.py
@@ -2064,1159 +2064,1163 @@ def write_pov(filename, scene=None, info_callback=None):
 
         ob_num = 0
         for ob in sel:
-            ob_num += 1
-
-            # XXX I moved all those checks here, as there is no need to compute names
-            #     for object we won't export here!
-            if (ob.type in {'LIGHT', 'CAMERA', #'EMPTY', #empties can bear dupligroups
-                            'META', 'ARMATURE', 'LATTICE'}):
-                continue
-            smokeFlag=False
-            for mod in ob.modifiers:
-                if mod and hasattr(mod, 'smoke_type'):
-                    smokeFlag=True
-                    if (mod.smoke_type == 'DOMAIN'):
-                        exportSmoke(ob.name)
-                    break # don't render domain mesh or flow emitter mesh, skip to next object.
-            if not smokeFlag:
-                # Export Hair
-                renderEmitter = True
-                if hasattr(ob, 'particle_systems'):
-                    renderEmitter = False
-                    for pSys in ob.particle_systems:
-                        if pSys.settings.use_render_emitter:
-                            renderEmitter = True
-                        for mod in [m for m in ob.modifiers if (m is not None) and (m.type == 'PARTICLE_SYSTEM')]:
-                            if (pSys.settings.render_type == 'PATH') and mod.show_render and (pSys.name == mod.particle_system.name):
-                                tstart = time.time()
-                                texturedHair=0
-                                if ob.material_slots[pSys.settings.material - 1].material and ob.active_material is not None:
-                                    pmaterial = ob.material_slots[pSys.settings.material - 1].material
-                                    for th in pmaterial.texture_slots:
-                                        if th and th.use:
-                                            if (th.texture.type == 'IMAGE' and th.texture.image) or th.texture.type != 'IMAGE':
-                                                if th.use_map_color_diffuse:
-                                                    texturedHair=1
-                                    if pmaterial.strand.use_blender_units:
-                                        strandStart = pmaterial.strand.root_size
-                                        strandEnd = pmaterial.strand.tip_size
-                                        strandShape = pmaterial.strand.shape
-                                    else:  # Blender unit conversion
-                                        strandStart = pmaterial.strand.root_size / 200.0
-                                        strandEnd = pmaterial.strand.tip_size / 200.0
-                                        strandShape = pmaterial.strand.shape
-                                else:
-                                    pmaterial = "default"  # No material assigned in blender, use default one
-                                    strandStart = 0.01
-                                    strandEnd = 0.01
-                                    strandShape = 0.0
-                                # Set the number of particles to render count rather than 3d view display
-                                pSys.set_resolution(scene, ob, 'RENDER')
-                                steps = pSys.settings.display_step
-                                steps = 3 ** steps # or (power of 2 rather than 3) + 1 # Formerly : len(particle.hair_keys)
-
-                                totalNumberOfHairs = ( len(pSys.particles) + len(pSys.child_particles) )
-                                #hairCounter = 0
-                                file.write('#declare HairArray = array[%i] {\n' % totalNumberOfHairs)
-                                for pindex in range(0, totalNumberOfHairs):
-
-                                    #if particle.is_exist and particle.is_visible:
-                                        #hairCounter += 1
-                                        #controlPointCounter = 0
-                                        # Each hair is represented as a separate sphere_sweep in POV-Ray.
-
-                                        file.write('sphere_sweep{')
-                                        if pSys.settings.use_hair_bspline:
-                                            file.write('b_spline ')
-                                            file.write('%i,\n' % (steps + 2))  # +2 because the first point needs tripling to be more than a handle in POV
-                                        else:
-                                            file.write('linear_spline ')
-                                            file.write('%i,\n' % (steps))
-                                        #changing world coordinates to object local coordinates by multiplying with inverted matrix
-                                        initCo = ob.matrix_world.inverted()*(pSys.co_hair(ob, pindex, 0))
-                                        if ob.material_slots[pSys.settings.material - 1].material and ob.active_material is not None:
-                                            pmaterial = ob.material_slots[pSys.settings.material-1].material
-                                            for th in pmaterial.texture_slots:
-                                                if th and th.use and th.use_map_color_diffuse:
-                                                    #treat POV textures as bitmaps
-                                                    if (th.texture.type == 'IMAGE' and th.texture.image and th.texture_coords == 'UV' and ob.data.uv_textures is not None): # or (th.texture.pov.tex_pattern_type != 'emulator' and th.texture_coords == 'UV' and ob.data.uv_textures is not None):
-                                                        image=th.texture.image
-                                                        image_width = image.size[0]
-                                                        image_height = image.size[1]
-                                                        image_pixels = image.pixels[:]
-                                                        uv_co = pSys.uv_on_emitter(mod, pSys.particles[pindex], pindex, 0)
-                                                        x_co = round(uv_co[0] * (image_width - 1))
-                                                        y_co = round(uv_co[1] * (image_height - 1))
-                                                        pixelnumber = (image_width * y_co) + x_co
-                                                        r = image_pixels[pixelnumber*4]
-                                                        g = image_pixels[pixelnumber*4+1]
-                                                        b = image_pixels[pixelnumber*4+2]
-                                                        a = image_pixels[pixelnumber*4+3]
-                                                        initColor=(r,g,b,a)
-                                                    else:
-                                                        #only overwrite variable for each competing texture for now
-                                                        initColor=th.texture.evaluate((initCo[0],initCo[1],initCo[2]))
-                                        for step in range(0, steps):
-                                            co = ob.matrix_world.inverted()*(pSys.co_hair(ob, pindex, step))
-                                        #for controlPoint in particle.hair_keys:
-                                            if pSys.settings.clump_factor != 0:
-                                                hDiameter = pSys.settings.clump_factor / 200.0 * random.uniform(0.5, 1)
-                                            elif step == 0:
-                                                hDiameter = strandStart
+            #subtract original from the count of their instances as were not counted before 2.8 
+            if not (ob.is_instancer and ob.original != ob):
+                ob_num += 1
+
+                # XXX I moved all those checks here, as there is no need to compute names
+                #     for object we won't export here!
+                if (ob.type in {'LIGHT', 'CAMERA', #'EMPTY', #empties can bear dupligroups
+                                'META', 'ARMATURE', 'LATTICE'}):
+                    continue
+                smokeFlag=False
+                for mod in ob.modifiers:
+                    if mod and hasattr(mod, 'smoke_type'):
+                        smokeFlag=True
+                        if (mod.smoke_type == 'DOMAIN'):
+                            exportSmoke(ob.name)
+                        break # don't render domain mesh or flow emitter mesh, skip to next object.
+                if not smokeFlag:
+                    # Export Hair
+                    renderEmitter = True
+                    if hasattr(ob, 'particle_systems'):
+                        renderEmitter = False
+                        for pSys in ob.particle_systems:
+                            if pSys.settings.use_render_emitter:
+                                renderEmitter = True
+                            for mod in [m for m in ob.modifiers if (m is not None) and (m.type == 'PARTICLE_SYSTEM')]:
+                                if (pSys.settings.render_type == 'PATH') and mod.show_render and (pSys.name == mod.particle_system.name):
+                                    tstart = time.time()
+                                    texturedHair=0
+                                    if ob.material_slots[pSys.settings.material - 1].material and ob.active_material is not None:
+                                        pmaterial = ob.material_slots[pSys.settings.material - 1].material
+                                        for th in pmaterial.texture_slots:
+                                            if th and th.use:
+                                                if (th.texture.type == 'IMAGE' and th.texture.image) or th.texture.type != 'IMAGE':
+                                 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list