more rope API hooray
parent
60de61552e
commit
e72f70ae16
|
@ -1401,10 +1401,72 @@ double Silkworm_RopeNearestY(double ropeId, double xPosition, double yPosition)
|
||||||
return nearestY;
|
return nearestY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double Silkworm_RopeNodeCount(double ropeId)
|
||||||
|
{
|
||||||
|
Silkworm_Rope* rope = LookupRope(ropeId);
|
||||||
|
|
||||||
|
if (rope != NULL)
|
||||||
|
{
|
||||||
|
return rope->nodeCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
double Silkworm_RopeNodeXPosition(double ropeId, double nodeIndex)
|
||||||
|
{
|
||||||
|
Silkworm_Rope *rope = LookupRope(ropeId);
|
||||||
|
|
||||||
|
if (rope != NULL && nodeIndex < rope->nodeCount)
|
||||||
|
{
|
||||||
|
return rope->nodes[(uint32_t)nodeIndex]->position.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -99999999999;
|
||||||
|
}
|
||||||
|
|
||||||
|
double Silkworm_RopeNodeYPosition(double ropeId, double nodeIndex)
|
||||||
|
{
|
||||||
|
Silkworm_Rope* rope = LookupRope(ropeId);
|
||||||
|
|
||||||
|
if (rope != NULL && nodeIndex < rope->nodeCount)
|
||||||
|
{
|
||||||
|
return rope->nodes[(uint32_t)nodeIndex]->position.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -99999999999;
|
||||||
|
}
|
||||||
|
|
||||||
|
double Silkworm_RopeNodeXSpeed(double ropeId, double nodeIndex)
|
||||||
|
{
|
||||||
|
Silkworm_Rope* rope = LookupRope(ropeId);
|
||||||
|
|
||||||
|
if (rope != NULL && nodeIndex < rope->nodeCount)
|
||||||
|
{
|
||||||
|
return rope->nodes[(uint32_t)nodeIndex]->velocity.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double Silkworm_RopeNodeYSpeed(double ropeId, double nodeIndex)
|
||||||
|
{
|
||||||
|
Silkworm_Rope* rope = LookupRope(ropeId);
|
||||||
|
|
||||||
|
if (rope != NULL && nodeIndex < rope->nodeCount)
|
||||||
|
{
|
||||||
|
return rope->nodes[(uint32_t)nodeIndex]->velocity.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Silkworm_UnpinRope(double ropeId)
|
void Silkworm_UnpinRope(double ropeId)
|
||||||
{
|
{
|
||||||
Silkworm_Rope* rope = LookupRope(ropeId);
|
Silkworm_Rope* rope = LookupRope(ropeId);
|
||||||
|
|
||||||
|
if (rope != NULL)
|
||||||
|
{
|
||||||
Silkworm_Node* node = rope->nodes[0];
|
Silkworm_Node* node = rope->nodes[0];
|
||||||
|
|
||||||
if (node != NULL)
|
if (node != NULL)
|
||||||
|
@ -1412,6 +1474,22 @@ void Silkworm_UnpinRope(double ropeId)
|
||||||
node->pinned = false;
|
node->pinned = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Silkworm_DeleteEndNode(double ropeId)
|
||||||
|
{
|
||||||
|
Silkworm_Rope *rope = LookupRope(ropeId);
|
||||||
|
|
||||||
|
if (rope != NULL && rope->nodeCount > 0)
|
||||||
|
{
|
||||||
|
Silkworm_Node* node = rope->nodes[rope->nodeCount - 1];
|
||||||
|
if (node != NULL)
|
||||||
|
{
|
||||||
|
Silkworm_DestroyNode(node->id);
|
||||||
|
rope->nodeCount -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
double Silkworm_RopeCreate(double xPosition, double yPosition, double mass, double friction, double windFactor, double pushFactor, double tearThreshold)
|
double Silkworm_RopeCreate(double xPosition, double yPosition, double mass, double friction, double windFactor, double pushFactor, double tearThreshold)
|
||||||
{
|
{
|
||||||
|
@ -1954,7 +2032,7 @@ double Silkworm_DestroyClothInRadius(double x, double y, double radius)
|
||||||
{
|
{
|
||||||
/* TODO: spatial hash implementation */
|
/* TODO: spatial hash implementation */
|
||||||
|
|
||||||
uint32_t i, j;
|
uint32_t i;
|
||||||
int32_t clothId = -1;
|
int32_t clothId = -1;
|
||||||
|
|
||||||
for (i = 0; i < context->nodeCount; i += 1)
|
for (i = 0; i < context->nodeCount; i += 1)
|
||||||
|
|
|
@ -84,7 +84,13 @@ SILKWORMAPI double Silkworm_RopeAddNode(double ropeId, double xPosition, double
|
||||||
SILKWORMAPI double Silkworm_RopeVerticalLength(double ropeId);
|
SILKWORMAPI double Silkworm_RopeVerticalLength(double ropeId);
|
||||||
SILKWORMAPI double Silkworm_RopeNearestX(double ropeId, double xPosition, double yPosition);
|
SILKWORMAPI double Silkworm_RopeNearestX(double ropeId, double xPosition, double yPosition);
|
||||||
SILKWORMAPI double Silkworm_RopeNearestY(double ropeId, double xPosition, double yPosition);
|
SILKWORMAPI double Silkworm_RopeNearestY(double ropeId, double xPosition, double yPosition);
|
||||||
|
SILKWORMAPI double Silkworm_RopeNodeCount(double ropeId);
|
||||||
|
SILKWORMAPI double Silkworm_RopeNodeXPosition(double ropeId, double nodeIndex);
|
||||||
|
SILKWORMAPI double Silkworm_RopeNodeYPosition(double ropeId, double nodeIndex);
|
||||||
|
SILKWORMAPI double Silkworm_RopeNodeXSpeed(double ropeId, double nodeIndex);
|
||||||
|
SILKWORMAPI double Silkworm_RopeNodeYSpeed(double ropeId, double nodeIndex);
|
||||||
SILKWORMAPI void Silkworm_UnpinRope(double ropeId);
|
SILKWORMAPI void Silkworm_UnpinRope(double ropeId);
|
||||||
|
SILKWORMAPI void Silkworm_DeleteEndNode(double ropeId);
|
||||||
SILKWORMAPI void Silkworm_RopeDestroy(double ropeId);
|
SILKWORMAPI void Silkworm_RopeDestroy(double ropeId);
|
||||||
SILKWORMAPI double Silkworm_RopeRequiredBufferSize(double ropeId);
|
SILKWORMAPI double Silkworm_RopeRequiredBufferSize(double ropeId);
|
||||||
SILKWORMAPI double Silkworm_RopeFillBuffer(double ropeId, double width, double leftUV, double widthUV, double topUV, double heightUV);
|
SILKWORMAPI double Silkworm_RopeFillBuffer(double ropeId, double width, double leftUV, double widthUV, double topUV, double heightUV);
|
||||||
|
|
Loading…
Reference in New Issue