diff --git a/ModelImporter/import_scene.py b/ModelImporter/import_scene.py index 290d705..416b275 100644 --- a/ModelImporter/import_scene.py +++ b/ModelImporter/import_scene.py @@ -569,7 +569,7 @@ def _add_empty_to_scene(self, scene_node: SceneNodeData, j = 3 - empty_obj.NMSReference_props.num_lods for _ in range(j): lods.append(0) - empty_obj.NMSReference_props.lod_levels = lods + empty_obj.NMSReference_props.lod_levels = lods[:3] empty_obj.NMSReference_props.has_lods = True # Add a custom property so that if it is exported with the diff --git a/NMS/classes/Object.py b/NMS/classes/Object.py index d6ee98c..6fd677a 100644 --- a/NMS/classes/Object.py +++ b/NMS/classes/Object.py @@ -3,7 +3,6 @@ # as child objects. from typing import Optional -from zlib import crc32 from .TkSceneNodeData import TkSceneNodeData from .TkSceneNodeAttributeData import TkSceneNodeAttributeData @@ -16,6 +15,19 @@ TYPES = ['MESH', 'LOCATOR', 'COLLISION', 'MODEL', 'REFERENCE'] +def jenkins_one_at_a_time(data: str) -> int: + # https://en.wikipedia.org/wiki/Jenkins_hash_function#one_at_a_time + hash = 0 + for char in data.upper(): + hash = (hash + ord(char)) & 0xFFFFFFFF + hash = (hash + (hash << 10)) & 0xFFFFFFFF + hash = (hash ^ (hash >> 6)) & 0xFFFFFFFF + hash = (hash + (hash << 3)) & 0xFFFFFFFF + hash = (hash ^ (hash >> 11)) & 0xFFFFFFFF + hash = (hash + (hash << 15)) & 0xFFFFFFFF + return hash + + class Object(): """ Structure: TkSceneNodeData: @@ -219,9 +231,7 @@ def NameHash(self) -> int: orig_name_hash = self.orig_node_data.get('NameHash', None) if orig_name_hash: return orig_name_hash - byte_name = bytes(self.Name, encoding='utf-8') - # do bit operation to ensure it's always unsigned - return crc32(byte_name) & 0xFFFFFFFF + return jenkins_one_at_a_time(self.Name) class Locator(Object): diff --git a/__init__.py b/__init__.py index 85ce3f1..51cc741 100644 --- a/__init__.py +++ b/__init__.py @@ -1,7 +1,7 @@ bl_info = { "name": "No Man's Sky Development Kit", "author": "gregkwaste, monkeyman192", - "version": (0, 9, 25), + "version": (0, 9, "26a"), "blender": (4, 0, 0), "location": "File > Export/Import", "description": "Create NMS scene structures and export to NMS File format",