Skip to content

Commit 86c905a

Browse files
authored
temporary workaround for issue with 4.4.3 visibility channel import (#272)
* temporary workaround for issue with 4.4.3 visibility channel import * print a warning if visibility channel is available in animation import on 4.4.3
1 parent f3e223f commit 86c905a

6 files changed

Lines changed: 67 additions & 30 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ jobs:
2929
- blender-version: '4.2'
3030
blender-version-suffix: '0'
3131
python-version: '3.11.7'
32+
- blender-version: '4.4'
33+
blender-version-suffix: '3'
34+
python-version: '3.11.7'
3235

3336
steps:
3437
- uses: actions/checkout@v3

CHANGELOG.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
11
# Version History
22

33
## v0.7.2 (28.09.24)
4+
45
* adapt to API changes in Blender 4.2+
56

67
## v0.7.1 (29.01.24)
7-
* adapt to API changes in Blender 4.0+
88

9+
* adapt to API changes in Blender 4.0+
910

1011
## v0.7.0 (09.09.23)
12+
1113
* delete base sphere object and mesh after hierarchy import
1214
* fix face distance calculation to match 3DS max exporter
1315
* multi-texture / multi-material support by @nkx111 thx!
1416

1517
## v0.6.9 (06.04.23)
18+
1619
* fixed export of materials with normal maps
1720

1821
## v0.6.8 (29.12.21)
22+
1923
* fixed issues with api changes in blender 3.0
2024
* export texture names always with '.tga' extension
2125

2226
## v0.6.7 (22.10.21)
27+
2328
* added auto updater
2429
* adaptions for python 3.9 used in blender 2.93 and later
2530
* Bugfix: pivot and vertex groups are compared all lowercase
2631

2732
## v0.6.6 (24.7.21)
33+
2834
* display valid vertex color layer names if layer name is invalid
2935
* display actual bone weights if they do not add up to 100%
3036
* inform user on animation import that armature might have been hidden due to visibility channels
@@ -34,13 +40,15 @@
3440
* Bugfix: do not crash if mesh has more shader structs than vertex materials
3541

3642
## v0.6.5 (26.3.21)
43+
3744
* cancel export if a mesh and a bone share the same name and mesh is not configured properly
3845
* inform user if both vertex bone weights do not add up to 100%
3946
* Bugfix: handling of specular and emission color
4047
* Bugfix: use proper file extension for loaded textures
4148
* Bugfix: split vertices with n uv-coords into n vertices
4249

4350
## v0.6.4 (23.2.21)
51+
4452
* support mesh property 'two sided'
4553
* cancel export if vertices are not rigged to any bone
4654
* cancel export if vertices are rigged to more than 2 bones
@@ -51,13 +59,16 @@
5159
* Bugfix: normalize quaternions on animation export
5260

5361
## v0.6.3 (17.1.20)
62+
5463
* geometry data can now be exported to xml and ini
5564

5665
## v0.6.2 (01.12.20)
66+
5767
* support for floats in xml files with ',' and '.'
5868
* support more collision box properties (type, collision_type)
5969

6070
## v0.6.0 (28.7.20)
71+
6172
* export dummy shade indices (they are needed for the mod SDK (at least for W3X))
6273
* support for mesh sorting levels
6374
* only display appropriate custom object properties
@@ -72,6 +83,7 @@
7283
* Bugfix: set hierarchy name always uppercase
7384

7485
## v0.5.0 (10.06.20)
86+
7587
* use proper enums for vertex material shader properties
7688
* create pivots for meshes on export if they have no parent bone
7789
* create a bone for each hierarchy pivot on import (otherwise pivot order can not be maintained on roundtrip)
@@ -84,9 +96,11 @@
8496
* Bugfix: use proper hierarchy name for animation and hlod on export
8597

8698
## v0.4.7 (26.04.20)
99+
87100
* Bugfix: fixed installation issue
88101

89102
## v0.4.6 (24.04.20)
103+
90104
* apply modifiers to meshes on export
91105
* handle export of 'multi-user' meshes
92106
* default material type is now 'VERTEX_MATERIAL'
@@ -95,6 +109,7 @@
95109
* Bugfix: check for referenced armature case insensitive
96110

97111
## v0.4.5 (11.03.20)
112+
98113
* split vertices with multiple uv coordinates on export
99114
* use actual mesh normals on import
100115
* export tangents and bitangents
@@ -105,34 +120,41 @@
105120
* Bugfix: proper bool string export
106121

107122
## v0.4.4 (19.02.20)
123+
108124
* limit decimal digits in w3x files to 6
109125
* Bugfix: use armature name as hierarchy ID
110126
* Bugfix: create includes on export
111127

112128
## v0.4.3 (13.02.20)
129+
113130
* create only required keyframes on animation import
114131
* support more texture file formats
115132
* Bugfix: bone visibility channels
116133
* Bugfix: do not crash on missing float vector entries
117134

118135
## v0.4.2 (04.02.20)
136+
119137
* switched to ElementTree for xml stuff
120138
* Bugfix: write boolean values as lower in w3x
121139
* Bugfix: loading of animations without include for corresponding hierarchy
122140

123141
## v0.4.1 (01.02.20)
142+
124143
* support splitted w3x files
125144
* support w3x single mesh imports
126145
* Bugfix: do not crash on missing attributes
127146

128147
## v0.4.0 (31.01.20)
148+
129149
* support for w3x files
130150

131151
## v0.3.0 (05.01.20)
152+
132153
* support multiple levels of detail in HLod chunks
133154
* Bugfix: fix rigging issues with C&C Generals and C&C Renegade models
134155

135156
## v0.2.1 (13.11.19)
157+
136158
* support for basic uncompressd and timecoded animation export
137159
* added multiple custom properties in order to reduce data loss on roundtrips
138160
* Bugfix: exported files now work in W3DViewer 6.0 and the recent revora version

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
![Sample](/art/AotR_Umbar_Buildings.jpg)
99

1010
**OpenSAGE.BlenderPlugin**: a free, open source blender plugin for the [Westwood](https://de.wikipedia.org/wiki/Westwood_Studios) 3D
11-
format used in Command & Conquer™: Generals and other RTS titles from Westwood Studios and EA Pacific.
11+
format used in Command & Conquer™: Generals and other RTS titles from Westwood Studios and EA Pacific.
1212

1313
## Installing and activating
1414

io_mesh_w3d/common/utils/animation_import.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,51 +56,54 @@ def set_rotation(bone, frame, value):
5656
bone.keyframe_insert(data_path='rotation_quaternion', frame=frame)
5757

5858

59-
def set_visibility(bone, frame, value):
59+
def set_visibility(context, bone, frame, value):
6060
if isinstance(bone, bpy.types.Bone):
61-
bone.visibility = value
62-
bone.keyframe_insert(data_path='visibility', frame=frame, options=creation_options)
61+
if bpy.app.version != (4, 4, 3): #TODO fix 4.4.3
62+
bone.visibility = value
63+
bone.keyframe_insert(data_path='visibility', frame=frame, options=creation_options)
64+
else:
65+
context.warning(f'bone visibility channels are currently not supported for blender 4.4.3!')
6366
else:
6467
bone.hide_viewport = bool(value)
6568
bone.keyframe_insert(data_path='hide_viewport', frame=frame, options=creation_options)
6669

6770

68-
def set_keyframe(bone, channel, frame, value):
71+
def set_keyframe(context, bone, channel, frame, value):
6972
if is_visibility(channel):
70-
set_visibility(bone, frame, value)
73+
set_visibility(context, bone, frame, value)
7174
elif is_translation(channel):
7275
set_translation(bone, channel.type, frame, value)
7376
else:
7477
set_rotation(bone, frame, value)
7578

7679

77-
def apply_timecoded(bone, channel):
80+
def apply_timecoded(context, bone, channel):
7881
for key in channel.time_codes:
79-
set_keyframe(bone, channel, key.time_code, key.value)
82+
set_keyframe(context, bone, channel, key.time_code, key.value)
8083

8184

82-
def apply_motion_channel_time_coded(bone, channel):
85+
def apply_motion_channel_time_coded(context, bone, channel):
8386
for datum in channel.data:
84-
set_keyframe(bone, channel, datum.time_code, datum.value)
87+
set_keyframe(context, bone, channel, datum.time_code, datum.value)
8588

8689

87-
def apply_motion_channel_adaptive_delta(bone, channel):
90+
def apply_motion_channel_adaptive_delta(context, bone, channel):
8891
data = decode(channel.type, channel.vector_len, channel.num_time_codes, channel.data.scale, channel.data.data)
8992
for i in range(channel.num_time_codes):
90-
set_keyframe(bone, channel, i, data[i])
93+
set_keyframe(context, bone, channel, i, data[i])
9194

9295

93-
def apply_adaptive_delta(bone, channel):
96+
def apply_adaptive_delta(context, bone, channel):
9497
data = decode(channel.type, channel.vector_len, channel.num_time_codes, channel.scale, channel.data)
9598
for i in range(channel.num_time_codes):
96-
set_keyframe(bone, channel, i, data[i])
99+
set_keyframe(context, bone, channel, i, data[i])
97100

98101

99-
def apply_uncompressed(bone, channel):
102+
def apply_uncompressed(context, bone, channel):
100103
for index in range(channel.last_frame - channel.first_frame + 1):
101104
data = channel.data[index]
102105
frame = index + channel.first_frame
103-
set_keyframe(bone, channel, frame, data)
106+
set_keyframe(context, bone, channel, frame, data)
104107

105108

106109
def process_channels(context, hierarchy, channels, rig, apply_func):
@@ -109,7 +112,7 @@ def process_channels(context, hierarchy, channels, rig, apply_func):
109112
if obj is None:
110113
continue
111114

112-
apply_func(obj, channel)
115+
apply_func(context, obj, channel)
113116

114117

115118
def process_motion_channels(context, hierarchy, channels, rig):
@@ -119,9 +122,9 @@ def process_motion_channels(context, hierarchy, channels, rig):
119122
continue
120123

121124
if channel.delta_type == 0:
122-
apply_motion_channel_time_coded(obj, channel)
125+
apply_motion_channel_time_coded(context, obj, channel)
123126
else:
124-
apply_motion_channel_adaptive_delta(obj, channel)
127+
apply_motion_channel_adaptive_delta(context, obj, channel)
125128

126129

127130
def create_animation(context, rig, animation, hierarchy):

tests/common/cases/structs/test_animation.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# <pep8 compliant>
22
# Written by Stephan Vedder and Michael Schnabel
33

4-
import io
4+
import io, bpy
55
from tests.common.helpers.animation import *
66
from tests.utils import TestCase
77
from unittest.mock import patch, call
@@ -12,8 +12,12 @@ def test_write_read(self):
1212
expected = get_animation()
1313

1414
self.assertEqual(52, expected.header.size())
15-
self.assertEqual(683, expected.size(False))
16-
self.assertEqual(691, expected.size())
15+
if bpy.app.version == (4, 4, 3):
16+
self.assertEqual(645, expected.size(False))
17+
self.assertEqual(653, expected.size())
18+
else:
19+
self.assertEqual(683, expected.size(False))
20+
self.assertEqual(691, expected.size())
1721

1822
self.write_read_test(expected, W3D_CHUNK_ANIMATION, Animation.read, compare_animations, self, True)
1923

tests/common/helpers/animation.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# <pep8 compliant>
22
# Written by Stephan Vedder and Michael Schnabel
3-
3+
import bpy
44
from io_mesh_w3d.common.structs.animation import *
55
from tests.mathutils import *
66
from tests.w3d.helpers.version import *
@@ -99,9 +99,8 @@ def compare_animation_bit_channels(self, expected, actual):
9999

100100

101101
def get_animation(hierarchy_name='TestHierarchy', xml=False):
102-
return Animation(
103-
header=get_animation_header(hierarchy_name),
104-
channels=[get_animation_channel(type=0, pivot=0),
102+
channels = [
103+
get_animation_channel(type=0, pivot=0),
105104
get_animation_channel(type=1, pivot=1),
106105
get_animation_channel(type=2, pivot=1),
107106

@@ -114,9 +113,15 @@ def get_animation(hierarchy_name='TestHierarchy', xml=False):
114113
get_animation_channel(type=1, pivot=3),
115114
get_animation_channel(type=2, pivot=3),
116115
get_animation_channel(type=6, pivot=3),
117-
118-
get_animation_bit_channel(pivot=6, xml=xml),
119-
get_animation_bit_channel(pivot=7)])
116+
]
117+
118+
if bpy.app.version != (4, 4, 3): #TODO fix 4.4.3
119+
channels.append(get_animation_bit_channel(pivot=6, xml=xml))
120+
channels.append(get_animation_bit_channel(pivot=7))
121+
122+
return Animation(
123+
header=get_animation_header(hierarchy_name),
124+
channels=channels)
120125

121126

122127
def get_animation_minimal():

0 commit comments

Comments
 (0)