Skip to content

Commit

Permalink
Merge pull request #1 from BarthPaleologue/HPBD
Browse files Browse the repository at this point in the history
HXPbd Physics Engine
  • Loading branch information
BarthPaleologue authored Feb 9, 2024
2 parents e7dc5c3 + 8628c4f commit e2187b5
Show file tree
Hide file tree
Showing 80 changed files with 701,281 additions and 561 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
Expand Down
33 changes: 19 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,38 @@ file(GLOB SRCS ./*.h ./*.cpp
core/materials/*.cpp core/materials/*.h
core/utils/*.cpp core/utils/*.h
core/physics/*.cpp core/physics/*.h
core/shadows/*.cpp core/shadows/*.h
imgui/*.cpp imgui/*.h
)
add_executable(featherGL ${SRCS}
core/physics/DistanceConstraint.h
core/physics/BendConstraint.h
core/physics/SelfCollisionConstraint.h
core/physics/ClothBalloonConstraint.h
core/physics/Cloth.h
core/physics/PhysicsBody.h
core/physics/FixedConstraint.h
core/utils/ComputeShader.h
core/shadows/ShadowRenderer.h
core/materials/DepthMaterial.h
core/meshes/ScreenQuad.h
core/materials/PbrMaterial.h


add_executable(featherGL ${SRCS} ${IMGUI_SRC}
core/physics/UniformAccelerationField.h
core/physics/DihedralBendConstraint.h
core/physics/ConstraintHelper.h
core/Renderable.h
core/AABB.h
core/AABBHelper.h
core/physics/GlobalVolumeConstraint.h
core/PickResult.h
core/physics/PhysicsBodyHelper.h
)

file(COPY assets DESTINATION ${CMAKE_BINARY_DIR})

find_package(glfw3 REQUIRED)
message(STATUS "Found GLFW3")
target_link_libraries(${PROJECT_NAME} glfw)

find_package(glm REQUIRED)
message(STATUS "GLM included")

target_link_libraries(${PROJECT_NAME} glfw glm::glm)

target_sources(${PROJECT_NAME} PRIVATE glad/src/glad.c)
target_include_directories(${PROJECT_NAME} PRIVATE glad/include/)

target_sources(${PROJECT_NAME} PRIVATE Eigen/Dense)
target_include_directories(${PROJECT_NAME} PRIVATE Eigen/)

# Set optimization level to -O3
target_compile_options(${PROJECT_NAME} PRIVATE -O3)
2 changes: 1 addition & 1 deletion CelestialBody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

CelestialBody::CelestialBody(const char *name, float radius, float rotationPeriod, float orbitPeriod, float orbitRadius,
std::shared_ptr<BlinnPhongMaterial> material, Scene &scene) :
_mesh(MeshBuilder::makeSphere(name, scene, 32)) {
_mesh(MeshBuilder::makeUvSphere(name, scene, 32)) {
_mesh->transform()->setScale(radius);
_mesh->setMaterial(material);
_rotationPeriod = rotationPeriod;
Expand Down
59 changes: 54 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,60 @@
# Feather

Feather is a small opengl engine written in c++ inspired by BabylonJS aiming at easily create complex playgrounds for simulations.
Feather is a small OpenGL engine written in C++ developed for fun and learning purposes. The API is loosely inspired by BabylonJS.

It features a demo of a small simple solar system made using the engine.
![HXPBD](img.png)

![Many Point Lights](./coverImages/cover0.png)
## Features

<img src="./coverImages/cover3.png">
### General

<img src="./coverImages/cover4.png">
- Blinn-Phong shading
- PBR shading
- Normal mapping
- Shadow Mapping
- CPU mouse picking
- Post-processing effects
- Compute shaders
- Raw `.obj` file loading
- Up to 128 point lights by default
- ImGui integration

### Physics

The entire code for the physics engine is available in the `core/physics` directory. It is based on the Position-Based Dynamics (PBD) method, and includes the following features:

- XPBD soft body simulation
- HPBD multigrid solver for XPBD
- Distance constraints
- Fast and Dihedral bending constraints
- Tetrahedral volume constraints
- Global volume constraints
- Collision constraints with friction
- Collision LoD using HPBD
- Constraints and bounding boxes helpers

### How to build

#### Dependencies

Feather uses GLFW3 for window management and input, as well as GLM for math operations.

They can be installed on any Debian-based system using the following command:

```bash
sudo apt install libglfw3-dev libglm-dev
```

#### CMake

Feather uses CMake as its build system. To build the project, you can use the following commands:

```bash
mkdir build
cd build
cmake ..
make
```


![Many Point Lights](./coverImages/cover0.png)
Loading

0 comments on commit e2187b5

Please sign in to comment.