40 using namespace HDK_Sample;
48 namespace HDK_Sample {
54 #if defined(HOUDINI_11)
59 const GB_AttributeRef &massoffset,
60 const GB_AttributeRef &veloffset);
72 const char *
name)
override;
97 , myTimestep(timestep)
98 , myMassHandle(masshandle)
99 , myVelHandle(velhandle)
114 force->
getPointForces(*
this, myObject, gdh, myTransform, 0, 0,
false);
122 float mass = myMassHandle.
get(ptoff);
123 myVelHandle.
set(ptoff, myVelHandle.
get(ptoff) + (force/
mass)*myTimestep);
127 : BaseClass(factory),
137 SIM_SolverHair::getSolverHairDopDescription()
150 return &theDopDescription;
164 for (
exint geonum = 0; geonum < srcobjs.
entries(); geonum++)
166 const SIM_Object *sourceobj = srcobjs(geonum);
172 const GU_Detail *sourcegdp = sourcegdl.getGdp();
176 #if defined(HOUDINI_11)
178 const float one = 1.0;
181 sizeof(
float), GB_ATTRIB_FLOAT, &one);
198 masshandle, velhandle);
199 object.forEachConstSubData(callback,
229 UT_Vector3 startpos = sourcegdp->getPos3(sourceptoff);
230 startpos *= sourcexform;
244 velhandle.
set(hairpt0off, vel);
247 for (
int ptnum = 1; ptnum < 10; ptnum++)
256 dp = midline * (0.1 / midline.
length()) +
259 vel = velhandle.
get(hairpt1off);
263 velhandle.
set(hairpt1off, vel);
265 hairpt0off = hairpt1off;
266 hairpt1off = hairpt2off;
281 for (
exint geonum = 0; geonum < srcobjs.
entries(); geonum++)
283 const SIM_Object *sourceobj = srcobjs(geonum);
289 const GU_Detail *sourcegdp = sourcegdl.getGdp();
296 UT_Vector4 startpos = sourcegdp->getPos4(sourceptoff);
297 startpos *= sourcexform;
299 for (
int i = 0; i < 10; i++)
303 startpos.
y() + (
fpreal)i * 0.1,
327 object.getAffectors(sourceobjects,
"SIM_RelationshipSource");
328 if( hairgeo && sourceobjects.
entries() > 0 )
337 object.getAffectors(sourceobjects,
"SIM_RelationshipSource");
338 if( hairgeo && sourceobjects.
entries() > 0 )
339 solveHair(*hairgeo, sourceobjects,
object, timestep);
#define SIM_FORCES_DATANAME
virtual void createHairFromSource(SIM_GeometryCopy &hairgeo, const SIM_ObjectArray &srcobjs) const
virtual void solveHair(SIM_GeometryCopy &hairgeo, const SIM_ObjectArray &srcobjs, const SIM_Object &object, const SIM_Time ×tep) const
SYS_FORCE_INLINE GA_Attribute * addPointAttrib(const GA_Attribute *src)
#define SIM_DATA_CASTCONST(Data, DataClass)
SYS_FORCE_INLINE GA_Offset getPointOffset(GA_Size i) const
SYS_FORCE_INLINE GA_Size getVertexCount() const
Return the number of vertices used by this primitive.
SIM_SolverHair(const SIM_DataFactory *factory)
void getTransform(UT_DMatrix4 &xform) const
Iteration over a range of elements.
bool setTypeInfo(GA_TypeInfo info)
Set type information on the attribute.
#define IMPLEMENT_DATAFACTORY(DataClass)
Class which stores the default values for a GA_Attribute.
GA_Attribute * addFloatTuple(GA_AttributeOwner owner, GA_AttributeScope scope, const UT_StringHolder &name, int tuple_size, const GA_Defaults &defaults=GA_Defaults(0.0), const UT_Options *creation_args=0, const GA_AttributeOptions *attribute_options=0, GA_Storage storage=GA_STORE_REAL32, const GA_ReuseStrategy &reuse=GA_ReuseStrategy())
constexpr SYS_FORCE_INLINE T & y() noexcept
void initializeSIM(void *)
UT_Vector3T< float > UT_Vector3
SIM_API const UT_StringHolder torque
SYS_FORCE_INLINE const GA_PrimitiveTypeId & getTypeId() const
~SIM_SolverHair() override
**But if you need a or simply need to know when the task has note that the like this
constexpr SYS_FORCE_INLINE T length() const noexcept
SYS_FORCE_INLINE UT_Vector3 getPos3(GA_Offset ptoff) const
The ptoff passed is the point offset.
void getPointForces(SIM_PointForceCallback &cb, const SIM_Object &object, const GU_ConstDetailHandle &gdh, const UT_DMatrix4 &geoxform, const SIM_Position *position, const SIM_Motion *motion, bool forcesinworldspace) const
constexpr SYS_FORCE_INLINE T & x() noexcept
void allocateAndSet(GU_Detail *gdp, bool own=true)
SIM_HairForceCallback(GU_Detail &gdp, const SIM_Object &object, const UT_DMatrix4 &xform, fpreal timestep, const GA_RWHandleF &masshandle, const GA_RWHandleV3 &velhandle)
This class provides a way to manage a reference to an attribute permitting Read-Write access...
void forceCallbackOffset(GA_Offset ptoff, const UT_Vector3 &force, const UT_Vector3 &torque) override
IMATH_NAMESPACE::V2f float
static GU_PrimPoly * build(GA_Detail *gdp, int npts, int open=0, int appendpts=1)
GA_Size appendVertex(GA_Offset ptoff) override
constexpr SYS_FORCE_INLINE T & z() noexcept
Holds pointers to a number of SIM_Object objects.
#define SIM_DATA_GET(Parent, DataName, DataClass)
const SIM_Geometry * getGeometry() const
#define SIM_SOLVER_DATANAME
SYS_FORCE_INLINE T get(GA_Offset off, int comp=0) const
~SIM_HairForceCallback() override
GLuint const GLchar * name
#define GA_FOR_ALL_PTOFF(gdp, ptoff)
SIM_Result solveSingleObjectSubclass(SIM_Engine &engine, SIM_Object &object, SIM_ObjectArray &feedbacktoobjects, const SIM_Time ×tep, bool newobject) override
GA_API const UT_StringHolder mass
SYS_FORCE_INLINE GA_Offset appendPointOffset()
SYS_FORCE_INLINE const GA_Primitive * get(GA_Offset off) const
SYS_FORCE_INLINE void setPos3(GA_Offset ptoff, const UT_Vector3 &pos)
Set P from a UT_Vector3.
SIM_API const UT_StringHolder force
#define SIM_GEOMETRY_DATANAME
This filter rejects all data.
SYS_FORCE_INLINE void set(GA_Offset off, const T &val) const
UT_StringHolder getStdAttributeName(GEO_Standard_Attributes name, int layer=-1) const
GU_ConstDetailHandle getGeometry() const
Data represents a direction vector. Token "vector".
const GA_PrimitiveList & getPrimitiveList() const
SIM_API void SIMgetGeometryTransform(UT_DMatrix4 &result, const SIM_Object &)
This class is used for callbacks from SIM_Force::getPointForces().
GA_Range getPrimitiveRange(const GA_PrimitiveGroup *group=0) const
Get a range of all primitives in the detail.
ImageBuf OIIO_API zero(ROI roi, int nthreads=0)
#define SIM_DATA_CREATE(Parent, DataName, DataClass, Flags)
void callbackConst(const SIM_Data *data, const char *name) override
This implements a SIM_Geometry that copies the source geometry.