Skip to content

Commit b12320e

Browse files
committed
- all scene file parameters are now GenericParameters
- updated Python examples - added ParameterParser tool which can generate a scene file json schema or an example scene file with all parameters - added json schema for scene files - fixed OBJ meshes - updated glfw - updated pybind11
1 parent cb81904 commit b12320e

File tree

193 files changed

+49332
-25503
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

193 files changed

+49332
-25503
lines changed

CMake/DataCopyTargets.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ add_dependencies(CopyPBDShaders Ext_PBD)
2424
set_target_properties(CopyPBDShaders PROPERTIES FOLDER "Data copy")
2525

2626
add_custom_target(CopyImguiFonts
27-
${CMAKE_COMMAND} -E copy
28-
${PROJECT_SOURCE_DIR}/extern/imgui/misc/fonts/Roboto-Medium.ttf
29-
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/resources/fonts/Roboto-Medium.ttf
27+
${CMAKE_COMMAND} -E copy_directory
28+
${PROJECT_SOURCE_DIR}/extern/imgui/misc/fonts
29+
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/resources/fonts
3030
COMMENT "Copying fonts"
3131
)
32-
set_target_properties(CopyImguiFonts PROPERTIES FOLDER "Data copy")
32+
set_target_properties(CopyImguiFonts PROPERTIES FOLDER "Data copy")

