Skip to content

Commit

Permalink
Merge branch 'Dev' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
xavier150 committed Jan 23, 2024
2 parents c1a3b33 + 2bf29f2 commit e98a990
Show file tree
Hide file tree
Showing 77 changed files with 4,426 additions and 2,085 deletions.
3 changes: 2 additions & 1 deletion Release log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,12 @@ It is now possible to force the duration of an animation according to the scene
- New: Alembic animation support multiple unit scales and global scale.
- New: Selection filter "Only selected" and "Only selected and active action" now filter only visible objects.
- New: Modular export (Export several skeletal meshs with the same skeleton)
- New: You can enable skeletal mesh per poly collision.
- Fixed: Blender 3.5 may crash during NLA Export. (Interacting with an NlaStripFCurves not linked to an object could lead to a crash in Blender 3.5.)
- Fixed: Applying skeletal export scale with Proxy and Unit Scale not set to 0.01 could result in a script error.
- Fixed: Using "Convert Attribute to UV" can swap UV Indices in the exported mesh.
- Fixed: The "Export Procedure" option is visible with static meshes.
- Fixed: Hidden objects and collections are unhidden after export when using the same name.
- Fixed: Skeletons imported with skeletal meshes use incorrect names.
- Fixed: Collection.exclude is not recovery after export when using multi view layers.
- Fixed: Camera import script don't work in Unreal Engine 5.3
- Fixed: Camera import script doesn’t work in Unreal Engine 5.3
479 changes: 479 additions & 0 deletions blender-for-unrealengine/Release log.txt

Large diffs are not rendered by default.

27 changes: 19 additions & 8 deletions blender-for-unrealengine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@
from . import bps
from . import bbpl
from . import bfu_propertys
from . import bfu_camera
from . import bfu_collision
from . import bfu_addon_parts
from . import bfu_ui_utils
from . import bfu_export_procedure
from . import bfu_addon_pref
from . import bfu_export_logs
from . import bfu_ui
from . import bfu_check_potential_error
from . import bfu_write_text
from . import bfu_write_utils
from . import bfu_write_import_asset_script
from . import bfu_write_import_sequencer_script
from . import bfu_basics
Expand All @@ -58,10 +61,14 @@
importlib.reload(bbpl)
if "bfu_propertys" in locals():
importlib.reload(bfu_propertys)
if "bfu_camera" in locals():
importlib.reload(bfu_camera)
if "bfu_collision" in locals():
importlib.reload(bfu_collision)
if "bfu_addon_parts" in locals():
importlib.reload(bfu_addon_parts)
if "bfu_ui_utils" in locals():
importlib.reload(bfu_ui_utils)
if "bfu_export_procedure" in locals():
importlib.reload(bfu_export_procedure)
if "bfu_addon_pref" in locals():
importlib.reload(bfu_addon_pref)
if "bfu_export_logs" in locals():
Expand All @@ -72,6 +79,8 @@
importlib.reload(bfu_check_potential_error)
if "bfu_write_text" in locals():
importlib.reload(bfu_write_text)
if "bfu_write_utils" in locals():
importlib.reload(bfu_write_utils)
if "bfu_write_import_asset_script" in locals():
importlib.reload(bfu_write_import_asset_script)
if "bfu_write_import_sequencer_script" in locals():
Expand All @@ -96,7 +105,7 @@
'blender': (2, 80, 0),
'location': 'View3D > UI > Unreal Engine',
'description': "This add-ons allows to easily export several "
"objects at the same time for use in unreal engine 4.",
"objects at the same time for use in Unreal Engine.",
'warning': '',
"wiki_url": "https://github.com/xavier150/Blender-For-UnrealEngine-Addons/wiki",
'tracker_url': 'https://github.com/xavier150/Blender-For-UnrealEngine-Addons/issues',
Expand All @@ -114,16 +123,16 @@ class BFUCachedAction(bpy.types.PropertyGroup):
classes = (
)



