Skip to content

Commit

Permalink
gltf: Couple small fixes
Browse files Browse the repository at this point in the history
- Replace a throwing cast that was meant to be a nulling cast
- ShaderRegex wasn't working for gltfs created with "copy files to gltf"

Change-Id: Id000b015a4e3e22cc84f006fc396572f4084fa53
  • Loading branch information
dubois committed Oct 1, 2019
1 parent 8b5ec11 commit c5e8c24
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ namespace TiltBrushToolkit {
public class GltfMaterialConverter {
private static readonly Regex kTiltBrushMaterialRegex = new Regex(
@".*([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$");
// Matches
// http://...<guid>/shadername.glsl
// <some local file>/.../<guid>-<version>.glsl
private static readonly Regex kTiltBrushShaderRegex = new Regex(
@".*([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/");
@".*([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})[/-]");

/// <summary>
/// Information about a Unity material generated from a Gltf node.
Expand Down
3 changes: 1 addition & 2 deletions UnitySDK/Assets/TiltBrush/Scripts/Gltf/ImportGltf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1009,8 +1009,7 @@ static Semantic GetTexcoordSemantic(ImportState state, GltfMaterialBase material
// Thus it needs to be data-driven.
if (desc == null) {
// Might happen in gltf2
Gltf2Material material2 = (Gltf2Material)material;
if (material2 == null) {
if (!(material is Gltf2Material material2)) {
Debug.LogWarning("Unexpected: Non-BrushDescriptor geometry in gltf1");
return Semantic.Unspecified;
} else {
Expand Down

0 comments on commit c5e8c24

Please sign in to comment.