aboutsummaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
author Nemrav <>2024-09-16 21:22:49 +0200
committer Nemrav <>2024-09-16 21:22:49 +0200
commit0c301c66a028c2e006c0e26378d83db113d19310 (patch)
treef9c33d70827260310e5fb05aa870255f52e2d553 /game
parentdc0b0ede2368b43ab6c91a5e24d76ec34e91cf46 (diff)
fix unit culling and arab helmet
Diffstat (limited to 'game')
-rw-r--r--game/src/Game/Model/XACLoader.gd13
-rw-r--r--game/src/Game/Model/XSMLoader.gd10
2 files changed, 17 insertions, 6 deletions
diff --git a/game/src/Game/Model/XACLoader.gd b/game/src/Game/Model/XACLoader.gd
index b003296..6b12cf2 100644
--- a/game/src/Game/Model/XACLoader.gd
+++ b/game/src/Game/Model/XACLoader.gd
@@ -2,6 +2,7 @@ class_name XACLoader
static var unit_shader : ShaderMaterial = preload("res://src/Game/Model/unit_colours_mat.tres")
const MAX_UNIT_TEXTURES : int = 32 # max number of textures supported by the shader
+const EXTRA_CULL_MARGIN : int = 2 # extra margin to stop sub-meshes from being culled near the edges of screens
static var added_unit_textures_spec : PackedStringArray
static var added_unit_textures_diffuse : PackedStringArray
@@ -141,6 +142,13 @@ static func _load_xac_model(source_file : String, is_unit : bool) -> Node3D:
push_warning("Skipping unused mesh \"", mesh_chunk_name, "\" in model \"", node.name, "\"")
continue
+ # polySurface97 corresponds to the "arab_infantry_helmet", and needs to be removed often
+ # but only in cases where it isn't an attachment
+ const INVALID_IF_NOT_ONLY_MESH : PackedStringArray = ["polySurface97"]
+ if mesh_chunks.size() != 1 and mesh_chunk_name in INVALID_IF_NOT_ONLY_MESH:
+ push_warning("Skipping unused mesh \"", mesh_chunk_name, "\" in model \"", node.name, "\" because it was not the only mesh chunk in its file")
+ break
+
var mesh : ArrayMesh = null
var verts : PackedVector3Array
var normals : PackedVector3Array
@@ -164,6 +172,8 @@ static func _load_xac_model(source_file : String, is_unit : bool) -> Node3D:
_: # type 4 32bit colours and type 6 128bit colours aren't used
pass
+ #FIXME: find a better solution if possible
+ #pCube1 hardcoding is to fix the cruiser which doesn't properly mark its collision mesh
if chunk.bIsCollisionMesh or mesh_chunk_name == "pCube1":
var ar3d : Area3D = Area3D.new()
node.add_child(ar3d)
@@ -193,6 +203,9 @@ static func _load_xac_model(source_file : String, is_unit : bool) -> Node3D:
var meshInstance : MeshInstance3D = MeshInstance3D.new()
node.add_child(meshInstance)
meshInstance.owner = node
+
+ #stop the culling of units near the tops of screens
+ meshInstance.extra_cull_margin = EXTRA_CULL_MARGIN
if mesh_chunk_name:
meshInstance.name = mesh_chunk_name
diff --git a/game/src/Game/Model/XSMLoader.gd b/game/src/Game/Model/XSMLoader.gd
index 332bbec..bc85f9b 100644
--- a/game/src/Game/Model/XSMLoader.gd
+++ b/game/src/Game/Model/XSMLoader.gd
@@ -46,7 +46,8 @@ static func _load_xsm_animation(source_file : String) -> Animation:
0xC9: #Metadata
metadataChunk = readMetadataChunk(file)
0xCA: #Bone Animation
- boneAnimationChunks.push_back(readBoneAnimationChunk(file, metadataChunk.use_quat_16()))
+ # v1 is float32 quaternions, v2 is int16 quaternions
+ boneAnimationChunks.push_back(readBoneAnimationChunk(file, version == 2))
_:
push_error(">> INVALID XSM CHUNK TYPE %X" % type)
break
@@ -155,11 +156,8 @@ class MetadataChunk:
func debugPrint() -> void:
print("FileName: %s, sourceApp: %s, exportDate: %s, ExporterV:%d.%d" %
[origFileName, sourceApp, exportDate, exporterMajorVersion, exporterMinorVersion])
- print("MotionName: %s, fps: %d, MaxError: %s, Use 16-bit int Quaternions?:%s" %
- [motionName, fps, fMaxAcceptableError, use_quat_16()])
-
- func use_quat_16() -> bool:
- return pad == 0x0
+ print("MotionName: %s, fps: %d, MaxError: %s" %
+ [motionName, fps, fMaxAcceptableError])
static func readPosKey(file : FileAccess) -> PosKey:
return PosKey.new(FileAccessUtils.read_pos(file), file.get_float())