Skip to content

Commit

Permalink
Merge pull request #569 from james-baber/fix-563
Browse files Browse the repository at this point in the history
Send to Unreal 2.3.1
  • Loading branch information
james-baber authored Mar 2, 2023
2 parents 8e58fff + 8f483c3 commit 3329038
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 68 deletions.
4 changes: 0 additions & 4 deletions docs/main/contributing/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ you want to run the unittests on the open app instances.
## Hot reloading from PyCharm
These steps must be completed in-order for the addons to hot-reload while you type in PyCharm.
1. If you have the addons already installed, uninstall them and shutdown Blender and PyCharm.
1. Set a static value for `RPC_AUTH_TOKEN` in your system environment variables and restart Pycharm and Blender.
::: tip Windows
Hit the Windows key then search for `Edit the system environment variables` then add it.
:::
1. You must symlink the addon folders into the blender addon installation location. Then enable the addons
::: tip Windows
Run this from a commandline launched as administrator. Swapping out the last path with your own.
Expand Down
1 change: 0 additions & 1 deletion docs/main/contributing/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,3 @@ specific cases with `EXCLUSIVE_TESTS` can be beneficial.
| `CONTAINER_TEST_FOLDER` | The path in the container where the repo tests folder is mounted | `/tmp/blender_tools/tests` |
| `RPC_TIME_OUT` | When running a Non-Blocking server, the is a timeout value for command execution. If a command has been sent from the client, the server will try to give the client the response up until 20 seconds has passed. Once the response or timeout has been reached, the server will let the event loop of the DCC continue again. | `20` |
| `RPC_EXECUTION_HISTORY_FILE` | Lets you specify a file path to write out the python execution history by the rpc module. This is useful for debugging. | `None` |
| `RPC_AUTH_TOKEN` | Can be used to set a static auth token value for the client and server connection. | `password` |
6 changes: 0 additions & 6 deletions docs/send2ue/extras/addon-preferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ It is not recommended to set the timeout too high. The timeout is a safeguard ag
indefinitely.
:::

### RPC auth token
This is the auth token that the client uses to connect to the RPC server. A default value is generated
automatically when the addon is registered. If you want to use a static auth token, then you can set the
environment variable `RPC_AUTH_TOKEN` on your system. The addon must be uninstalled and both blender and unreal
restarted and the addon re-installed for this change to take effect.

### Extensions Repo Path
Set this path to the folder that contains your Send to Unreal python extensions. All extensions in this folder
will be automatically loaded.
9 changes: 2 additions & 7 deletions docs/send2ue/settings/validations.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ assigned to a vertex on the mesh object. If there is a unused material, then an
### Check texture references
This checks the texture references and sees if they actually exist on disk.

### Check paths:
### Check paths
This checks the export and import paths and makes sure they are valid before preforming
the operation.

Expand All @@ -29,13 +29,8 @@ the operation.

### Check blender object names
This checks whether the blender object names in the Export collection contain any
invalid special characters or white space. While the following special characters `'".,/.:|&!~\n\r\t@#(){}[]=;^%$\*?<>` or ` have
invalid special characters or white space. While the following special characters ```'".,/.:|&!~\n\r\t@#(){}[]=;^%$\`*?<>``` have
valid usage in Blender, they are not valid to use in asset names in Unreal.

Send2UE automatically converts any invalid characters to `_` during the export process
if this validation is turned off.

