Fix: Add Mesh Extra Objects: dual tetrahedron is sometimes flipped #105127

Merged
Damien Picard merged 2 commits from pioverfour/blender-addons:dp_fix_solids into main 2024-01-16 22:04:16 +01:00
7 changed files with 22 additions and 10 deletions
Showing only changes of commit dd44ad13ec - Show all commits

View File

@ -13,7 +13,7 @@
bl_info = {
"name": "Extra Objects",
"author": "Multiple Authors",
"version": (0, 3, 9),
"version": (0, 3, 10),
"blender": (2, 80, 0),
"location": "View3D > Add > Mesh",
"description": "Add extra mesh object types",

View File

@ -51,6 +51,11 @@ def vSum(list):
return reduce(lambda a, b: a + b, list)
# Get a copy of the input faces, but with the normals flipped by reversing the order of the vertex indices of each face.
def flippedFaceNormals(faces):
return [list(reversed(vertexIndices)) for vertexIndices in faces]
# creates the 5 platonic solids as a base for the rest
# plato: should be one of {"4","6","8","12","20"}. decides what solid the
# outcome will be.
@ -146,7 +151,8 @@ def createSolid(plato, vtrunc, etrunc, dual, snub):
vInput, fInput = source(dualSource[plato])
supposedSize = vSum(vInput[i] for i in fInput[0]).length / len(fInput[0])
vInput = [-i * supposedSize for i in vInput] # mirror it
return vInput, fInput
# Inverting vInput turns the mesh inside-out, so normals need to be flipped.
return vInput, flippedFaceNormals(fInput)
return source(plato)
elif 0 < vtrunc <= 0.5: # simple truncation of the source
vInput, fInput = source(plato)
@ -159,7 +165,8 @@ def createSolid(plato, vtrunc, etrunc, dual, snub):
if dual:
vInput, fInput = source(plato)
vInput = [-i * supposedSize for i in vInput]
return vInput, fInput
# Inverting vInput turns the mesh inside-out, so normals need to be flipped.
return vInput, flippedFaceNormals(fInput)
# generate connection database
vDict = [{} for i in vInput]
@ -267,6 +274,10 @@ def createSolid(plato, vtrunc, etrunc, dual, snub):
if supposedSize and not dual: # this to make the vtrunc > 1 work
supposedSize *= len(fvOutput[0]) / vSum(vOutput[i] for i in fvOutput[0]).length
vOutput = [-i * supposedSize for i in vOutput]
# Inverting vOutput turns the mesh inside-out, so normals need to be flipped.
flipNormals = True
else:
flipNormals = False
# create new faces by replacing old vert IDs by newly generated verts
ffOutput = [[] for i in fInput]
@ -285,7 +296,10 @@ def createSolid(plato, vtrunc, etrunc, dual, snub):
ffOutput[x].append(fvOutput[i][vData[i][3].index(x) - 1])
if not dual:
return vOutput, fvOutput + feOutput + ffOutput
fOutput = fvOutput + feOutput + ffOutput
if flipNormals:
fOutput = flippedFaceNormals(fOutput)
return vOutput, fOutput
else:
# do the same procedure as above, only now on the generated mesh
# generate connection database

View File

@ -55,8 +55,6 @@ class AutoKeying:
options.add('INSERTKEY_VISUAL')
if prefs.edit.use_keyframe_insert_needed:
options.add('INSERTKEY_NEEDED')
if prefs.edit.use_insertkey_xyz_to_rgb:
options.add('INSERTKEY_XYZ_TO_RGB')
if ts.use_keyframe_cycle_aware:
options.add('INSERTKEY_CYCLE_AWARE')
return options

View File

@ -5,7 +5,7 @@
bl_info = {
"name": "FBX format",
"author": "Campbell Barton, Bastien Montagne, Jens Restemeier, @Mysteryem",
"version": (5, 11, 4),
"version": (5, 11, 5),
"blender": (4, 1, 0),
"location": "File > Import-Export",
"description": "FBX IO meshes, UVs, vertex colors, materials, textures, cameras, lamps and actions",

View File

@ -686,7 +686,7 @@ def fbx_data_camera_elements(root, cam_obj, scene_data):
elem_props_template_set(tmpl, props, "p_double", b"SafeAreaAspectRatio", aspect)
# Depth of field and Focus distance.
elem_props_template_set(tmpl, props, "p_bool", b"UseDepthOfField", cam_data.dof.use_dof)
elem_props_template_set(tmpl, props, "p_double", b"FocusDistance", cam_data.dof.focus_distance * 1000 * gscale)
elem_props_template_set(tmpl, props, "p_double", b"FocusDistance", cam_data.dof.focus_distance * gscale)
# Default to perspective camera.
elem_props_template_set(tmpl, props, "p_enum", b"CameraProjectionType", 1 if cam_data.type == 'ORTHO' else 0)
elem_props_template_set(tmpl, props, "p_double", b"OrthoZoom", cam_data.ortho_scale)

View File

@ -2169,7 +2169,7 @@ def blen_read_camera(fbx_tmpl, fbx_obj, settings):
camera.type = 'ORTHO' if elem_props_get_enum(fbx_props, b'CameraProjectionType', 0) == 1 else 'PERSP'
camera.dof.focus_distance = elem_props_get_number(fbx_props, b'FocusDistance', 10 * 1000) / 1000 * global_scale
camera.dof.focus_distance = elem_props_get_number(fbx_props, b'FocusDistance', 10) * global_scale
if (elem_props_get_bool(fbx_props, b'UseDepthOfField', False)):
camera.dof.use_dof = True

View File

@ -77,7 +77,7 @@ class PT_VDMBaker(bpy.types.Panel):
It also has settings for name (image, texture and brush at once), resolution, compression and color depth.
"""
bl_label = 'VDM Brush Baker'
bl_idname = 'Editor_PT_LayoutPanel'
bl_idname = 'VDM_PT_bake_tools'
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = 'Tool'