Skip to content

Commit

Permalink
Checking back in various bug fixes from internal branch and glb writi…
Browse files Browse the repository at this point in the history
…ng logic (#253)

* Merged PR 947085: Merging changes for loading from glTF branch into master

- Reset master to be the same as the KhronosGroup github master branch
- Sending out PR which are changes that are not committed yet to KhronosGroup master branch. Main new changes is ILoader implementation
- Some of this code has been previously reviewed, such as the changes to GLTFSerialization

* Merged PR 950991: Added StorageFolder support for file loading

* Added coroutine helper in order to run Unity main thread tasks as async
* Refactored ILoader to only load streams
*  Made ILoader async for UWP

Related work items: #14071709

* Merged PR 999460: Fixed issue where extras and extensions would break parsing

Fixed issue where extras and extensions would break parsing also comitting Json 9.0 changes

* Merged PR 1014087: Adding GLTF merge feature and copy constructor for GLTFRoot

[+] Added test that merges lantern and boombox together
[+] Added test that verifies lengths and copying behaviour in serialization unit test
[~] Added copy constructors to each GLTFProperty class
[~] Added GLTFHelpers merge code which adds together two GLTF objects

* Merged PR 1023531: fixes for copy and merge bugs

fixes for copy and merge bugs

* Min and max are optional parameters
* Extensions used and extensions required were not initialized

* Merged PR 1086143: Merging changes from Pisa back into internal glTF repo

Merging changes from Pisa back into internal glTF repo

* Merged PR 1096169: Adding unsigned int as a supported type

Adding unsigned int as a supported type to GetUnsignedDiscreteElement

* Merged PR 1097336: Fixed matrix on node to serialize as column major

Fixed matrix on node to serialize as column major

* Merged PR 1105269: refactor to remove unity-specific coordinate space conversion

refactor to remove unity-specific coordinate space conversion

* Merged PR 1112053: Refactored UnityGLTF to be able to have a Unity component and a file load component with the Unity component being based around coroutines

Refactored UnityGLTF to be able to have a Unity component and a file load component with the Unity component being based around coroutines

* Got project working in UWP
* Separated out functions into multiple components for loading buffers vs loading images
* Added coroutines to Unity loading to split loading up across frames

Related work items: #14485947

* Merged PR 1134418: Updated standalone texture creation

Updated standalone texture creation.

* Merged PR 1162126: More fixes to transforms

More fixes to transforms

* Merged PR 1112053: Refactored UnityGLTF to be able to have a Unity component and a file load component with the Unity component being based around coroutines

Refactored UnityGLTF to be able to have a Unity component and a file load component with the Unity component being based around coroutines

* Got project working in UWP
* Separated out functions into multiple components for loading buffers vs loading images
* Added coroutines to Unity loading to split loading up across frames

Related work items: #14485947

* Merged PR 1134418: Updated standalone texture creation

Updated standalone texture creation.

* Merged PR 1162126: More fixes to transforms

More fixes to transforms

* Updated GLTF

* Reverted WebRequestLoader to use UnityWebRequest and ILoader interface for non UWP now uses ILoader

* Merged PR 1241880: Made all API's use coroutines instead of async in UWP

- Switched async functions to coroutine based
- Added TaskExtensions to run async as coroutines

* Merged PR 1242827: Merging glTF master into Pisa

- Merged together glTF master and Pisa
- Fixed bugs that popped up
- Main merge problem was merging together the changes that happened to spec gloss

* Merged PR 1243600: GLTFRoot now goes through extension clone

There was a bug where any clone that depended on GLTFRoot could not be completed successfully. All clones now have GLTFRoot passed in.

* Adding GLTF merge feature and copy constructor for GLTFRoot

[+] Added test that merges lantern and boombox together
[+] Added test that verifies lengths and copying behaviour in serialization unit test
[~] Added copy constructors to each GLTFProperty class
[~] Added GLTFHelpers merge code which adds together two GLTF objects

* Min and max are now optional parameters
* Extensions used and extensions required were not initialized

* Deleting files that we do not want to keep

Deleting Examples, UnityTestFramework, and Test files so that they are not included in Pisa

* Merged PR 1326279: Modifying UnityGLTF Components to function with current version of Unity

Modified some files to function properly with our current Pisa codebase
In addition removed AsyncCoroutineHelpers from here and ported to Pisa

* Merged PR 1328468: Fixing the TaskExtension check for proper unity support

The .Net check only works for il2cpp. Swapping to use check for Unity Version so this works everywhere.

* Merged PR 1344253: GLB Updates

GLB Updates to GLTFSceneImporter
[+] Allow delay-loading the GLB stream
[~] Properly initialize the buffer if asking for a thumbnail before loading all textures
[~] Sending all image loads through LoadUnityTexture so our Pisa version can check for dds regardless of source type

* Merged PR 1353216: GLB serialization fix

Fix serialization of images with buffer view references.

* Merged PR 1373687: Merging github/master into pisa_dev

* Merged PR 1385832: Merging initial glb builder work into pisa_dev. Can create a GLBObject from a GLB and resave it out with varying size JSON

See https://microsoft.sharepoint.com/teams/wdg_wex/hxt/Shared%20Documents/Pisa/Dev/Dev%20Specs/Edit%20and%20Save%20as%20GLB%20One%20Pager.docx?web=1 for implementation details.

See https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#glb-file-format-specification for GLB specification

- Upgraded .NET version to 4.6
- Implemented ConstructFromStream and UpdateStream API's
- Adds ability to create a GLB from a stream, and update the JSON of the GLB. Supports having two streams to same resource.
-- Reallocation for JSON chunks is currently only a "growing" allocation and will always double. Max size is uint.maxvalue
-- Known issue: having a file to copy that is larger than RAM will cause an OutOfMemoryException. This will be fixed in a future version of the API

* Merged PR 1390761: Added functions to Add or Remove generic stream blobs to the GLB

- Implemented AddBlob which appends a stream onto the end of GLB and updates the GLTFRoot with the updated BufferView and returns the new BufferView
- Implemented BufferView RemoveBlob which removes a BufferView from GLTF and will shrink the buffer it is at the end

* Merged PR 1395885: Buffers are now treated as uint32

Buffers are now treated as uint32

* Merged PR 1407945: Fixed issue where binary segment was not aligned properly

Fixed issue where binary segment was not aligned properly

* Merged PR 1412368: UInt script updates

Updating a couple scripts for the Int > UInt changes.
Also adding a null check to the GLBBuilder for the case where a GLB references a non-buffer-view image.

* Merged PR 1413081: Merge pisa_dev to master

- Made all methods synchronous. Callers can call them async
- Reverted project to be .NET 3,5
- Added MergeGLB method to merge two GLB's together

* Merged PR 1428200: Fix for issue where writing to incorrect buffer location

Fix for issue where writing to incorrect buffer location

* Merged PR 1441409: added ability to load color and emissive as sRGB

added ability to load color and emissive as sRGB

* Merged PR 1470088: Changed GLBBuilder namespace from UnityGLTF to GLTF

Changed GLBBuilder namespace from UnityGLTF to GLTF

* Merged PR 1471747: Created generic interface for glTF objects

Created generic interface for glTF objects

IGLTFObject represents an abstract GLTFObject that only has a root

GLTFObject is to be used by glTF (up to calling library to wrap)
GLBObject is produced by the GLBBuilder API's.

* Merged PR 1472641: adding constructor for GLTFObject

adding constructor for GLTFObject

* Merged PR 1475126: reset position to properly parse JSON to GLB

reset position to properly parse JSON to GLB

* Merged PR 1531076: Fixed for GLBBuilder and to GLTFHelper that were found when building out GLB save functionality

- Added more tests
- Fixed bug where Root Merge would merge buffers
- Fixed bug where extensions were not copied properly
- Created the ability to construct from an empty stream
- Added ability to add to a buffer without creating a buffer view

* Merged PR 1527102: Modifications to GLTFSerialization projects to get them to compile in external solutions

Modifications to GLTFSerialization projects to get them to compile in external solutions

* Merged PR 1569575: parsing now only looks for two chunks

parsing now only looks for two chunks

* Merged PR 1569970: fix to ensure that we do not try to parse past stream end

fix to ensure that we do not try to parse past stream end

* Merged PR 1589667: Thumbnail index fix

Correcting the CreateTexture function to pass the requested texture index/id to LoadImageBuffer instead of the image index/id.  This happened to work before because we normally have a 1-to-1 relationship between textures and images, but when we don't this breaks the cache loading math.

Bug 16500028 - [PC App] Most assets imported from Reinwood don't have thumbnails inside Woodinville's asset library

* Merged PR 1609994: fixed issue with invariant culture in float parsing and tangents are now calculated

fixed issue with invariant culture in float parsing and made it so that tangents and normals are calculated if not specified

* Merged PR 1616105: making it so that tangents are always recalculated

making it so that tangents are always recalculated. This is the only way that anything shows correct in Unity regardless of whether or not the initial asset has tangents.

* Merged PR 1629903: gltf root can be explicity swapped

gltf root can be explicity swapped

* Merged PR 1659403: Changes to GLBBuilder to ensure that files without binary contents export properly and get updated correctly

-If chunk info sections are not initialized, we now initialize them
- Added test to verify files are written out properly

Related work items: #16672277

* Merged PR 1692792: added copy constructor to GLBObject

added copy constructor to GLBObject

* Merged PR 1707450: Fixed null check that should be in ref counted cache data that was causing exception on asset clean up

Fixed null check that should be in ref counted cache data that was causing exception on asset clean up

* Merged PR 1746215: Recalculate tangents

We need to recalculate tangents we're getting back from Simplygon

* Merged PR 1775517: Changed Node Creation to not yield between Nodes and made it iterative

- Added profiling
- Made node creation iterative and stopped yielding

* Merged PR 1780585: Fix for bug where if node parent was 0 it would not be set properly

Fix for bug where if node parent was 0 it would not be set properly which caused scaling issue in the PC app

Related work items: #17378069

* Merged PR 2026929: Invalid GLTF handling

Adding a helper function for dropping invalid data from a gltf node (references to indexes that don't exist) and turning it on by default in the GLBBuilder.

Related work items: #17520364

* Merged PR 2095998: Removed invariant culture as ToString() adds the culture info

Removed invariant culture as ToString() adds the culture info

This is giving the issue in locales like fr-FR when we try to render the asset in Perspective view in the Pisa PC App and this is happening due to the parsing in the InvariantCulture and ToString() localizes the value.

Related work items: #18189854

* Merged PR 2104257: Fixed exceptions when serializing assets with the khr spec-gloss extension

Fixed exceptions when serializing assets with the khr spec-gloss extension

* Merged PR 2115866: Fixing some deserialization exceptions

Fixed a few deserialization exceptions while testing with the sample assets from the GLTF sample assets repo

* Merged PR 2302513: parent nodes no longer are set active automatically to prevent preappearing

parent nodes no longer are set active automatically to prevent preappearing before compleition

* fixed gltf root merge issue
  • Loading branch information
Blake Gross committed Oct 4, 2018
1 parent 04b5cd7 commit 71563fb
Show file tree
Hide file tree
Showing 52 changed files with 13,694 additions and 3,178 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -148,4 +148,6 @@ _pkginfo.txt
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
!*.[Cc]ache/

*.orig
1 change: 1 addition & 0 deletions GLTFSerialization/External/glTF-Binary/.gitignore
@@ -0,0 +1 @@
*Out*
Binary file added GLTFSerialization/External/glTF-Binary/Box.glb
Binary file not shown.
Expand Up @@ -18,6 +18,10 @@
<Version>1.0.0-alpha</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\GLTFSerialization\**\*.cs" Exclude="..\GLTFSerialization\Properties\**\*.cs" />
</ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions GLTFSerialization/GLTFSerialization.sln
Expand Up @@ -37,12 +37,12 @@ Global
{72AC331F-9810-4DE2-8EA3-84559A787218}.Release|x86.Build.0 = Release|x86
{D228AE89-BE53-474F-AB7C-04A3293F59C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D228AE89-BE53-474F-AB7C-04A3293F59C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D228AE89-BE53-474F-AB7C-04A3293F59C1}.Debug|x86.ActiveCfg = Debug|x86
{D228AE89-BE53-474F-AB7C-04A3293F59C1}.Debug|x86.Build.0 = Debug|x86
{D228AE89-BE53-474F-AB7C-04A3293F59C1}.Debug|x86.ActiveCfg = Debug|Any CPU
{D228AE89-BE53-474F-AB7C-04A3293F59C1}.Debug|x86.Build.0 = Debug|Any CPU
{D228AE89-BE53-474F-AB7C-04A3293F59C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D228AE89-BE53-474F-AB7C-04A3293F59C1}.Release|Any CPU.Build.0 = Release|Any CPU
{D228AE89-BE53-474F-AB7C-04A3293F59C1}.Release|x86.ActiveCfg = Release|x86
{D228AE89-BE53-474F-AB7C-04A3293F59C1}.Release|x86.Build.0 = Release|x86
{D228AE89-BE53-474F-AB7C-04A3293F59C1}.Release|x86.ActiveCfg = Release|Any CPU
{D228AE89-BE53-474F-AB7C-04A3293F59C1}.Release|x86.Build.0 = Release|Any CPU
{821B87A3-D8FA-407A-BC58-928A859C71C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{821B87A3-D8FA-407A-BC58-928A859C71C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{821B87A3-D8FA-407A-BC58-928A859C71C4}.Debug|x86.ActiveCfg = Debug|x86
Expand Down
2 changes: 1 addition & 1 deletion GLTFSerialization/GLTFSerialization/AttributeAccessor.cs
Expand Up @@ -7,7 +7,7 @@ public class AttributeAccessor
public AccessorId AccessorId { get; set; }
public NumericArray AccessorContent { get; set; }
public System.IO.Stream Stream { get; set; }
public long Offset { get; set; }
public uint Offset { get; set; }

public AttributeAccessor()
{
Expand Down
Expand Up @@ -314,11 +314,11 @@ public static Quaternion ReadAsQuaternion(this JsonReader reader)
return quat;
}

public static Dictionary<string, T> ReadAsDictionary<T>(this JsonReader reader, Func<T> deserializerFunc)
public static Dictionary<string, T> ReadAsDictionary<T>(this JsonReader reader, Func<T> deserializerFunc, bool skipStartObjectRead = false)
{
if (reader.Read() && reader.TokenType != JsonToken.StartObject)
if (!skipStartObjectRead && reader.Read() && reader.TokenType != JsonToken.StartObject)
{
throw new Exception(string.Format("Dictionary must be an object at: {0}", reader.Path));
throw new Exception(string.Format("Dictionary must be an object at: {0}.", reader.Path));
}

var dict = new Dictionary<string, T>();
Expand Down
Expand Up @@ -86,13 +86,13 @@ public JProperty Serialize()
JProperty jProperty =
new JProperty(KHR_materials_pbrSpecularGlossinessExtensionFactory.EXTENSION_NAME,
new JObject(
new JProperty(KHR_materials_pbrSpecularGlossinessExtensionFactory.DIFFUSE_FACTOR, DiffuseFactor),
new JProperty(KHR_materials_pbrSpecularGlossinessExtensionFactory.DIFFUSE_FACTOR, new JArray(DiffuseFactor.R, DiffuseFactor.G, DiffuseFactor.B, DiffuseFactor.A)),
new JProperty(KHR_materials_pbrSpecularGlossinessExtensionFactory.DIFFUSE_TEXTURE,
new JObject(
new JProperty(TextureInfo.INDEX, DiffuseTexture.Index.Id)
)
),
new JProperty(KHR_materials_pbrSpecularGlossinessExtensionFactory.SPECULAR_FACTOR, SpecularFactor),
new JProperty(KHR_materials_pbrSpecularGlossinessExtensionFactory.SPECULAR_FACTOR, new JArray(SpecularFactor.X, SpecularFactor.Y, SpecularFactor.Z)),
new JProperty(KHR_materials_pbrSpecularGlossinessExtensionFactory.GLOSSINESS_FACTOR, GlossinessFactor),
new JProperty(KHR_materials_pbrSpecularGlossinessExtensionFactory.SPECULAR_GLOSSINESS_TEXTURE,
new JObject(
Expand Down

0 comments on commit 71563fb

Please sign in to comment.