def register():
for cls in classes:
bpy.utils.register_class(cls)

bbpl.register()
bfu_propertys.register()
bfu_camera.register()
bfu_collision.register()
bfu_addon_parts.register()
bfu_ui_utils.register()
bfu_export_procedure.register()
bfu_addon_pref.register()
bfu_export_logs.register()
bfu_ui.register()
Expand All @@ -141,7 +150,9 @@ def unregister():
bfu_ui.unregister()
bfu_export_logs.unregister()
bfu_addon_pref.unregister()
bfu_ui_utils.unregister()
bfu_export_procedure.unregister()
bfu_addon_parts.unregister()
bfu_camera.unregister()
bfu_collision.unregister()
bfu_propertys.unregister()
bbpl.unregister()
19 changes: 15 additions & 4 deletions blender-for-unrealengine/bbpl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
import bpy
import importlib


from . import blender_layout
from . import backward_compatibility
from . import blender_rig
from . import blender_addon
from . import basics
from . import utils
from . import rig_utils
from . import rig_bone_visual
from . import skin_utils
from . import anim_utils
Expand All @@ -38,12 +39,16 @@

if "blender_layout" in locals():
importlib.reload(blender_layout)
if "backward_compatibility" in locals():
importlib.reload(backward_compatibility)
if "blender_rig" in locals():
importlib.reload(blender_rig)
if "blender_addon" in locals():
importlib.reload(blender_addon)
if "basics" in locals():
importlib.reload(basics)
if "utils" in locals():
importlib.reload(utils)
if "rig_utils" in locals():
importlib.reload(rig_utils)
if "rig_bone_visual" in locals():
importlib.reload(rig_bone_visual)
if "skin_utils" in locals():
Expand All @@ -66,10 +71,16 @@ def register():
bpy.utils.register_class(cls)

blender_layout.register()
backward_compatibility.register()
blender_rig.register()
blender_addon.register()


def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)

blender_addon.unregister()
blender_rig.unregister()
backward_compatibility.unregister()
blender_layout.unregister()
165 changes: 162 additions & 3 deletions blender-for-unrealengine/bbpl/anim_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import bpy
import mathutils
from . import scene_utils
from . import utils


class NLA_Save:
Expand Down Expand Up @@ -181,7 +182,7 @@ def paste_data_on(self, nla_strip: bpy.types.NlaStrip):
nla_strip.extrapolation = self.extrapolation
for fcurve in self.fcurves:
new_fcurve = nla_strip.fcurves.find(fcurve.data_path) # Can't create so use find
fcurve.PasteDataOn(new_fcurve)
fcurve.paste_data_on(new_fcurve)
nla_strip.frame_end = self.frame_end
if bpy.app.version >= (3, 3, 0):
nla_strip.frame_end_ui = self.frame_end_ui
Expand Down Expand Up @@ -220,7 +221,6 @@ def __init__(self, fcurve: bpy.types.FCurve):
def paste_data_on(self, fcurve: bpy.types.FCurve):
pass


