-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added OcclusionCullingData for world.zen - TODO: Need to be tested if…
… performance is better. (Drawcalls during runtime are ~80% less at least...)
- Loading branch information
Showing
10 changed files
with
119 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using System; | ||
using System.IO; | ||
using GVR.Caches; | ||
using GVR.Creator; | ||
using GVR.Phoenix.Interface; | ||
using GVR.Util; | ||
using PxCs.Interface; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace GothicVR.Editor | ||
{ | ||
public class OcclusionCullingTool : EditorWindow | ||
{ | ||
private const string _G1DIR = "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Gothic"; | ||
private static IntPtr _vdfsPtr = IntPtr.Zero; | ||
private static MeshCreator _meshCreator; | ||
|
||
|
||
[MenuItem("GothicVR/Tools/Occlusion Culling", true)] | ||
private static bool ValidateMyMenuItem() | ||
{ | ||
// If game is in playmode, disable button. | ||
return !EditorApplication.isPlaying; | ||
} | ||
|
||
[MenuItem("GothicVR/Tools/Occlusion Culling")] | ||
public static void ShowWindow() | ||
{ | ||
// Do not show Window when game is started. | ||
if (Application.isPlaying) | ||
return; | ||
|
||
_meshCreator = SingletonBehaviour<MeshCreator>.GetOrCreate(); | ||
var assetCache = SingletonBehaviour<AssetCache>.GetOrCreate(); | ||
|
||
_meshCreator.EditorInject(assetCache); | ||
|
||
var fullPath = Path.GetFullPath(Path.Join(_G1DIR, "Data")); | ||
_vdfsPtr = VdfsBridge.LoadVdfsInDirectory(fullPath); | ||
|
||
// Hint: When we load meshes/textures via MeshCreator.cs, there's hard coded PhoenixBridge.VdfPtr used. | ||
// As we ensured our Window is only active when not playing, we can safely reuse it for now. | ||
PhoenixBridge.VdfsPtr = _vdfsPtr; | ||
|
||
var world = WorldBridge.LoadWorld(_vdfsPtr, "world.zen"); | ||
|
||
_meshCreator.Create(world); | ||
} | ||
|
||
void OnGUI() | ||
{ | ||
// Do not show Window when game is started. | ||
if (Application.isPlaying) | ||
{ | ||
Close(); | ||
return; | ||
} | ||
} | ||
|
||
void OnDestroy() | ||
{ | ||
if (_vdfsPtr == IntPtr.Zero) | ||
return; | ||
|
||
PxVdf.pxVdfDestroy(_vdfsPtr); | ||
_vdfsPtr = IntPtr.Zero; | ||
|
||
// Hint: If window closes as the game is started, we must not! clear PhoenixBridge.VdfPtr as it would crash the game. | ||
// Therefore just leave it as it is... | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Assets/GothicVR/Editor/GVR.Editor.OcclusionCullingTool.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
Assets/GothicVR/Scenes/SampleScene/OcclusionCullingData.asset
Git LFS file not shown
8 changes: 8 additions & 0 deletions
8
Assets/GothicVR/Scenes/SampleScene/OcclusionCullingData.asset.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters