forked from Mirrors/openclonk
Rope: Change third parameter of CreateRope to nominal segment length
Was number of segments beforerope
parent
4f2aedd635
commit
c3eaa66bef
|
@ -6,8 +6,8 @@ func Initialize()
|
|||
var b = CreateObject(Rock, 200, 100, NO_OWNER);
|
||||
//a->SetCategory(C4D_StaticBack);
|
||||
//b->SetCategory(C4D_StaticBack);
|
||||
Scenario.rope = CreateRope(a, b, 20, LiftTower_Rope);
|
||||
//CreateRope(a, b, 1, LiftTower_Rope);
|
||||
Scenario.rope = CreateRope(a, b, 5, LiftTower_Rope);
|
||||
//CreateRope(a, b, 100, LiftTower_Rope);
|
||||
}
|
||||
|
||||
func InitializePlayer(int plr)
|
||||
|
@ -15,7 +15,7 @@ func InitializePlayer(int plr)
|
|||
var clonk = GetCrew(plr, 0);
|
||||
var a = CreateObject(Rock, clonk->GetX(), clonk->GetY()-100, NO_OWNER);
|
||||
a->SetCategory(C4D_StaticBack);
|
||||
var rope = CreateRope(a, clonk, 20, LiftTower_Rope);
|
||||
var rope = CreateRope(a, clonk, 5, LiftTower_Rope);
|
||||
|
||||
rope->SetFrontAutoSegmentation(200);
|
||||
}
|
||||
|
|
|
@ -2125,7 +2125,7 @@ static bool FnSetMeshMaterial(C4AulObjectContext* ctx, C4String* Material, int i
|
|||
return true;
|
||||
}
|
||||
|
||||
static C4PropList* FnCreateRope(C4AulContext *cthr, C4Object* First, C4Object* Second, int iSegments, C4PropList* Graphics)
|
||||
static C4PropList* FnCreateRope(C4AulContext *cthr, C4Object* First, C4Object* Second, int SegmentLength, C4PropList* Graphics)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -2133,7 +2133,7 @@ static C4PropList* FnCreateRope(C4AulContext *cthr, C4Object* First, C4Object* S
|
|||
C4Def* Def = Graphics->GetDef();
|
||||
if(!Def) return false;
|
||||
|
||||
return Game.Ropes.CreateRope(First, Second, iSegments, &Def->Graphics);
|
||||
return Game.Ropes.CreateRope(First, Second, itofix(SegmentLength), &Def->Graphics);
|
||||
}
|
||||
catch(const C4RopeError& err)
|
||||
{
|
||||
|
|
|
@ -325,15 +325,13 @@ bool C4RopeElement::SetForceRedirectionByLookAround(const C4Rope* rope, int ox,
|
|||
return true;
|
||||
}
|
||||
|
||||
C4Rope::C4Rope(C4PropList* Prototype, C4Object* first_obj, C4Object* second_obj, int32_t n_segments, C4DefGraphics* graphics):
|
||||
C4PropListNumbered(Prototype), Width(5.0f), Graphics(graphics), SegmentCount(n_segments),
|
||||
l(ObjectDistance(first_obj, second_obj) / (n_segments + 1)), k(Fix1*3), mu(Fix1*3), eta(Fix1*3), NumIterations(10),
|
||||
C4Rope::C4Rope(C4PropList* Prototype, C4Object* first_obj, C4Object* second_obj, C4Real segment_length, C4DefGraphics* graphics):
|
||||
C4PropListNumbered(Prototype), Width(5.0f), Graphics(graphics), SegmentCount(itofix(ObjectDistance(first_obj, second_obj))/segment_length),
|
||||
l(segment_length), k(Fix1*3), mu(Fix1*3), eta(Fix1*3), NumIterations(10),
|
||||
FrontAutoSegmentation(Fix0), BackAutoSegmentation(Fix0)
|
||||
{
|
||||
if(!PathFree(first_obj->GetX(), first_obj->GetY(), second_obj->GetX(), second_obj->GetY()))
|
||||
throw C4RopeError("Path between objects is blocked");
|
||||
if(n_segments < 1)
|
||||
throw C4RopeError("Segments < 1 given");
|
||||
if(Graphics->Type != C4DefGraphics::TYPE_Bitmap)
|
||||
throw C4RopeError("Can only use bitmap as rope graphics");
|
||||
|
||||
|
@ -343,11 +341,11 @@ C4Rope::C4Rope(C4PropList* Prototype, C4Object* first_obj, C4Object* second_obj,
|
|||
const C4Real m(Fix1); // TODO: This should be a property
|
||||
|
||||
C4RopeElement* prev_seg = Front;
|
||||
for(int32_t i = 0; i < n_segments; ++i)
|
||||
for(int32_t i = 0; i < SegmentCount; ++i)
|
||||
{
|
||||
// Create new element
|
||||
C4Real seg_x = first_obj->fix_x + (second_obj->fix_x - first_obj->fix_x) * (i+1) / (n_segments+1);
|
||||
C4Real seg_y = first_obj->fix_y + (second_obj->fix_y - first_obj->fix_y) * (i+1) / (n_segments+1);
|
||||
C4Real seg_x = first_obj->fix_x + (second_obj->fix_x - first_obj->fix_x) * (i+1) / (SegmentCount+1);
|
||||
C4Real seg_y = first_obj->fix_y + (second_obj->fix_y - first_obj->fix_y) * (i+1) / (SegmentCount+1);
|
||||
C4RopeElement* seg = new C4RopeElement(seg_x, seg_y, m, false);
|
||||
|
||||
// Link it
|
||||
|
@ -759,9 +757,9 @@ C4RopeList::C4RopeList()
|
|||
delete Ropes[i];
|
||||
}
|
||||
|
||||
C4Rope* C4RopeList::CreateRope(C4Object* first_obj, C4Object* second_obj, int32_t n_segments, C4DefGraphics* graphics)
|
||||
C4Rope* C4RopeList::CreateRope(C4Object* first_obj, C4Object* second_obj, C4Real segment_length, C4DefGraphics* graphics)
|
||||
{
|
||||
Ropes.push_back(new C4Rope(RopeAul.GetPropList(), first_obj, second_obj, n_segments, graphics));
|
||||
Ropes.push_back(new C4Rope(RopeAul.GetPropList(), first_obj, second_obj, segment_length, graphics));
|
||||
return Ropes.back();
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ private:
|
|||
class C4Rope: public C4PropListNumbered
|
||||
{
|
||||
public:
|
||||
C4Rope(C4PropList* Prototype, C4Object* first_obj, C4Object* second_obj, int32_t n_segments, C4DefGraphics* graphics);
|
||||
C4Rope(C4PropList* Prototype, C4Object* first_obj, C4Object* second_obj, C4Real segment_length, C4DefGraphics* graphics);
|
||||
~C4Rope();
|
||||
|
||||
void Draw(C4TargetFacet& cgo, C4BltTransform* pTransform);
|
||||
|
@ -143,7 +143,7 @@ public:
|
|||
void Execute();
|
||||
void Draw(C4TargetFacet& cgo, C4BltTransform* pTransform);
|
||||
|
||||
C4Rope* CreateRope(C4Object* first_obj, C4Object* second_obj, int32_t n_segments, C4DefGraphics* graphics);
|
||||
C4Rope* CreateRope(C4Object* first_obj, C4Object* second_obj, C4Real segment_length, C4DefGraphics* graphics);
|
||||
void RemoveRope(C4Rope* rope);
|
||||
|
||||
void ClearPointers(C4Object* obj);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
static C4Void FnRemove(C4AulContext* Context)
|
||||
{
|
||||
Game.Ropes.RemoveRope(static_cast<C4Rope*>(Context->Def));
|
||||
return C4Void();
|
||||
}
|
||||
|
||||
static C4Object* FnGetFront(C4AulContext* Context)
|
||||
|
|
Loading…
Reference in New Issue