class AnimationManagment():
"""
Helper class for managing animation data in Blender.
Expand Down Expand Up @@ -308,4 +308,163 @@ def reset_armature_pose(obj):
b.rotation_quaternion = mathutils.Quaternion()
b.rotation_euler = mathutils.Vector((0, 0, 0))
b.scale = mathutils.Vector((1, 1, 1))
b.location = mathutils.Vector((0, 0, 0))
b.location = mathutils.Vector((0, 0, 0))


class ProxyCopy_Constraint:
"""
Proxy class for copying Blender PoseBoneConstraints.
It is used to safely copy Blender PoseBoneConstraints.
"""

def __init__(self, constraint):
"""
Initializes the ProxyCopy_Constraint object.
Args:
constraint (bpy.types.Constraint): The constraint to copy.
Returns:
None
"""
if constraint:
self.type = constraint.type
self.name = constraint.name
self.target = constraint.target
self.subtarget = constraint.subtarget
self.influence = constraint.influence
self.mute = constraint.mute
self.target_space = constraint.target_space
self.owner_space = constraint.owner_space
# Add more constraint parameters here as needed

if self.type == 'CHILD_OF':
self.inverse_matrix = constraint.inverse_matrix.copy()


def paste_data_on(self, target_constraint):
"""
Pastes the saved data onto the target constraint.
Args:
target_constraint (bpy.types.Constraint): The target constraint to apply the data to.
Returns:
None
"""
if target_constraint:
#target_constraint.type = self.type
target_constraint.name = self.name
target_constraint.target = self.target
target_constraint.subtarget = self.subtarget
target_constraint.influence = self.influence
target_constraint.mute = self.mute
target_constraint.target_space = self.target_space
target_constraint.owner_space = self.owner_space
# Copy more constraint parameters here as needed

if self.type == 'CHILD_OF':
target_constraint.inverse_matrix = self.inverse_matrix


class BoneConstraintManagment():
"""
Helper class for managing Bone Constraint data in Blender.
"""

def __init__(self):
self.saved_constraints = []

def save_bone_constraints_data(self, armature, bone_name):
"""
Saves the constraints data from an armature bone.
Args:
armature: The armature object where the bone is located.
bone_name: The name of the bone you want to save constraints for.
"""
# Get the bone object from the armature
bone = armature.pose.bones.get(bone_name)

if bone:
# Clear the saved_constraints list to start fresh
self.saved_constraints.clear()

# Get the list of constraints on the bone and save them
for constraint in bone.constraints:
self.saved_constraints.append(ProxyCopy_Constraint(constraint))

#print(f"Constraints for bone {bone_name} saved successfully.")
else:
print(f"Bone {bone_name} not found in the armature.")


def set_bone_constraints_data(self, armature, bone_name, replace=True):
"""
Sets the constraints data on the bone of an armature.
Args:
armature: The armature object where the bone is located.
bone_name: The name of the bone on which you want to set constraints.
replace: If True, replace existing constraints; if False, keep them and add saved constraints.
"""
# Get the bone object from the armature
bone = armature.pose.bones.get(bone_name)

if bone:
if replace:
# Remove all existing constraints on the bone
for old_constraint in bone.constraints:
bone.constraints.remove(old_constraint)

# Add the saved constraints to the bone
for constraint_data in self.saved_constraints:
new_constraint = bone.constraints.new(type=constraint_data.type)
constraint_data.paste_data_on(new_constraint)

print(f"Constraints for bone {bone_name} set successfully.")
else:
print(f"Bone {bone_name} not found in the armature.")

class RigConstraintManagment():
"""
Helper class for managing Rig Constraint data in Blender.
"""

def __init__(self):
self.saved_bones_constraints = {}

def save_rig_constraints_data(self, armature, bone_names):
"""
Saves the constraints data from an armature bone.
Args:
armature: The armature object where the bone is located.
bone_names: The names of the bones you want to save constraints for.
"""
self.saved_bones_constraints.clear()

for bone_name in bone_names:
bone = armature.pose.bones.get(bone_name)
constraints = BoneConstraintManagment()
constraints.save_bone_constraints_data(armature, bone_name)

if bone:
self.saved_bones_constraints[bone_name] = constraints

#print(f"Constraints for bone {bone_name} saved successfully.")
else:
print(f"Bone {bone_name} not found in the armature.")


def set_rig_constraints_data(self, armature, replace=True):
"""
Sets the constraints data on the bones of an armature.
Args:
armature: The armature object where the bones are located.
replace: If True, replace existing constraints; if False, keep them and add saved constraints.
"""
for bone_name, constraints in self.saved_bones_constraints.items():
constraints.set_bone_constraints_data(armature, bone_name, replace)
Loading

0 comments on commit e98a990

Please sign in to comment.