Browse Source

Minor fixes for compatibility issues with QRally:

- Handle null frame names when matching with animation regex
- Default to skin 0 when the provided skin number is out of range
- Convert polygon vertices directly to Unity coordinate positions
console
Nico de Poel 5 years ago
parent
commit
c5cefca10d
  1. 5
      Assets/Scripts/Game/Entity.cs
  2. 2
      Assets/Scripts/Support/AliasModel.cs
  3. 2
      Assets/Scripts/Support/BrushModel.cs

5
Assets/Scripts/Game/Entity.cs

@ -1,5 +1,4 @@
using UnityEngine; using UnityEngine;
using UnityEngine.Rendering;
public class Entity public class Entity
{ {
@ -142,9 +141,9 @@ public class Entity
return; return;
var skins = aliasModel.Textures.Skins; var skins = aliasModel.Textures.Skins;
if (skinNumber >= 0 && skinNumber < skins.Count)
if (skins.Count > 0)
{ {
var skin = skins[skinNumber];
var skin = skins[skinNumber >= 0 && skinNumber < skins.Count ? skinNumber : 0];
if (skin.Frames.Count > 0) if (skin.Frames.Count > 0)
visualStyle.SetAliasModelTextures(material, skin.Frames[0].MainTexture, skin.Frames[0].FullBrightTexture); visualStyle.SetAliasModelTextures(material, skin.Frames[0].MainTexture, skin.Frames[0].FullBrightTexture);
} }

2
Assets/Scripts/Support/AliasModel.cs

@ -105,7 +105,7 @@ public class AliasModel
for (int frameIdx = 0; frameIdx < header.numFrames; ++frameIdx) for (int frameIdx = 0; frameIdx < header.numFrames; ++frameIdx)
{ {
// Individual sequences are identified by their prefix // Individual sequences are identified by their prefix
string frameName = AnimationRegex.Match(header.frames[frameIdx].name).Value;
string frameName = AnimationRegex.Match(header.frames[frameIdx].name ?? "").Value;
if (animName == null) if (animName == null)
{ {
animName = frameName; animName = frameName;

2
Assets/Scripts/Support/BrushModel.cs

@ -104,7 +104,7 @@ public class BrushModel
{ {
for (int vertIdx = 0; vertIdx < polyVerts.Length; ++vertIdx) for (int vertIdx = 0; vertIdx < polyVerts.Length; ++vertIdx)
{ {
tempVertices.Add(polyVerts[vertIdx].position.ToVector3().ToUnity());
tempVertices.Add(polyVerts[vertIdx].position.ToUnityPosition());
tempTextureUVs.Add(polyVerts[vertIdx].textureUV.ToVector2()); tempTextureUVs.Add(polyVerts[vertIdx].textureUV.ToVector2());
tempLightmapUVs.Add(polyVerts[vertIdx].lightmapUV.ToVector2()); tempLightmapUVs.Add(polyVerts[vertIdx].lightmapUV.ToVector2());
} }

Loading…
Cancel
Save