CMake/SetUpExternalProjects.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ExternalProject_Add(
3333
Ext_GenericParameters
3434
PREFIX "${CMAKE_BINARY_DIR}/extern/GenericParameters"
3535
GIT_REPOSITORY https://github.com/InteractiveComputerGraphics/GenericParameters.git
36-
GIT_TAG "89ae733fb8b8b9df25d0e44a0e49e51136901e8c"
36+
GIT_TAG "42d52ad551fafba600ee99e59fb0f9c7b557e2ed"
3737
INSTALL_DIR ${ExternalInstallDir}/GenericParameters
3838
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${EXT_CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=${ExternalInstallDir}/GenericParameters -DGENERICPARAMETERS_NO_TESTS:BOOL=1 -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
3939
)
@@ -47,7 +47,7 @@ ExternalProject_Add(
4747
Ext_PBD
4848
PREFIX "${CMAKE_BINARY_DIR}/extern/PositionBasedDynamics"
4949
GIT_REPOSITORY https://github.com/InteractiveComputerGraphics/PositionBasedDynamics.git
50-
GIT_TAG "544cc0cba4db8cabe2217cd48b87fb095848ea92"
50+
GIT_TAG "06e18ba4c1fab9401a494f5479e026641467f22e"
5151
INSTALL_DIR ${ExternalInstallDir}/PositionBasedDynamics
5252
DEPENDS Ext_GenericParameters Ext_Discregrid
5353
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${EXT_CMAKE_BUILD_TYPE}

Changelog.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2.12.1
2+
- all scene file parameters are now GenericParameters
3+
- updated Python examples
4+
- added ParameterParser tool which can generate a scene file json schema or an example scene file with all parameters
5+
- added json schema for scene files
6+
- fixed OBJ meshes
7+
- updated glfw
8+
- updated pybind11
9+
110
2.12.0
211
- added PLY exporter
312
- improved the DFSPH implementation significantly

GUI/OpenGL/MiniGL.cpp

Lines changed: 71 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ std::vector<MiniGL::MousePressFct> MiniGL::m_mousePressFct;
7070
std::vector<MiniGL::MouseMoveFct> MiniGL::m_mouseMoveFct;
7171
std::vector<MiniGL::MouseWheelFct> MiniGL::m_mouseWheelFct;
7272
GLFWwindow* MiniGL::m_glfw_window = nullptr;
73+
bool MiniGL::m_vsync = false;
74+
double MiniGL::m_lastTime;
7375

7476
void MiniGL::bindTexture()
7577
{
@@ -468,14 +470,15 @@ void MiniGL::setClientSceneFunc (SceneFct func)
468470
scenefunc = func;
469471
}
470472

471-
void MiniGL::init(int argc, char **argv, const int width, const int height, const char *name)
473+
void MiniGL::init(const int width, const int height, const char *name, const bool vsync, const bool maximized)
472474
{
473475
fovy = 60;
474476
znear = 0.5f;
475477
zfar = 1000;
476478

477479
m_width = width;
478480
m_height = height;
481+
m_vsync = vsync;
479482

480483
scenefunc = nullptr;
481484

@@ -488,7 +491,13 @@ void MiniGL::init(int argc, char **argv, const int width, const int height, cons
488491
//glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
489492
//glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
490493

491-
//glfwWindowHint(GLFW_DOUBLEBUFFER, GL_FALSE);
494+
if (maximized)
495+
glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE);
496+
497+
if (m_vsync)
498+
glfwWindowHint(GLFW_DOUBLEBUFFER, GL_TRUE);
499+
else
500+
glfwWindowHint(GLFW_DOUBLEBUFFER, GL_FALSE);
492501
m_glfw_window = glfwCreateWindow(width, height, name, NULL, NULL);
493502
if (!m_glfw_window)
494503
{
@@ -525,6 +534,8 @@ void MiniGL::init(int argc, char **argv, const int width, const int height, cons
525534
glfwSetScrollCallback(m_glfw_window, mouseWheel);
526535

527536
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
537+
538+
m_lastTime = glfwGetTime();
528539
}
529540

530541
void MiniGL::initTexture()
@@ -604,12 +615,12 @@ void MiniGL::setClientDestroyFunc(DestroyFct func)
604615
destroyfunc = func;
605616
}
606617

607-
void MiniGL::addKeyFunc (unsigned char k, std::function<void()> const& func)
618+
void MiniGL::addKeyFunc(int key, int modifiers, std::function<void()> const& func)
608619
{
609620
if (func == nullptr)
610621
return;
611622
else
612-
keyfunc.push_back({ func, k });
623+
keyfunc.push_back({ func, key, modifiers });
613624
}
614625

615626
void MiniGL::keyboard(GLFWwindow* window, int key, int scancode, int action, int mods)
@@ -621,6 +632,13 @@ void MiniGL::keyboard(GLFWwindow* window, int key, int scancode, int action, int
621632
return;
622633
}
623634

635+
// execute user key functions
636+
for (int i = 0; i < keyfunc.size(); i++)
637+
{
638+
if ((key == keyfunc[i].key) && (mods == keyfunc[i].modifiers) && (action == GLFW_PRESS))
639+
keyfunc[i].fct();
640+
}
641+
624642
if (key == GLFW_KEY_ESCAPE)
625643
{
626644
m_breakPointLoop = false;
@@ -657,19 +675,14 @@ void MiniGL::char_callback(GLFWwindow* window, unsigned int codepoint)
657675
return;
658676
}
659677

660-
for (int i = 0; i < keyfunc.size(); i++)
661-
{
662-
if (codepoint == keyfunc[i].key)
663-
keyfunc[i].fct();
664-
else if (codepoint == GLFW_KEY_1)
665-
rotateX(-turnspeed);
666-
else if (codepoint == GLFW_KEY_2)
667-
rotateX(turnspeed);
668-
else if (codepoint == GLFW_KEY_3)
669-
rotateY(-turnspeed);
670-
else if (codepoint == GLFW_KEY_4)
671-
rotateY(turnspeed);
672-
}
678+
if (codepoint == GLFW_KEY_1)
679+
rotateX(-turnspeed);
680+
else if (codepoint == GLFW_KEY_2)
681+
rotateX(turnspeed);
682+
else if (codepoint == GLFW_KEY_3)
683+
rotateY(-turnspeed);
684+
else if (codepoint == GLFW_KEY_4)
685+
rotateY(turnspeed);
673686
}
674687

675688
void MiniGL::setProjectionMatrix (int width, int height)
@@ -964,8 +977,8 @@ void MiniGL::drawSelectionRect()
964977
glOrtho(0.0f, m_width, m_height, 0.0f, -1.0f, 1.0f);
965978
glBegin(GL_LINE_LOOP);
966979
glColor3f(1, 0, 0); //Set the colour to red
967-
glVertex2f(m_selectionStart[0], m_selectionStart[1]);
968-
glVertex2f(m_selectionStart[0], mouse_pos_y_old);
980+
glVertex2f(static_cast<GLfloat>(m_selectionStart[0]), static_cast<GLfloat>(m_selectionStart[1]));
981+
glVertex2f(static_cast<GLfloat>(m_selectionStart[0]), static_cast<GLfloat>(mouse_pos_y_old));
969982
glVertex2f(mouse_pos_x_old, mouse_pos_y_old);
970983
glVertex2f(mouse_pos_x_old, m_selectionStart[1]);
971984
glEnd();
@@ -980,22 +993,30 @@ void MiniGL::mainLoop()
980993
{
981994
while (!glfwWindowShouldClose(m_glfw_window))
982995
{
983-
glfwPollEvents();
984-
985996
if (idlefunc != nullptr)
986997
idlefunc();
987998

988-
glPolygonMode(GL_FRONT_AND_BACK, drawMode);
989-
viewport();
999+
double currentTime = glfwGetTime();
1000+
if (currentTime - m_lastTime >= 1.0 / 60.0) // render at maximum at 60 fps
1001+
{
1002+
glfwPollEvents();
1003+
1004+
glPolygonMode(GL_FRONT_AND_BACK, drawMode);
1005+
viewport();
1006+
1007+
if (scenefunc != nullptr)
1008+
scenefunc();
9901009

991-
if (scenefunc != nullptr)
992-
scenefunc();
1010+
if (selectionMode)
1011+
drawSelectionRect();
9931012

994-
if (selectionMode)
995-
drawSelectionRect();
1013+
if (m_vsync)
1014+
glfwSwapBuffers(m_glfw_window);
1015+
else
1016+
glFlush();
9961017

997-
glfwSwapBuffers(m_glfw_window);
998-
//glFlush();
1018+
m_lastTime = currentTime;
1019+
}
9991020
}
10001021

10011022
if (destroyfunc != nullptr)
@@ -1015,8 +1036,10 @@ void MiniGL::leaveMainLoop()
10151036

10161037
void MiniGL::swapBuffers()
10171038
{
1018-
glfwSwapBuffers(m_glfw_window);
1019-
//glFlush();
1039+
if (m_vsync)
1040+
glfwSwapBuffers(m_glfw_window);
1041+
else
1042+
glFlush();
10201043
}
10211044

10221045
void MiniGL::getWindowPos(int &x, int &y)
@@ -1039,6 +1062,19 @@ void MiniGL::setWindowSize(int w, int h)
10391062
glfwSetWindowSize(m_glfw_window, w, h);
10401063
}
10411064

1065+
bool MiniGL::getWindowMaximized()
1066+
{
1067+
return glfwGetWindowAttrib(m_glfw_window, GLFW_MAXIMIZED);
1068+
}
1069+
1070+
void MiniGL::setWindowMaximized(const bool b)
1071+
{
1072+
if (b)
1073+
glfwRestoreWindow(m_glfw_window);
1074+
else
1075+
glfwRestoreWindow(m_glfw_window);
1076+
}
1077+
10421078
void MiniGL::breakPointMainLoop()
10431079
{
10441080
if (m_breakPointActive)
@@ -1052,8 +1088,10 @@ void MiniGL::breakPointMainLoop()
10521088
if (scenefunc != nullptr)
10531089
scenefunc();
10541090

1055-
glfwSwapBuffers(m_glfw_window);
1056-
//glFlush();
1091+
if (m_vsync)
1092+
glfwSwapBuffers(m_glfw_window);
1093+
else
1094+
glFlush();
10571095
glfwPollEvents();
10581096
}
10591097
}

GUI/OpenGL/MiniGL.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ namespace SPH
6363
struct KeyFunction
6464
{
6565
std::function<void()> fct;
66-
unsigned char key;
66+
int key;
67+
int modifiers;
6768
};
6869

6970
typedef std::function<void()> SceneFct;
@@ -119,6 +120,8 @@ namespace SPH
119120
static bool m_breakPointLoop;
120121
static GLUquadricObj* m_sphereQuadric;
121122
static GLFWwindow* m_glfw_window;
123+
static bool m_vsync;
124+
static double m_lastTime;
122125

123126
static void reshape (GLFWwindow* glfw_window, int w, int h);
124127
static void keyboard(GLFWwindow* window, int key, int scancode, int action, int mods);
@@ -153,9 +156,9 @@ namespace SPH
153156
static void setClientSceneFunc (SceneFct func);
154157
static void setClientIdleFunc (IdleFct func);
155158
static void setClientDestroyFunc(DestroyFct func);
156-
static void addKeyFunc(unsigned char k, std::function<void()> const& func);
159+
static void addKeyFunc(int key, int modifiers, std::function<void()> const& func);
157160
static std::vector<KeyFunction> &getKeyFunc() { return keyfunc; }
158-
static void init(int argc, char **argv, const int width, const int height, const char *name);
161+
static void init(const int width, const int height, const char* name, const bool vsync, const bool maximized = false);
159162
static void destroy ();
160163
static void viewport ();
161164
static void initLights ();
@@ -176,6 +179,7 @@ namespace SPH
176179
static void hsvToRgb(float h, float s, float v, float *rgb);
177180
static void rgbToHsv(float r, float g, float b, float *hsv);
178181
static int getModifierKey() { return modifier_key; }
182+
static bool getVSync() { return m_vsync; }
179183

180184
static void addReshapeFunc(ReshapeFct func) { m_reshapeFct.push_back(func); }
181185
static std::vector<ReshapeFct> &getReshapeFunc() { return m_reshapeFct; }
@@ -211,6 +215,8 @@ namespace SPH
211215
static void getWindowSize(int& w, int& h);
212216
static void setWindowPos(int x, int y);
213217
static void setWindowSize(int w, int h);
218+
static bool getWindowMaximized();
219+
static void setWindowMaximized(const bool b);
214220
};
215221
}
216222

