Skip to content

Commit

Permalink
Fixed: Blender 4.1 support
Browse files Browse the repository at this point in the history
  • Loading branch information
AlwarrenSidh committed Mar 26, 2024
1 parent 1cc827f commit 86694ba
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
19 changes: 14 additions & 5 deletions ArmaToolbox/MDLImporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ def makeLodName(fileName, lodLevel):
return lodName

def maybeAddEdgeSplit(obj):
obj.data.use_auto_smooth = True
obj.data.auto_smooth_angle = 3.1415927
if (4,1,0) > bpy.app.version:
obj.data.use_auto_smooth = True
obj.data.auto_smooth_angle = 3.1415927
else:
pass


#modifier = obj.modifiers.get("FHQ_ARMA_Toolbox_EdgeSplit")
#if modifier is None:
Expand Down Expand Up @@ -369,7 +373,7 @@ def loadLOD(context, filePtr, objectName, materialData, layerFlag, lodnr):
n1 = readULong(filePtr)
n2 = readULong(filePtr)
sharpEdges.append([n1, n2])
print ("sharp edges", sharpEdges)
# print ("sharp edges", sharpEdges)
elif tagName == "#Property#":
# Read named property
propName = struct.unpack("64s", filePtr.read(64))[0].decode("utf-8")
Expand All @@ -396,14 +400,19 @@ def loadLOD(context, filePtr, objectName, materialData, layerFlag, lodnr):
index += 1
elif tagName == "#Mass#":
weightArray = []
weight = 0;
weight = 0
for idx in range (0,numPoints):
f = readFloat(filePtr)
weightArray.append(f)
weight += f
elif tagName[0] == '#':
elif tagName.__len__() > 0 and tagName[0] == '#':
print("Unkown/Unsued tagg " + tagName)
print("Skipping " , numBytes , " bytes in file")
# System tag we don't read
filePtr.seek(numBytes, 1)
elif tagName.__len__() == 0:
print ("Unnamed tagg????")
filePtr.seek(numBytes, 1)
else:
# Named Selection
# Add a vertex group
Expand Down
3 changes: 2 additions & 1 deletion ArmaToolbox/MDLexporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ def OLDwriteNormals(filePtr, mesh, numberOfNormals):
# FaceNormals must be inverted (-X, -Y, -Z) for clockwise vertex order (default for DirectX), and not changed for counterclockwise order.
def writeNormals(filePtr, mesh, numberOfNormals):
print("faces = ", len(mesh.polygons))
mesh.calc_normals_split()
if (4,1,0) > bpy.app.version:
mesh.calc_normals_split()
for poly in mesh.polygons:
#print("index = ", poly.index)
loops = poly.loop_indices
Expand Down
1 change: 1 addition & 0 deletions ArmaToolbox/lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ def draw_item(self, context, layout, data, item, icon, active_data, active_propn
)

def safeAddTime(frame, prop):
frame = int(frame)
for k in prop:
if k.timeIndex == frame:
return
Expand Down
2 changes: 1 addition & 1 deletion ArmaToolbox/panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ def poll(cls, context):
## Visible when there is a selected object, it is a mesh
obj = context.active_object

return (obj
return (obj != None
and obj.select_get() == True
and obj.armaObjProps != None
and obj.armaObjProps.isArmaObject == True
Expand Down
4 changes: 2 additions & 2 deletions deploy.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
xcopy /y ArmaToolbox\*.* "%appdata%\Blender Foundation\Blender\4.0\scripts\addons\ArmaToolbox"
del /s/q "%appdata%\Blender Foundation\Blender\4.0\scripts\addons\ArmaToolbox\__pycache__"
xcopy /y ArmaToolbox\*.* "%appdata%\Blender Foundation\Blender\4.1\scripts\addons\ArmaToolbox"
del /s/q "%appdata%\Blender Foundation\Blender\4.1\scripts\addons\ArmaToolbox\__pycache__"

0 comments on commit 86694ba

Please sign in to comment.