[Bf-extensions-cvs] [98003acc] master: Fix io_mesh_atomic: decreasing the stick diameter revealed the stick mesh

Clemens Barth noreply at git.blender.org
Tue Jan 25 13:18:00 CET 2022


Commit: 98003acc981d34661b387cb06541d0a55c8a5288
Author: Clemens Barth
Date:   Tue Jan 25 13:14:31 2022 +0100
Branches: master
https://developer.blender.org/rBA98003acc981d34661b387cb06541d0a55c8a5288

Fix io_mesh_atomic: decreasing the stick diameter revealed the stick mesh

Reason: the planes used for the instancing vertice structure were
visible at once because their size was as large as the stick diameter.

I decreased the size of those planes by a factor of 100, everything is
fine now

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

M	io_mesh_atomic/pdb_import.py

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

diff --git a/io_mesh_atomic/pdb_import.py b/io_mesh_atomic/pdb_import.py
index 635c3c09..11bdb972 100644
--- a/io_mesh_atomic/pdb_import.py
+++ b/io_mesh_atomic/pdb_import.py
@@ -542,7 +542,7 @@ def build_stick(radius, length, sectors, element_name):
     # Attention: the linking will be done a few moments later, after this
     # is done definition.
 
-    return (new_cylinder, new_cups)
+    return new_cylinder, new_cups
 
 
 # Rotate an object.
@@ -864,7 +864,8 @@ def draw_sticks_dupliverts(all_atoms,
         faces    = []
         i = 0
 
-        # What follows is school mathematics! :-)
+        # What follows is school mathematics! :-) We construct equidistant
+        # planes, on which the stcik sections (cylinders) are perpendicular on.
         for stick in stick_list:
 
             dv = stick[2]
@@ -881,11 +882,15 @@ def draw_sticks_dupliverts(all_atoms,
 
             for j in range(loops):
 
+                # The plane, which is normal to the length of the cylinder,
+                # will have a 1/100 of the stick diameter. => When decreasing
+                # the size of the stick diameter, the plane will not be visible.
+                f = 0.01
                 g  = v1 - n * dl / 2.0 - n * dl * j
-                p1 = g + n_b * Stick_diameter
-                p2 = g - n_b * Stick_diameter
-                p3 = g - n_b.cross(n) * Stick_diameter
-                p4 = g + n_b.cross(n) * Stick_diameter
+                p1 = g + n_b * Stick_diameter * f
+                p2 = g - n_b * Stick_diameter * f
+                p3 = g - n_b.cross(n) * Stick_diameter * f
+                p4 = g + n_b.cross(n) * Stick_diameter * f
 
                 vertices.append(p1)
                 vertices.append(p2)
@@ -914,19 +919,17 @@ def draw_sticks_dupliverts(all_atoms,
         # Link active object to the new collection
         coll.objects.link(new_mesh)
 
-        # Build the object.
-        # Get the cylinder from the 'build_stick' function.
-        object_stick = build_stick(Stick_diameter,
-                                   dl,
-                                   Stick_sectors,
-                                   stick[0][1:])
-        # Link active object to the new collection
-        coll.objects.link(object_stick[0])
-        coll.objects.link(object_stick[1])
+        # Build the object. Get the cylinder from the 'build_stick' function.
+        stick_cylinder, stick_cups = build_stick(Stick_diameter,
+                                                 dl,
+                                                 Stick_sectors,
+                                                 stick[0][1:])
+        # Link active object to the new collection.
+        coll.objects.link(stick_cylinder)
+        coll.objects.link(stick_cups)
 
-        stick_cylinder = object_stick[0]
+        # Assign the material.
         stick_cylinder.active_material = stick[3]
-        stick_cups = object_stick[1]
         stick_cups.active_material = stick[3]
 
         # Smooth the cylinders.



More information about the Bf-extensions-cvs mailing list