-
Notifications
You must be signed in to change notification settings - Fork 285
MeshLodGenerator: native v2 Mesh support #580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Laxx18
wants to merge
3
commits into
OGRECave:master
Choose a base branch
from
Laxx18:feature/v2-mesh-lod-generator
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
74 changes: 74 additions & 0 deletions
74
Components/MeshLodGenerator/include/OgreLodInputProviderMeshV2.h
This file contains hidden or 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,74 @@ | ||
| /* | ||
| * ----------------------------------------------------------------------------- | ||
| * This source file is part of OGRE-Next | ||
| * (Object-oriented Graphics Rendering Engine) | ||
| * For the latest info, see http://www.ogre3d.org/ | ||
| * | ||
| * Copyright (c) 2000-2014 Torus Knot Software Ltd | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| * of this software and associated documentation files (the "Software"), to deal | ||
| * in the Software without restriction, including without limitation the rights | ||
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| * copies of the Software, and to permit persons to whom the Software is | ||
| * furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in | ||
| * all copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| * THE SOFTWARE. | ||
| * ----------------------------------------------------------------------------- | ||
| */ | ||
|
|
||
| #ifndef _LodInputProviderMeshV2_H__ | ||
| #define _LodInputProviderMeshV2_H__ | ||
|
|
||
| #include "OgreLodPrerequisites.h" | ||
|
|
||
| #include "OgreLodInputProvider.h" | ||
| #include "OgreSharedPtr.h" | ||
|
|
||
| namespace Ogre | ||
| { | ||
| /** Reads geometry directly from a v2 Mesh's SubMesh VAOs (no v1 mesh involved at | ||
| any point) and populates a LodData for MeshLodGenerator to collapse. | ||
| @remarks | ||
| Unlike LodInputProviderMesh, there is no shared-vertex-data concept to handle: | ||
| v2 Mesh has no Mesh-level shared vertex buffer, only per-SubMesh VAOs. This | ||
| removes the mSharedVertexLookup / useSharedVertexLookup branching entirely. | ||
| @par | ||
| Reads vertex/index data via VertexArrayObject::readRequests() + | ||
| mapAsyncTickets() + unmapAsyncTickets() (the same pattern SubMesh:: | ||
| _dearrangeEfficient() already uses elsewhere in this codebase), which works | ||
| synchronously regardless of whether the buffers are shadow-copied, so there | ||
| is no special buffer-policy requirement on the source mesh. | ||
| */ | ||
| class _OgreLodExport LodInputProviderMeshV2 : public LodInputProvider | ||
| { | ||
| public: | ||
| LodInputProviderMeshV2( MeshPtr mesh ); | ||
|
|
||
| void initData( LodData *data ) override; | ||
|
|
||
| protected: | ||
| MeshPtr mMesh; | ||
|
|
||
| /// Reused across submeshes; cleared at the start of each addVertexData() call. | ||
| /// One entry per vertex in the submesh's LOD-0 vertex buffer, mapping its | ||
| /// position in that buffer to the deduplicated LodData::VertexI. | ||
| VertexLookupList mVertexLookup; | ||
|
|
||
| void tuneContainerSize( LodData *data ); | ||
| void initialize( LodData *data ); | ||
| void addVertexData( LodData *data, SubMesh *subMesh, unsigned submeshID ); | ||
| void addIndexData( LodData *data, SubMesh *subMesh, unsigned submeshID ); | ||
| }; | ||
|
|
||
| } // namespace Ogre | ||
| #endif |
79 changes: 79 additions & 0 deletions
79
Components/MeshLodGenerator/include/OgreLodOutputProviderMeshV2.h
This file contains hidden or 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,79 @@ | ||
| /* | ||
| * ----------------------------------------------------------------------------- | ||
| * This source file is part of OGRE-Next | ||
| * (Object-oriented Graphics Rendering Engine) | ||
| * For the latest info, see http://www.ogre3d.org/ | ||
| * | ||
| * Copyright (c) 2000-2014 Torus Knot Software Ltd | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| * of this software and associated documentation files (the "Software"), to deal | ||
| * in the Software without restriction, including without limitation the rights | ||
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| * copies of the Software, and to permit persons to whom the Software is | ||
| * furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in | ||
| * all copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| * THE SOFTWARE. | ||
| * ----------------------------------------------------------------------------- | ||
| */ | ||
|
|
||
| #ifndef _LodOutputProviderMeshV2_H__ | ||
| #define _LodOutputProviderMeshV2_H__ | ||
|
|
||
| #include "OgreLodPrerequisites.h" | ||
|
|
||
| #include "OgreLodOutputProvider.h" | ||
| #include "OgreSharedPtr.h" | ||
|
|
||
| namespace Ogre | ||
| { | ||
| /** Writes generated LOD levels directly onto a v2 Mesh's SubMesh::mVao arrays. | ||
| @remarks | ||
| Unlike LodOutputProviderMesh (which builds a v1::SubMesh::LODFaceList), this | ||
| appends a brand new VertexArrayObject per LOD level directly onto | ||
| SubMesh::mVao[VpNormal] (and [VpShadow], see bakeLodLevel()), reusing the | ||
| existing LOD-0 vertex buffers untouched -- LOD generation only ever changes | ||
| the index buffer, never vertex data, matching the pattern already proven in | ||
| SubMesh::importBuffersFromV1()'s own v1-LOD-import loop. | ||
| @par | ||
| Populating Mesh::_setLodValues() is intentionally NOT done here: just like | ||
| v1's LodOutputProviderMesh leaves _configureMeshLodUsage() as a separate step | ||
| MeshLodGenerator calls itself (it already has LodConfig in scope, this | ||
| provider doesn't need to carry a copy of it), the v2 path has a parallel | ||
| MeshLodGenerator::_configureMeshLodUsageV2() called the same way, after | ||
| output->finalize(). | ||
| @par | ||
| Manual (mesh-swap) LOD levels are intentionally not supported here; see | ||
| bakeManualLodLevel(). | ||
| */ | ||
| class _OgreLodExport LodOutputProviderMeshV2 : public LodOutputProvider | ||
| { | ||
| public: | ||
| LodOutputProviderMeshV2( MeshPtr mesh ) : mMesh( mesh ) {} | ||
|
|
||
| void prepare( LodData *data ) override; | ||
| void finalize( LodData *data ) override {} | ||
| void bakeManualLodLevel( LodData *data, String &manualMeshName, int lodIndex ) override; | ||
| void bakeLodLevel( LodData *data, int lodIndex ) override; | ||
|
|
||
| protected: | ||
| MeshPtr mMesh; | ||
|
|
||
| /// Builds a new IndexBufferPacked from data's current triangle list for one | ||
| /// submesh, exactly mirroring LodOutputProviderMesh::bakeLodLevel's v1 index | ||
| /// construction (same "dummy triangle if empty" handling), but returning a | ||
| /// v2 IndexBufferPacked instead of writing into a v1::IndexData. | ||
| IndexBufferPacked *buildIndexBufferForSubmesh( LodData *data, unsigned submeshID ); | ||
| }; | ||
|
|
||
| } // namespace Ogre | ||
| #endif |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unrelated.