-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87f8dc8
commit 6225989
Showing
10 changed files
with
223 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,46 @@ | ||
cmake_minimum_required(VERSION 3.26) | ||
|
||
project(SIM_PBF) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(TARGET SIM_PBFSolver) | ||
|
||
# Find Houdini | ||
set(Houdini_PATH "C:/Program Files/Side Effects Software/Houdini 20.0.547") | ||
set(Houdini_DIR ${Houdini_PATH}/toolkit/cmake) | ||
find_package(Houdini REQUIRED) | ||
|
||
# Load Source | ||
add_library( | ||
${TARGET} | ||
SHARED | ||
Entrance.cpp | ||
SIM_PBF.cpp | ||
SIM_PBF.h | ||
|
||
src/solver.cpp | ||
src/solver.h | ||
src/utils.cpp | ||
src/utils.h | ||
src/data.cpp | ||
src/data.h | ||
) | ||
|
||
# Link Houdini Toolkit | ||
target_link_libraries( | ||
${TARGET} | ||
PUBLIC | ||
Houdini | ||
) | ||
target_link_directories( | ||
${TARGET} | ||
PUBLIC | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
target_include_directories( | ||
${TARGET} | ||
PUBLIC | ||
${CMAKE_CURRENT_BINARY_DIR} | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
houdini_configure_target(${TARGET}) |
This file contains 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,8 @@ | ||
#include <UT/UT_DSOVersion.h> // Very Important!!! Include this!!! | ||
|
||
#include "SIM_PBF.h" | ||
|
||
void initializeSIM(void *) | ||
{ | ||
IMPLEMENT_DATAFACTORY(SIM_PBFSolver); | ||
} |
This file contains 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,40 @@ | ||
#include "SIM_PBF.h" | ||
|
||
#include <PRM/PRM_Name.h> | ||
#include <PRM/PRM_Template.h> | ||
#include <PRM/PRM_Shared.h> | ||
#include <PRM/PRM_Default.h> | ||
|
||
#include <SIM/SIM_Engine.h> | ||
#include <SIM/SIM_Object.h> | ||
#include <SIM/SIM_ObjectArray.h> | ||
#include <SIM/SIM_PositionSimple.h> | ||
#include <SIM/SIM_GeometryCopy.h> | ||
|
||
SIM_Solver::SIM_Result SIM_PBFSolver::solveSingleObjectSubclass(SIM_Engine &engine, SIM_Object &object, SIM_ObjectArray &feedbacktoobjects, const SIM_Time ×tep, bool newobject) | ||
{ | ||
static bool NeedReBuild = true; | ||
|
||
if (NeedReBuild || newobject) | ||
{ | ||
NeedReBuild = false; | ||
return SIM_SOLVER_SUCCESS; | ||
} | ||
|
||
return SIM_Solver::SIM_SOLVER_SUCCESS; | ||
} | ||
|
||
const SIM_DopDescription *SIM_PBFSolver::GetDescription() | ||
{ | ||
static std::array<PRM_Template, 1> PRMS{ | ||
PRM_Template() | ||
}; | ||
|
||
static SIM_DopDescription DESC(true, | ||
"pbf_solver", | ||
"PBF Solver", | ||
"PBFSolver", | ||
classname(), | ||
PRMS.data()); | ||
return &DESC; | ||
} |
This file contains 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,21 @@ | ||
#ifndef HINAPE_SIM_PBF_H | ||
#define HINAPE_SIM_PBF_H | ||
|
||
#include <SIM/SIM_SingleSolver.h> | ||
#include <SIM/SIM_OptionsUser.h> | ||
#include <SIM/SIM_DopDescription.h> | ||
#include <SIM/SIM_Utils.h> | ||
|
||
class SIM_PBFSolver : public SIM_SingleSolver, public SIM_OptionsUser | ||
{ | ||
private: | ||
SIM_PBFSolver(const SIM_DataFactory *factory) : SIM_SingleSolver(factory), SIM_OptionsUser(this) {} | ||
~SIM_PBFSolver() override = default; | ||
SIM_Result solveSingleObjectSubclass(SIM_Engine &engine, SIM_Object &object, SIM_ObjectArray &feedbacktoobjects, const SIM_Time ×tep, bool newobject) override; | ||
static const SIM_DopDescription* GetDescription(); | ||
|
||
DECLARE_STANDARD_GETCASTTOTYPE(); | ||
DECLARE_DATAFACTORY(SIM_PBFSolver, SIM_SingleSolver, "PBF Solver Description", GetDescription()); | ||
}; | ||
|
||
#endif //HINAPE_SIM_PBF_H |
This file contains 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 @@ | ||
#include "data.h" |
This file contains 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,28 @@ | ||
#ifndef SIM_PBF_DATA_H | ||
#define SIM_PBF_DATA_H | ||
|
||
#include <vector> | ||
|
||
namespace HinaPE_PBF | ||
{ | ||
using real = float; | ||
using size = int32_t; | ||
|
||
struct PBF_DATA | ||
{ | ||
// Sim Data | ||
std::vector<real> positions; | ||
std::vector<real> positions_predicted; | ||
std::vector<real> velocities; | ||
std::vector<real> forces; | ||
std::vector<real> mass; | ||
std::vector<real> inv_mass; | ||
|
||
// State Data | ||
std::vector<real> densities; | ||
std::vector<real> lambdas; | ||
std::vector<real> delta_p; | ||
}; | ||
} | ||
|
||
#endif //SIM_PBF_DATA_H |
This file contains 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,6 @@ | ||
#include "solver.h" | ||
|
||
void InitPBFData(HinaPE_PBF::PBF_DATA &data, const GU_Detail &gdp) | ||
{ | ||
|
||
} |
This file contains 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,9 @@ | ||
#ifndef SIM_PBF_SOLVER_H | ||
#define SIM_PBF_SOLVER_H | ||
|
||
#include "data.h" | ||
|
||
#include <GU/GU_Detail.h> | ||
void InitPBFData(HinaPE_PBF::PBF_DATA &data, const GU_Detail &gdp); | ||
|
||
#endif //SIM_PBF_SOLVER_H |
This file contains 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,10 @@ | ||
#include "utils.h" | ||
|
||
void SyncParticlePositionFromGDP(HinaPE_PBF::PBF_DATA &data, const GU_Detail &gdp) | ||
{ | ||
|
||
} | ||
void SyncGDPFromParticlePosition(GU_Detail &gdp, const HinaPE_PBF::PBF_DATA &data) | ||
{ | ||
|
||
} |
This file contains 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,54 @@ | ||
#ifndef SIM_PBF_UTILS_H | ||
#define SIM_PBF_UTILS_H | ||
|
||
#include "data.h" | ||
#include <GU/GU_Detail.h> | ||
|
||
namespace HinaPE_PBF | ||
{ | ||
template<typename T, typename Prim> | ||
struct ArrayHandle | ||
{ | ||
ArrayHandle(T *_internal) : internal(_internal) {} | ||
~ArrayHandle() = default; | ||
|
||
virtual Prim get(int off) const = 0; | ||
virtual void set(int off, Prim p) = 0; | ||
|
||
T *internal; | ||
}; | ||
|
||
template<typename T, typename Prim> | ||
struct ConstArrayHandle | ||
{ | ||
ConstArrayHandle(ArrayHandle<T, Prim> *_internal) : internal(_internal) {} | ||
~ConstArrayHandle() = default; | ||
|
||
Prim get(int off) const { return internal->get(off); } | ||
|
||
ArrayHandle<T, Prim> *internal; | ||
}; | ||
|
||
struct NativeVector3Handle : public ArrayHandle<std::vector<real>, UT_Vector3T<real>> | ||
{ | ||
NativeVector3Handle(std::vector<real> *_internal) : ArrayHandle(_internal) {} | ||
~NativeVector3Handle() = default; | ||
|
||
UT_Vector3T<real> get(int off) const override { return UT_Vector3T<real>(internal->data() + off * 3); } | ||
void set(int off, UT_Vector3T<real> p) override { memcpy(internal->data() + off * 3, p.data(), sizeof(real) * 3); } | ||
}; | ||
|
||
struct GDPVector3Handle : public ArrayHandle<GU_Detail, UT_Vector3T<real>> | ||
{ | ||
GDPVector3Handle(GU_Detail *gdp) : ArrayHandle(gdp) {} | ||
~GDPVector3Handle() = default; | ||
|
||
UT_Vector3T<real> get(int off) const override { return internal->getPos3(off); } | ||
void set(int off, UT_Vector3T<real> p) override { internal->setPos3(off, p); } | ||
}; | ||
} | ||
|
||
void SyncParticlePositionFromGDP(HinaPE_PBF::PBF_DATA &data, const GU_Detail &gdp); | ||
void SyncGDPFromParticlePosition(GU_Detail &gdp, const HinaPE_PBF::PBF_DATA &data); | ||
|
||
#endif //SIM_PBF_UTILS_H |