Skip to content

Commit

Permalink
UAS v2.1 Finally Finished !
Browse files Browse the repository at this point in the history
  • Loading branch information
Aspirata committed Oct 24, 2024
1 parent 7c7e1f7 commit 26d73c5
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 32 deletions.
Binary file modified MiBlend.blend
Binary file not shown.
9 changes: 4 additions & 5 deletions MiBlend_Source/Assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ def run_python_script(name, path):
properties = {key.replace('_property', ''): value for key, value in asset.items() if 'property' in key}

with open(path, 'r') as file:
context = {**globals(), 'properties': properties}
exec(file.read(), context)
exec(file.read(), globals(), {'properties': properties})
except:
Absolute_Solver("009", name, traceback.print_exc())

Expand Down Expand Up @@ -189,10 +188,10 @@ def update_assets():
asset_author = asset_data.get("Author")
asset_tags = asset_data.get("Tags", [])

if asset_tags[0] != "Script":
asset_file_path = os.path.join(root, os.path.basename(convert_to_linux(asset_data.get("File_path", ""))) + ".blend")
else:
if asset_tags[0] == "Script":
asset_file_path = os.path.join(root, os.path.basename(convert_to_linux(asset_data.get("File_path", ""))) + ".py")
else:
asset_file_path = os.path.join(root, os.path.basename(convert_to_linux(asset_data.get("File_path", ""))) + ".blend")

if format_version != "test" or (bpy.context.preferences.addons[__package__].preferences.dev_tools and bpy.context.preferences.addons[__package__].preferences.uas_debug_mode):
if not asset_name:
Expand Down
24 changes: 24 additions & 0 deletions MiBlend_Source/Assets/Scripts/Beveler/Beveler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,36 @@

for selected_object in bpy.context.selected_objects:
if use_node:
bevel_node = None
PBSDF = None
if not selected_object.material_slots:
continue

for material in selected_object.data.materials:
if material is None or not material.use_nodes:
continue

for node in material.node_tree.nodes:
if node.type == "BEVEL":
bevel_node = node
elif node.type == "BSDF_PRINCIPLED":
PBSDF = node

if bevel_node == None:
bevel_node = material.node_tree.nodes.new(type='ShaderNodeBevel')
bevel_node.location = (PBSDF.location.x - 180, PBSDF.location.y - 132)

bevel_node.samples = segments
bevel_node.inputs[0].default_value = amount

try:
if GetConnectedSocketTo("Normal", PBSDF).node != bevel_node:
material.node_tree.links.new(GetConnectedSocketTo("Normal", PBSDF), bevel_node.inputs["Normal"])
except:
pass

material.node_tree.links.new(bevel_node.outputs[0], PBSDF.inputs["Normal"])

else:
if selected_object.modifiers.get("Bevel") == None:
bevel_modifier = selected_object.modifiers.new('Bevel', type='BEVEL')
Expand Down
26 changes: 5 additions & 21 deletions MiBlend_Source/Assets/Scripts/Contact Shadows/Contact Shadows.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,11 @@
import bpy
import os
import json

addon_dir = os.path.dirname(os.path.abspath(__file__))
only_selected_objects = properties.get("Only Selected Objects", False)
distance = properties.get("Distance", 0.2)
bias = properties.get("Bias", 0.03)
thickness = properties.get("Thickness", 0.01)

current_index = bpy.context.scene.assetsproperties.asset_index
items = bpy.context.scene.assetsproperties.asset_items

current_asset = items[current_index]

json_file_path = current_asset.get("File_path", "") + ".json"

with open(json_file_path, 'r') as json_file:
asset_data = json.load(json_file)

properties = {key.replace('_property', ''): value for key, value in current_asset.items() if 'property' in key.lower()}

mode = properties.get("Mode", asset_data["Mode_property"])
distance = properties.get("Distance", asset_data["Distance_property"])
bias = properties.get("Bias", asset_data["Bias_property"])
thickness = properties.get("Thickness", asset_data["Thickness_property"])

if mode == 0:
if only_selected_objects:
for obj in bpy.context.selected_objects:
try:
obj.data.use_contact_shadow = True
Expand Down
4 changes: 2 additions & 2 deletions MiBlend_Source/MIB_API.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def convert_hex_to_rgba(hex_code, alpha=1.0):
a = alpha
return (r, g, b, a)

def clamp(min, value, max):
return max(min(value, 100.0), 0.0)
def clamp(min_value, value, max_value):
return max(min_value, min(value, max_value))

def convert_to_linux(path):
if sys.platform.startswith('linux'):
Expand Down
8 changes: 4 additions & 4 deletions MiBlend_Source/Operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,8 @@ def execute(self, context):

properties = {key: value for key, value in current_asset.items() if '_property' in key}

blend_file_path = current_asset.get("File_path", "")
json_file_path = blend_file_path.replace(".blend", ".json")
file_path = current_asset.get("File_path", "")
json_file_path = file_path.replace(os.path.splitext(file_path)[-1], ".json")

if not os.path.isfile(json_file_path):
self.report({'ERROR'}, f"File not found: {json_file_path}")
Expand Down Expand Up @@ -439,8 +439,8 @@ def execute(self, context):

properties = {key: value for key, value in current_asset.items() if 'property' in key.lower()}

blend_file_path = current_asset.get("File_path", "")
json_file_path = blend_file_path.replace(".blend", ".json")
file_path = current_asset.get("File_path", "")
json_file_path = file_path.replace(os.path.splitext(file_path)[-1], ".json")

if not os.path.isfile(json_file_path):
self.report({'ERROR'}, f"File not found: {json_file_path}")
Expand Down
5 changes: 5 additions & 0 deletions MiBlend_Source/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ def InitOnStart():
else:
mib_options["is_replaced_materials"] = False

mib_options["components_vesion"] = {
"MiBlend": "Beehive",
"UAS": "v2.1",
}

update_assets()

if bpy.context.preferences.addons[__package__].preferences.dev_tools and bpy.context.preferences.addons[__package__].preferences.open_console_on_start and not sys.platform.startswith('linux'):
Expand Down

0 comments on commit 26d73c5

Please sign in to comment.