::: tip Note
Checking the unreal paths makes a few remote calls which requires an open Unreal editor instance with remote
execution enabled. Also, if this is disabled it can shave 1 to 5 seconds off the validation step.
:::
2 changes: 1 addition & 1 deletion send2ue/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
bl_info = {
"name": "Send to Unreal",
"author": "Epic Games Inc.",
"version": (2, 3, 0),
"version": (2, 3, 1),
"blender": (3, 3, 0),
"location": "Header > Pipeline > Send to Unreal",
"description": "Sends an asset to the first open Unreal Editor instance on your machine.",
Expand Down
8 changes: 0 additions & 8 deletions send2ue/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,6 @@ def set_property_group_with_dictionary(property_group, data):
setattr(property_group, attribute, data.get(attribute))


def set_rpc_auth_token(self, value):
"""
Overrides setter method on rpc_auth_token property to update the
environment variable as well.
"""
os.environ['RPC_AUTH_TOKEN'] = value


def set_rpc_response_timeout(self, value):
"""
Overrides setter method on rpc_response_timeout property to update the
Expand Down
8 changes: 6 additions & 2 deletions send2ue/core/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,6 @@ def setup_project(*args):
"""
# set the auth token variable
addon_properties = bpy.context.preferences.addons.get(ToolInfo.NAME.value)
settings.set_rpc_auth_token(None, addon_properties.preferences.rpc_auth_token)

# remove the cached files
remove_temp_folder()
Expand Down Expand Up @@ -1122,8 +1121,13 @@ def report_error(message, details='', raise_exception=True):
:param str message: The error message to display to the user.
:param str details: The error message details to display to the user.
:param bool raise_exception: Whether or not to raise an exception or report the error in the popup.
:param bool raise_exception: Whether to raise an exception or report the error in the popup.
"""
# if a warning is received, then don't raise an error
if message == {'WARNING'}:
print(f'{message} {details}')
return

if os.environ.get('SEND2UE_DEV', raise_exception):
raise RuntimeError(message + details)
else:
Expand Down
11 changes: 7 additions & 4 deletions send2ue/dependencies/rpc/base_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,13 @@ def is_authorized(self):
:returns: Whether the request is authorized.
:rtype: bool
"""
for key, value in self.headers.items():
if key == 'Authorization':
return value and value == os.environ.get('RPC_AUTH_TOKEN', 'password')
return False
# do not allow requests sent cross site
if self.headers.get('Sec-Fetch-Site') == 'cross-site':
return False
# do not allow requests from another origin
if self.headers.get('Origin'):
return False
return True

def report_401(self):
"""
Expand Down
4 changes: 1 addition & 3 deletions send2ue/dependencies/rpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ def __init__(self, *args, **kwargs):
"""
Override so we can redefine the ServerProxy to use our custom transport.
"""
kwargs['transport'] = RPCTransport(headers=[
('Authorization', os.environ.get('RPC_AUTH_TOKEN', 'password'))
])
kwargs['transport'] = RPCTransport()
ServerProxy.__init__(self, *args, **kwargs)


Expand Down
4 changes: 3 additions & 1 deletion send2ue/dependencies/unreal.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ def bootstrap_unreal_with_rpc_server():
"""
if not os.environ.get('TEST_ENVIRONMENT'):
if not is_connected():
import bpy
rpc_response_timeout = bpy.context.preferences.addons["send2ue"].preferences.rpc_response_timeout
dependencies_path = os.path.dirname(__file__)
result = run_commands(
[
Expand All @@ -196,7 +198,7 @@ def bootstrap_unreal_with_rpc_server():
'for thread in threading.enumerate():',
'\tif thread.name =="UnrealRPCServer":',
'\t\tthread.kill()',
f'os.environ["RPC_AUTH_TOKEN"] = "{os.environ["RPC_AUTH_TOKEN"]}"',
f'os.environ["RPC_TIME_OUT"] = "{rpc_response_timeout}"',
f'sys.path.append(r"{dependencies_path}")',
'from rpc import unreal_server',
'rpc_server = unreal_server.RPCServer()',
Expand Down
12 changes: 0 additions & 12 deletions send2ue/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,6 @@ class Send2UeAddonProperties:
set=settings.set_rpc_response_timeout,
get=settings.get_rpc_response_timeout
)
rpc_auth_token: bpy.props.StringProperty(
name="RPC Auth Token",
subtype='PASSWORD',
default=os.environ.get('RPC_AUTH_TOKEN', str(uuid.uuid4().hex)),
description=(
"This is the auth token that the client uses to connect to the RPC server. A default value is generated "
"automatically when the addon is registered. If you want to use a static auth token, then you can set the "
"environment variable 'RPC_AUTH_TOKEN' on your system. The addon must be uninstalled and both blender and "
"unreal restarted and the addon re-installed for this change to take effect"
),
set=settings.set_rpc_auth_token
)
extensions_repo_path: bpy.props.StringProperty(
name="Extensions Repo Path",
default="",
Expand Down
23 changes: 8 additions & 15 deletions send2ue/release_notes.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
## Major Changes
* Send to Unreal is no longer using the blender FBX export operator. Instead, it uses a patched version of the logic in
the `export_fbx_bin` module from Blender's FBX addon. The reasoning for doing this was to fix the scale factor that gets baked into exported FBX files for SkeletalMesh and AnimSequence assets at the FBX level rather than fixing this issue by preforming operations to the blender scene and objects. (This logic was quite complex and still imposed some limitations. Now it can all be removed!). It should be noted that this change is substantial, and while we have done our best to test
this, it could introduce some new bugs that were overlooked. If there are issues with the scale, please report any issues and roll back to version `2.2.1` of the addon in the meantime.
* `Use object origin` is now a core feature. This now uses the FBX export module to set the world location of StaticMesh, SkeletalMesh, and AnimSequence assets. This fixes some common problems that were introduced by moving objects in the blender scene pre-export.
* The `Sync control rig tracks to source rig` option has been added back to the ue2rigify extension. Since the `Automatically scale bones` feature has been removed, it made it easy to add this option back in as an extension.
* [#417](https://github.com/EpicGames/BlenderTools/issues/417)

## Minor Changes
* "Send to Unreal" button in settings dialog was renamed to "Push Assets" to be more accurate since the tool can also
only export to disk if used in that mode.
* `Check scene scale` no longer has an option for 0.01. It now only checks for a scene scale of 1 since this is the only
recommend way to work.
* Fixed various connection and timeout issues by removing the authorization token in favor of checking CORS.
* [563](https://github.com/EpicGames/BlenderTools/issues/563)
* [564](https://github.com/EpicGames/BlenderTools/issues/564)
* [552](https://github.com/EpicGames/BlenderTools/issues/552)
* Fixed issue with FBX exporter failing to export with warnings. Now the exports finish and warnings are printed to the system console.
* [565](https://github.com/EpicGames/BlenderTools/issues/565)

## Deprecated
* The option `Automatically scale bones` has been removed. This was the default option that fixed the scale factor in
SkeletalMesh and AnimSequence assets by scaling the object, scene, and fcurves. This is no longer needed since this is handled in the FBX export now.
* The `Use object origin` extension has been removed since it is now a core feature.
* The `RPC Auth Token` option has been removed from the addon preferences since it can be cumbersome to configure and
was causing issues. Instead, the same security can be provided by checking CORS in the RPC server.

## Tests Passing On
* Blender `3.3`, `3.4`
Expand Down
4 changes: 0 additions & 4 deletions send2ue/ui/addon_preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ def draw(self, context):
row.label(text='RPC Response Timeout')
row.prop(self, 'rpc_response_timeout', text='')
row = self.layout.row()
row.label(text='RPC Auth Token')
row.enabled = False
row.prop(self, 'rpc_auth_token', text='')
row = self.layout.row()
row.label(text='Extensions Repo Path:')
row = self.layout.row()
row = row.split(factor=0.95, align=True)
Expand Down

0 comments on commit 3329038

Please sign in to comment.