Skip to content

Commit

Permalink
feat: update PyBMap dependency.
Browse files Browse the repository at this point in the history
- update PyBMap dependency.
- use BMap 0.2 instead of old one.
- change default encoding name string according to the change of LibCmo changes.
  • Loading branch information
yyc12345 committed Sep 21, 2024
1 parent f5c50ae commit c8d59ef
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
12 changes: 8 additions & 4 deletions bbp_ng/PyBMap/bmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,13 @@ class bm_VxMatrix(ctypes.Structure):
else:
_g_BMapLibName = "BMap.bin"

_g_BMapLibPath: str = os.path.join(os.path.dirname(__file__), _g_BMapLibName)

_g_BMapModule: ctypes.CDLL | None = None
try:
_g_BMapModule = ctypes.cdll.LoadLibrary(
os.path.join(os.path.dirname(__file__), _g_BMapLibName)
)
_g_BMapModule = ctypes.cdll.LoadLibrary(_g_BMapLibPath)
except:
print(f'Fail to load native BMap dynamic library file "{_g_BMapLibPath}".')
_g_BMapModule = None

def is_bmap_available() -> bool:
Expand All @@ -107,6 +108,8 @@ def _create_bmap_func(fct_name: str, fct_params: list[typing.Any]) -> typing.Cal

#region Function Defines

##### GENERATED FUNCTIONS BEGIN #####

## BMInit
# @return True if no error, otherwise False.
BMInit = _create_bmap_func('BMInit', [])
Expand Down Expand Up @@ -781,5 +784,6 @@ def _create_bmap_func(fct_name: str, fct_params: list[typing.Any]) -> typing.Cal
# @return True if no error, otherwise False.
BM3dObject_SetVisibility = _create_bmap_func('BM3dObject_SetVisibility', [bm_void_p, bm_CKID, bm_bool])

#endregion
##### GENERATED FUNCTIONS END #####

#endregion
12 changes: 6 additions & 6 deletions bbp_ng/UTIL_ioport_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,28 +128,28 @@ class ImportParams():
items = _g_EnumHelper_ConflictStrategy.generate_items(),
description = "Define how to process texture name conflict",
default = _g_EnumHelper_ConflictStrategy.to_selection(ConflictStrategy.Current),
)
) # type: ignore

material_conflict_strategy: bpy.props.EnumProperty(
name = "Material Name Conflict",
items = _g_EnumHelper_ConflictStrategy.generate_items(),
description = "Define how to process material name conflict",
default = _g_EnumHelper_ConflictStrategy.to_selection(ConflictStrategy.Rename),
)
) # type: ignore

mesh_conflict_strategy: bpy.props.EnumProperty(
name = "Mesh Name Conflict",
items = _g_EnumHelper_ConflictStrategy.generate_items(),
description = "Define how to process mesh name conflict",
default = _g_EnumHelper_ConflictStrategy.to_selection(ConflictStrategy.Rename),
)
) # type: ignore

object_conflict_strategy: bpy.props.EnumProperty(
name = "Object Name Conflict",
items = _g_EnumHelper_ConflictStrategy.generate_items(),
description = "Define how to process object name conflict",
default = _g_EnumHelper_ConflictStrategy.to_selection(ConflictStrategy.Rename),
)
) # type: ignore

def draw_import_params(self, layout: bpy.types.UILayout) -> None:
layout.label(text = 'Object Name Conflict')
Expand Down Expand Up @@ -188,7 +188,7 @@ class ExportParams():
('COLLECTION', "Collection", "Export a collection", 'OUTLINER_COLLECTION', 0),
('OBJECT', "Object", "Export an object", 'OBJECT_DATA', 1),
),
)
) # type: ignore

def draw_export_params(self, layout: bpy.types.UILayout) -> None:
# make prop expand horizontaly, not vertical.
Expand Down Expand Up @@ -221,7 +221,7 @@ class VirtoolsParams():
name = "Encodings",
description = "The encoding list used by Virtools engine to resolve object name. Use `;` to split multiple encodings",
default = UTIL_virtools_types.g_PyBMapDefaultEncoding
)
) # type: ignore

def draw_virtools_params(self, layout: bpy.types.UILayout) -> None:
layout.label(text = 'Encodings')
Expand Down
11 changes: 4 additions & 7 deletions bbp_ng/UTIL_virtools_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,9 @@ def virtools_name_regulator(name: str | None) -> str:

## Default Encoding for PyBMap
# Use semicolon split each encodings. Support Western European and Simplified Chinese in default.
g_PyBMapDefaultEncoding: str
if sys.platform.startswith('win32') or sys.platform.startswith('cygwin'):
# See: https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers
g_PyBMapDefaultEncoding = "1252;936"
else:
# See: https://www.gnu.org/software/libiconv/
g_PyBMapDefaultEncoding = "CP1252;CP936"
# Since LibCmo 0.2, the encoding name of LibCmo become universal encoding which is platfoorm independent.
# So no need set it according to different platform.
# Use universal encoding name (like Python).
g_PyBMapDefaultEncoding: str = 'cp1252;gb2312'

#endregion

0 comments on commit c8d59ef

Please sign in to comment.