Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/v-sekai-godot/vsk-subdiv-4.4' i…
Browse files Browse the repository at this point in the history
…nto groups-staging-4.4
  • Loading branch information
fire committed Jan 28, 2025
2 parents ab75417 + 8a15f3b commit 882b903
Show file tree
Hide file tree
Showing 287 changed files with 103,935 additions and 0 deletions.
22 changes: 22 additions & 0 deletions modules/subdiv/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignOperands: DontAlign
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
BreakConstructorInitializers: AfterColon
ColumnLimit: 0
ConstructorInitializerIndentWidth: 8
ContinuationIndentWidth: 8
Cpp11BracedListStyle: false
IndentCaseLabels: true
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: false
SpacesInLineCommentPrefix:
Minimum: 0
Maximum: -1
TabWidth: 4
UseTab: Always

Language: Cpp
Standard: c++17
2 changes: 2 additions & 0 deletions modules/subdiv/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf
21 changes: 21 additions & 0 deletions modules/subdiv/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Binaries.
*.so

# Objects.
.scons-cache/
*.os

# SConstruct
.sconf_temp
.sconsign.dblite
*.pyc

# MacOS
.DS_Store/

# Editors
.vscode/

*.obj

*.o
12 changes: 12 additions & 0 deletions modules/subdiv/.gitrepo
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
; DO NOT EDIT (unless you know what you are doing)
;
; This subdirectory is a git "subrepo", and this file is maintained by the
; git-subrepo command. See https://github.com/ingydotnet/git-subrepo#readme
;
[subrepo]
remote = https://github.com/V-Sekai/godot-subdiv.git
branch = main
commit = 9b0c7e36c52ee931b95e406bb345009f073eed17
parent = e2d9f70a6e1ecaba5fa1a36a5c5c8689a0da10b0
method = merge
cmdver = 0.4.9
16 changes: 16 additions & 0 deletions modules/subdiv/AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Godot Subdiv authors

GitHub usernames are indicated in parentheses.

## Initial Project

This project is originally a port from a [Godot 3 module](https://github.com/godot-extended-libraries/godot-fire/tree/feature/3.2/opensubdiv-next) by

K. S. Ernest (iFire) Lee (fire)

who also contributed directly by testing, opening issues and helping with the Importer.
\
\
The [proposal for adding opensubdiv](https://github.com/godotengine/godot-proposals/issues/784) to Godot, laying the groundwork for said module, was made by

Camille Mohr-Daurat (pouleyKetchoupp)
22 changes: 22 additions & 0 deletions modules/subdiv/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2023-present K. S. Ernest (Lee) and contributors (cf. AUTHORS.md).
Copyright (c) 2022 Marvin Falk and contributors (cf. AUTHORS.md).

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.
68 changes: 68 additions & 0 deletions modules/subdiv/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Godot Subdiv

This is a modified version of tefusion/godot-subdiv to be a Godot Engine C++ module.

| ![UV Subdivision](UVSubdivision.gif) | ![Skinning subdivision](SkinningSubdivision.gif) |
| ------------------------------------ | ------------------------------------------------ |

## Getting Started

### Importing

After installing the addon and enabling it in the settings, you can select the custom **Godot Subdiv Importer** in the import settings for any glb or gltf file. You can also use the **subdivision settings in any scene importer** to be able to make use of all the features of the 3d import pipeline from Godot.

There you will see one option.

SubdivMeshInstance3D

Doesn't bake. Skinning and blend shape changes get processed by CPU and then directly thrown at the RenderingServer. This is useful if you have a changing mesh or changing subdivision level.

Adjust the subdivision level, click reimport and you should see your mesh subdivided.

### Modeling Tips

OpenSubdiv has a great section on [modeling for subdivision](https://graphics.pixar.com/opensubdiv/docs/mod_notes.html). Not all of them apply for Godot Subdiv though: You can currently only import either quad only meshes to use the Catmull-Clark scheme or any other mesh which will default to the Loop subdivision scheme.

### Building the project yourself

To build this project you need to have SCons installed, otherwise everything is included in the project.

For just building and trying out the project, do:

```bash
scons target=template_debug
```

in the cloned folder.

For running the tests, do:

```bash
scons -Q tests=1 target=template_debug
```

which will run simple doctest tests when starting godot on the terminal:

```bash
path/to/godot --editor --path ${workspaceFolder}/project
```

See more in the [SConstruct](SConstruct) file.

## FAQ

### How to create a mesh only containing Quads?

In Blender, you can go in Edit Mode and go Select->Select All by Trait->Faces by Sides and set it to Not Equal To 4. After removing the then selected faces and replacing them with quads, Quad import will work.

## Acknowledgments

- [OpenSubdiv](https://github.com/PixarAnimationStudios/OpenSubdiv) files in [thirdparty/opensubdiv](thirdparty/opensubdiv) licensed under [Modified Apache 2.0](thirdparty/opensubdiv/LICENSE.txt)
- [Godot3 module for opensubdiv](https://github.com/godot-extended-libraries/godot-fire/tree/feature/3.2/opensubdiv-next) by fire that was referenced for subdivision implementation
- [Template used](https://github.com/nathanfranke/gdextension), includes the used GitHub workflow and was easy to set up

## License

[MIT](LICENSE)

Third-party notices are in [THIRDPARTY.md](THIRDPARTY.md).
37 changes: 37 additions & 0 deletions modules/subdiv/SCsub
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python

Import("env")

module_env = env.Clone()
module_env.Append(CPPDEFINES=["_USE_MATH_DEFINES"])
module_env.add_source_files(env.modules_sources, "src/import/*.cpp")
module_env.add_source_files(env.modules_sources, "src/nodes/*.cpp")
module_env.add_source_files(env.modules_sources, "src/resources/*.cpp")
module_env.add_source_files(env.modules_sources, "src/subdivision/*.cpp")

thirdparty_dir = "thirdparty/opensubdiv/"
thirdparty_sources = [
"far/error.cpp",
"far/topologyDescriptor.cpp",
"far/topologyRefiner.cpp",
"far/topologyRefinerFactory.cpp",
"sdc/crease.cpp",
"sdc/typeTraits.cpp",
"vtr/fvarLevel.cpp",
"vtr/fvarRefinement.cpp",
"vtr/level.cpp",
"vtr/quadRefinement.cpp",
"vtr/refinement.cpp",
"vtr/sparseSelector.cpp",
"vtr/triRefinement.cpp",
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]

env_thirdparty = module_env.Clone()
env_thirdparty.disable_warnings()
env_thirdparty.add_source_files(env.modules_sources, thirdparty_sources)

module_env.add_source_files(env.modules_sources, "*.cpp")

if env.editor_build:
module_env.add_source_files(env.modules_sources, "editor/*.cpp")
Binary file added modules/subdiv/SkinningSubdivision.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 882b903

Please sign in to comment.