Commit 98718919 authored by Nghia Truong's avatar Nghia Truong

Merge remote-tracking branch 'origin-imstk/master' into ParallelPBDConstraintProjection

# Conflicts:
#	Source/DynamicalModels/ObjectStates/imstkPbdState.h
#	Source/Solvers/imstkPbdSolver.h
parents fc178ff5 e8ec9c88
......@@ -19,6 +19,8 @@ function(CopyAndCompileShaders)
compileShaders(Mesh/mesh_frag.frag Mesh/mesh_frag.spv)
compileShaders(Mesh/decal_vert.vert Mesh/decal_vert.spv)
compileShaders(Mesh/decal_frag.frag Mesh/decal_frag.spv)
compileShaders(Mesh/particle_vert.vert Mesh/particle_vert.spv)
compileShaders(Mesh/particle_frag.frag Mesh/particle_frag.spv)
compileShaders(Mesh/shadow_vert.vert Mesh/shadow_vert.spv)
compileShaders(Mesh/shadow_frag.frag Mesh/shadow_frag.spv)
compileShaders(Mesh/depth_frag.frag Mesh/depth_frag.spv)
......@@ -27,8 +29,11 @@ function(CopyAndCompileShaders)
compileShaders(PostProcessing/HDR_tonemap_frag.frag PostProcessing/HDR_tonemap_frag.spv)
compileShaders(PostProcessing/postprocess_vert.vert PostProcessing/postprocess_vert.spv)
compileShaders(PostProcessing/postprocess_frag.frag PostProcessing/postprocess_frag.spv)
compileShaders(PostProcessing/passthrough_frag.frag PostProcessing/passthrough_frag.spv)
compileShaders(PostProcessing/sss_frag.frag PostProcessing/sss_frag.spv)
compileShaders(PostProcessing/lens_distortion_frag.frag PostProcessing/lens_distortion_frag.spv)
compileShaders(PostProcessing/composite_frag.frag PostProcessing/composite_frag.spv)
compileShaders(PostProcessing/vr_composite_frag.frag PostProcessing/vr_composite_frag.spv)
compileShaders(PostProcessing/bloom_threshold_frag.frag PostProcessing/bloom_threshold_frag.spv)
compileShaders(PostProcessing/blur_horizontal_frag.frag PostProcessing/blur_horizontal_frag.spv)
compileShaders(PostProcessing/blur_vertical_frag.frag PostProcessing/blur_vertical_frag.spv)
......
#-----------------------------------------------------------------------------
# Compile Shaders
#-----------------------------------------------------------------------------
function(compileShaders sourceShader binaryShader)
add_custom_command(
TARGET ${PROJECT_NAME}
COMMAND glslangvalidator -V ${PROJECT_BINARY_DIR}/Shaders/VulkanShaders/${sourceShader} -o ${PROJECT_BINARY_DIR}/Shaders/VulkanShaders/${binaryShader})
endfunction()
function(CopyAndCompileShaders)
if( iMSTK_USE_Vulkan )
file(COPY ${CMAKE_SOURCE_DIR}/Source/Rendering/VulkanRenderer/VulkanShaders
DESTINATION ${PROJECT_BINARY_DIR}/Shaders)
# Mesh shaders
compileShaders(Mesh/mesh_vert.vert Mesh/mesh_vert.spv)
compileShaders(Mesh/mesh_tesc.tesc Mesh/mesh_tesc.spv)
compileShaders(Mesh/mesh_tese.tese Mesh/mesh_tese.spv)
compileShaders(Mesh/mesh_frag.frag Mesh/mesh_frag.spv)
compileShaders(Mesh/decal_vert.vert Mesh/decal_vert.spv)
compileShaders(Mesh/decal_frag.frag Mesh/decal_frag.spv)
compileShaders(Mesh/particle_vert.vert Mesh/particle_vert.spv)
compileShaders(Mesh/particle_frag.frag Mesh/particle_frag.spv)
compileShaders(Mesh/shadow_vert.vert Mesh/shadow_vert.spv)
compileShaders(Mesh/shadow_frag.frag Mesh/shadow_frag.spv)
compileShaders(Mesh/depth_frag.frag Mesh/depth_frag.spv)
# Post processing shaders
compileShaders(PostProcessing/HDR_tonemap_frag.frag PostProcessing/HDR_tonemap_frag.spv)
compileShaders(PostProcessing/postprocess_vert.vert PostProcessing/postprocess_vert.spv)
compileShaders(PostProcessing/postprocess_frag.frag PostProcessing/postprocess_frag.spv)
compileShaders(PostProcessing/passthrough_frag.frag PostProcessing/passthrough_frag.spv)
compileShaders(PostProcessing/sss_frag.frag PostProcessing/sss_frag.spv)
compileShaders(PostProcessing/lens_distortion_frag.frag PostProcessing/lens_distortion_frag.spv)
compileShaders(PostProcessing/composite_frag.frag PostProcessing/composite_frag.spv)
compileShaders(PostProcessing/vr_composite_frag.frag PostProcessing/vr_composite_frag.spv)
compileShaders(PostProcessing/bloom_threshold_frag.frag PostProcessing/bloom_threshold_frag.spv)
compileShaders(PostProcessing/blur_horizontal_frag.frag PostProcessing/blur_horizontal_frag.spv)
compileShaders(PostProcessing/blur_vertical_frag.frag PostProcessing/blur_vertical_frag.spv)
compileShaders(PostProcessing/bloom_threshold_frag.frag PostProcessing/bloom_threshold_frag.spv)
compileShaders(PostProcessing/ao_frag.frag PostProcessing/ao_frag.spv)
compileShaders(PostProcessing/bilateral_blur_horizontal_frag.frag PostProcessing/bilateral_blur_horizontal_frag.spv)
compileShaders(PostProcessing/bilateral_blur_vertical_frag.frag PostProcessing/bilateral_blur_vertical_frag.spv)
compileShaders(PostProcessing/depth_downscale_frag.frag PostProcessing/depth_downscale_frag.spv)
file(COPY ${PROJECT_BINARY_DIR}/Shaders/VulkanShaders
DESTINATION ${CMAKE_PROGRAM_PATH}/Shaders)
else( iMSTK_USE_Vulkan )
file(COPY ${CMAKE_SOURCE_DIR}/Source/Rendering/VTKRenderer/VTKShaders
DESTINATION ${PROJECT_BINARY_DIR}/Shaders)
file(COPY ${CMAKE_SOURCE_DIR}/Source/Rendering/VTKRenderer/VTKShaders
DESTINATION ${CMAKE_PROGRAM_PATH}/Shaders)
endif()
endfunction()
\ No newline at end of file
......@@ -64,11 +64,17 @@ int main()
scene->addDebugGeometry(debugTriangleGeo);
// Create debug Lines
auto debugLinesGeo = std::make_shared<DebugRenderLines>("debugLines", 2);
auto debugLinesGeo = std::make_shared<DebugRenderLines>("debugLines");
StdVectorOfVec3d linesVerts;
linesVerts.push_back(Vec3d(0, 0, 0));
linesVerts.push_back(Vec3d(100, 100, 100));
linesVerts.push_back(Vec3d(15, 0, 0));
linesVerts.push_back(Vec3d(100, 0, 0));
linesVerts.push_back(Vec3d(0, 15, 0));
linesVerts.push_back(Vec3d(0, 100, 0));
linesVerts.push_back(Vec3d(0, 0, 15));
linesVerts.push_back(Vec3d(0, 0, 100));
debugLinesGeo->setVertexData(linesVerts);
......
......@@ -39,7 +39,7 @@ using namespace imstk;
///
int main()
{
auto sdk = std::make_shared<SimulationManager>(false);
auto sdk = std::make_shared<SimulationManager>(SimulationManager::Mode::runInBackground);
auto scene = sdk->createNewScene("NoRendering");
// Create surface mesh
......
......@@ -27,15 +27,13 @@
using namespace imstk;
const bool runSimWithoutRendering = false;
///
/// \brief This example demonstrates the cloth simulation
/// using Position based dynamics
///
int main()
{
auto sdk = std::make_shared<SimulationManager>(runSimWithoutRendering);
auto sdk = std::make_shared<SimulationManager>();
auto scene = sdk->createNewScene("PBDCloth");
// Create surface mesh
......@@ -130,8 +128,8 @@ int main()
scene->addSceneObject(deformableObj);
// print UPS
auto ups = std::make_shared<UPSCounter>();
apiutils::printUPS(sdk->getSceneManager(scene), ups);
/*auto ups = std::make_shared<UPSCounter>();
apiutils::printUPS(sdk->getSceneManager(scene), ups);*/
scene->getCamera()->setFocalPoint(0, -5, 5);
scene->getCamera()->setPosition(-15., -5.0, 15.0);
......
......@@ -37,7 +37,7 @@ using namespace imstk;
///
int main()
{
auto sdk = std::make_shared<SimulationManager>(0);
auto sdk = std::make_shared<SimulationManager>();
auto scene = sdk->createNewScene("PBDFluid");
scene->getCamera()->setPosition(0, 10.0, 15.0);
......
......@@ -120,8 +120,8 @@ int main()
scene->addLight(light);
// print UPS
auto ups = std::make_shared<UPSCounter>();
apiutils::printUPS(sdk->getSceneManager(scene), ups);
/*auto ups = std::make_shared<UPSCounter>();
apiutils::printUPS(sdk->getSceneManager(scene), ups);*/
sdk->setActiveScene(scene);
sdk->getViewer()->setBackgroundColors(Vec3d(0.3285, 0.3285, 0.6525), Vec3d(0.13836, 0.13836, 0.2748), true);
......
###########################################################################
#
# Copyright (c) Kitware, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0.txt
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
###########################################################################
project(Example-SPHFluid)
#-----------------------------------------------------------------------------
# Create executable
#-----------------------------------------------------------------------------
add_executable(${PROJECT_NAME}-BallDrop SPHFluid-BallDrop.cpp Fluid.cpp Solid.cpp Bunny.cpp)
add_executable(${PROJECT_NAME}-HighViscousity SPHFluid-HighViscousity.cpp Fluid.cpp Solid.cpp Bunny.cpp)
add_executable(${PROJECT_NAME}-BunnyShape SPHFluid-BunnyShape.cpp Fluid.cpp Solid.cpp Bunny.cpp)
# Add Example subdirectories
#-----------------------------------------------------------------------------
macro(listOfSubDir result curdir)
file(GLOB children RELATIVE ${curdir} ${curdir}/*)
set(dirlist "")
foreach(child ${children})
if(IS_DIRECTORY ${curdir}/${child})
list(APPEND dirlist ${child})
endif()
endforeach()
set(${result} ${dirlist})
endmacro()
#-----------------------------------------------------------------------------
# Link libraries to executable
#-----------------------------------------------------------------------------
target_link_libraries(${PROJECT_NAME}-BallDrop SimulationManager)
target_link_libraries(${PROJECT_NAME}-HighViscousity SimulationManager)
target_link_libraries(${PROJECT_NAME}-BunnyShape SimulationManager)
listOfSubDir(subDirs ${CMAKE_CURRENT_SOURCE_DIR})
foreach(subdir ${subDirs})
add_subdirectory(${subdir})
endforeach()
#-----------------------------------------------------------------------------
# Add shaders
#-----------------------------------------------------------------------------
include(imstkCopyAndCompileShaders)
CopyAndCompileShaders()
#-----------------------------------------------------------------------------
# Associate external data
#-----------------------------------------------------------------------------
......@@ -89,21 +89,26 @@ StdVectorOfVec3d generateBoxShapeFluid(const double particleRadius)
return particles;
}
#if SCENE_ID == 3
StdVectorOfVec3d getBunny(); // Defined in Bunny.cpp
#endif
///
/// \brief Generate a bunny-shape fluid object
///
StdVectorOfVec3d generateBunnyShapeFluid(const double particleRadius)
{
LOG_IF(FATAL, (std::abs(particleRadius - 0.08) > 1e-6)) << "Particle radius for this scene must be 0.08";
StdVectorOfVec3d particles = getBunny();
StdVectorOfVec3d particles;
#if SCENE_ID == 3
particles = getBunny();
#endif
return particles;
}
std::shared_ptr<SPHObject> generateFluid(const std::shared_ptr<Scene>&scene, int sceneIdx, const double particleRadius)
std::shared_ptr<SPHObject> generateFluid(const std::shared_ptr<Scene>&scene, const double particleRadius)
{
StdVectorOfVec3d particles;
switch (sceneIdx)
switch (SCENE_ID)
{
case 1:
particles = generateSphereShapeFluid(particleRadius);
......@@ -141,7 +146,7 @@ std::shared_ptr<SPHObject> generateFluid(const std::shared_ptr<Scene>&scene, int
// configure model
auto sphParams = std::make_shared<SPHModelConfig>(particleRadius);
sphParams->m_bNormalizeDensity = true;
if (sceneIdx == 2) // highly viscous fluid
if (SCENE_ID == 2) // highly viscous fluid
{
sphParams->m_RatioKernelOverParticleRadius = 6.0;
sphParams->m_ViscosityFluid = 0.5;
......
###########################################################################
#
# Copyright (c) Kitware, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0.txt
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
###########################################################################
project(Example-SPHFluid-BallDrop)
#-----------------------------------------------------------------------------
# Create executable
#-----------------------------------------------------------------------------
add_executable(${PROJECT_NAME} SPHFluid-BallDrop.cpp)
#-----------------------------------------------------------------------------
# Link libraries to executable
#-----------------------------------------------------------------------------
target_link_libraries(${PROJECT_NAME} SimulationManager)
#-----------------------------------------------------------------------------
# Add shaders
#-----------------------------------------------------------------------------
include(imstkCopyAndCompileShaders)
CopyAndCompileShaders()
#-----------------------------------------------------------------------------
# Associate external data
#-----------------------------------------------------------------------------
......@@ -21,4 +21,4 @@
// Generate a fluid simulation example in with a sphere-shape fluid dropping onto the ground
#define SCENE_ID 1
#include "SPHFluidExample.hpp"
\ No newline at end of file
#include "../SPHFluidExample.hpp"
\ No newline at end of file
###########################################################################
#
# Copyright (c) Kitware, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0.txt
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
###########################################################################
project(Example-SPHFluid-BunnyShape)
#-----------------------------------------------------------------------------
# Create executable
#-----------------------------------------------------------------------------
add_executable(${PROJECT_NAME} SPHFluid-BunnyShape.cpp Bunny.cpp)
#-----------------------------------------------------------------------------
# Link libraries to executable
#-----------------------------------------------------------------------------
target_link_libraries(${PROJECT_NAME} SimulationManager)
#-----------------------------------------------------------------------------
# Add shaders
#-----------------------------------------------------------------------------
include(imstkCopyAndCompileShaders)
CopyAndCompileShaders()
#-----------------------------------------------------------------------------
# Associate external data
#-----------------------------------------------------------------------------
......@@ -21,4 +21,4 @@
// Generate a fluid simulation example in with a bunny-shape fluid dropping onto a box
#define SCENE_ID 3
#include "SPHFluidExample.hpp"
\ No newline at end of file
#include "../SPHFluidExample.hpp"
\ No newline at end of file
###########################################################################
#
# Copyright (c) Kitware, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0.txt
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
###########################################################################
project(Example-SPHFluid-HighViscousity)
#-----------------------------------------------------------------------------
# Create executable
#-----------------------------------------------------------------------------
add_executable(${PROJECT_NAME} SPHFluid-HighViscousity.cpp)
#-----------------------------------------------------------------------------
# Link libraries to executable
#-----------------------------------------------------------------------------
target_link_libraries(${PROJECT_NAME} SimulationManager)
#-----------------------------------------------------------------------------
# Add shaders
#-----------------------------------------------------------------------------
include(imstkCopyAndCompileShaders)
CopyAndCompileShaders()
#-----------------------------------------------------------------------------
# Associate external data
#-----------------------------------------------------------------------------
......@@ -21,4 +21,4 @@
// Generate a fluid simulation example in with a box-shape of highly viscous fluid dropping onto the ground
#define SCENE_ID 2
#include "SPHFluidExample.hpp"
\ No newline at end of file
#include "../SPHFluidExample.hpp"
\ No newline at end of file
......@@ -27,10 +27,10 @@
#include "imstkPlane.h"
#include "imstkSphere.h"
using namespace imstk;
#include "Fluid.hpp"
#include "Solid.hpp"
std::shared_ptr<SPHObject> generateFluid(const std::shared_ptr<Scene>&scene, int sceneIdx, const double particleRadius);
std::vector<std::shared_ptr<CollidingObject>> generateSolids(const std::shared_ptr<Scene>& scene, int sceneIdx);
using namespace imstk;
///
/// \brief Usage: ./SPHFluid [threads=<num_threads>] [radius=<particle_radius>]
......@@ -39,7 +39,7 @@ std::vector<std::shared_ptr<CollidingObject>> generateSolids(const std::shared_p
int main(int argc, char* argv[])
{
// SimulationManager must be created first
auto sdk = std::make_shared<SimulationManager>(0);
auto sdk = std::make_shared<SimulationManager>();
int threads = -1;
double particleRadius = 0.1;
......@@ -77,8 +77,8 @@ int main(int argc, char* argv[])
auto scene = sdk->createNewScene("SPH Fluid");
// Generate fluid and solid objects
auto fluidObj = generateFluid(scene, SCENE_ID, particleRadius);
auto solids = generateSolids(scene, SCENE_ID);
auto fluidObj = generateFluid(scene, particleRadius);
auto solids = generateSolids(scene);
// Collision between fluid and solid objects
auto colGraph = scene->getCollisionGraph();
......
......@@ -227,9 +227,9 @@ std::vector<std::shared_ptr<CollidingObject>> generateSolidsScene3(const std::sh
return solids;
}
std::vector<std::shared_ptr<CollidingObject>> generateSolids(const std::shared_ptr<Scene>& scene, int sceneIdx)
std::vector<std::shared_ptr<CollidingObject>> generateSolids(const std::shared_ptr<Scene>& scene)
{
switch (sceneIdx)
switch (SCENE_ID)
{
case 1:
return generateSolidsScene1(scene);
......
......@@ -19,8 +19,7 @@
=========================================================================*/
#ifndef imstkRenderParticleEmitter_h
#define imstkRenderParticleEmitter_h
#pragma once
#include <memory>
#include <vector>
......@@ -208,5 +207,3 @@ protected:
std::vector<std::unique_ptr<RenderParticle>> * m_particles;
};
} // imstk
#endif // ifndef imstkRenderParticleEmitter_h
......@@ -19,8 +19,7 @@
=========================================================================*/
#ifndef imstkCollisionData_h
#define imstkCollisionData_h
#pragma once
#include <array>
......@@ -169,5 +168,3 @@ public:
std::vector<PickingCollisionData> NodePickData; ///< List of points that are picked
};
}
#endif // ifndef imstkCollisionData_h
......@@ -19,8 +19,7 @@
=========================================================================*/
#ifndef imstkBidirectionalPlaneToSphereCD_h
#define imstkBidirectionalPlaneToSphereCD_h
#pragma once
#include <memory>
......@@ -68,5 +67,3 @@ private:
std::shared_ptr<Sphere> m_sphereB; ///>
};
}
#endif // ifndef imstkBidirectionalPlaneToSphereCD_h
......@@ -19,8 +19,7 @@
=========================================================================*/
#ifndef imstkCollisionDetection_h
#define imstkCollisionDetection_h
#pragma once
#include "imstkCollisionData.h"
......@@ -112,5 +111,3 @@ protected:
std::shared_ptr<CollisionData> m_colData; ///< Collision data
};
}
#endif // ifndef imstkCollisionDetection_h
......@@ -19,8 +19,7 @@
=========================================================================*/
#ifndef imstkIntersectionTestUtils_h
#define imstkIntersectionTestUtils_h
#pragma once
#include <algorithm>
......@@ -158,5 +157,3 @@ testPointToTriAABB(const double& x1, const double& y1, const double& z1,
min_y - prox2, max_y + prox2, min_z - prox2, max_z + prox2);
}
}
#endif // ifndef imstkIntersectionTestUtils_h
......@@ -19,8 +19,7 @@
=========================================================================*/
#ifndef imstkMeshToMeshBruteforceCD_h
#define imstkMeshToMeshBruteforceCD_h
#pragma once
#include <memory>
#include <iostream>
......@@ -75,5 +74,3 @@ private:
std::shared_ptr<SurfaceMesh> m_object2; ///> object 2
};
}
#endif // ifndef imstkMeshToMeshBruteForceCD_h
......@@ -19,8 +19,7 @@
=========================================================================*/
#ifndef imstkMeshToMeshCD_h
#define imstkMeshToMeshCD_h
#pragma once
// std library
#include <memory>
......@@ -85,5 +84,3 @@ private:
std::shared_ptr<DeformModel> m_modelB; ///>
};
}
#endif // ifndef imstkMeshToMeshCD_h
......@@ -19,8 +19,7 @@
=========================================================================*/
#ifndef imstkPointSetToCapsuleCD_h
#define imstkPointSetToCapsuleCD_h
#pragma once
#include <memory>
......@@ -64,5 +63,3 @@ private:
std::shared_ptr<Capsule> m_capsule; ///> Capsule
};
}
#endif // ifndef imstkPointSetToCapsuleCD_h
......@@ -19,8 +19,7 @@
=========================================================================*/
#ifndef imstkPointSetToPlaneCD_h
#define imstkPointSetToPlaneCD_h
#pragma once
#include <memory>
......@@ -64,5 +63,3 @@ private:
std::shared_ptr<Plane> m_plane; ///> Plane
};
}
#endif // ifndef imstkPointSetToPlaneCD_h
......@@ -19,8 +19,7 @@
=========================================================================*/
#ifndef imstkPointSetToSphereCD_h
#define imstkPointSetToSphereCD_h
#pragma once
#include <memory>
......@@ -64,5 +63,3 @@ private:
std::shared_ptr<Sphere> m_sphere; ///> Sphere
};
}
#endif // ifndef imstkPointSetToSphereCD_h
......@@ -19,8 +19,7 @@
=========================================================================*/
#ifndef imstkPointSetToSpherePickingCD_h
#define imstkPointSetToSpherePickingCD_h
#pragma once
#include <memory>
......@@ -73,5 +72,3 @@ private:
unsigned int m_buttonId = 0; ///> button id
};
}