GUI/imgui/imguiParameters.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,6 @@ void imguiParameters::createSubgroupParameters(const std::vector<std::pair<std::
243243

244244
void imguiParameters::createParameterGUI()
245245
{
246-
//struct Comparator {
247-
// bool operator()(std::pair<std::string, std::vector<std::pair<std::string, std::vector<imguiParameters::imguiParameter*>>>>& p1,
248-
// std::pair<std::string, std::vector<std::pair<std::string, std::vector<imguiParameters::imguiParameter*>>>>& p2)
249-
// {
250-
// return p1.first.compare(p2.first) < 0;
251-
// }
252-
//};
253-
//std::sort(m_imguiParams.begin(), m_imguiParams.end(), Comparator());
254-
255246
// always show "General"
256247
for (auto group_index = 0; group_index < m_imguiParams.size(); group_index++)
257248
{
@@ -302,6 +293,10 @@ void imguiParameters::createParameterObjectGUI(ParameterObject* paramObj)
302293
for (unsigned int i = 0; i < numParams; i++)
303294
{
304295
ParameterBase* paramBase = paramObj->getParameter(i);
296+
297+
if (!paramBase->getVisible())
298+
continue;
299+
305300
std::string group = paramBase->getGroup();
306301
std::string subgroup = "";
307302

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ For Windows and Linux targets there exists prebuilt python wheel files which can
5555
```
5656
pip install pysplishsplash
5757
```
58-
These are available for Python Versions: 2.7, 3.5, 3.6, 3.7, 3.8.
58+
These are available for Python Versions. See also here: [pySPlisHSPlasH](https://pypi.org/project/pySPlisHSPlasH/).
5959
If you do not meet these conditions please refer to the build instructions and to the python binding
6060
[Getting started guide](https://github.com/InteractiveComputerGraphics/SPlisHSPlasH/blob/master/doc/py_getting_started.md).
6161

SPlisHSPlasH/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,13 @@ set(UTILS_HEADER_FILES
149149
Utilities/MathFunctions.h
150150
Utilities/GaussQuadrature.h
151151
Utilities/MatrixFreeSolver.h
152+
Utilities/MeshImport.h
152153
Utilities/SurfaceSampling.h
153154
Utilities/PoissonDiskSampling.h
154155
Utilities/RegularTriangleSampling.h
155156
Utilities/RegularSampling2D.h
156157
Utilities/SceneLoader.h
158+
Utilities/SceneParameterObjects.h
157159
Utilities/SceneWriter.h
158160
Utilities/VolumeSampling.h
159161
Utilities/SDFFunctions.h
@@ -166,10 +168,12 @@ set(UTILS_SOURCE_FILES
166168
Utilities/DebugTools.cpp
167169
Utilities/MathFunctions.cpp
168170
Utilities/GaussQuadrature.cpp
171+
Utilities/MeshImport.cpp
169172
Utilities/PoissonDiskSampling.cpp
170173
Utilities/RegularTriangleSampling.cpp
171174
Utilities/RegularSampling2D.cpp
172175
Utilities/SceneLoader.cpp
176+
Utilities/SceneParameterObjects.cpp
173177
Utilities/SceneWriter.cpp
174178
Utilities/VolumeSampling.cpp
175179
Utilities/SDFFunctions.cpp

0 commit comments

Comments
 (0)