Skip to content

Commit 318a27a

Browse files
committed
Fixed resample issue when input had collinear points
1 parent af098c3 commit 318a27a

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

Plugins/PCGExtendedToolkit/Source/PCGExtendedToolkit/Private/Paths/PCGExExtrudeTensors.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ namespace PCGExExtrudeTensors
118118
PointDataFacade->Source->GetOutKeys(true);
119119
}
120120

121-
bool FExtrusion::Extrude(const PCGExTensor::FTensorSample& Sample, const FPCGPoint& InPoint)
121+
bool FExtrusion::Extrude(const PCGExTensor::FTensorSample& Sample, FPCGPoint& InPoint)
122122
{
123123
// return whether we can keep extruding or not
124124

@@ -131,13 +131,12 @@ namespace PCGExExtrudeTensors
131131
if (DistToLastSum < Settings->FuseDistance) { return true; }
132132
DistToLastSum = 0;
133133

134-
FVector TargetPosition = Metrics.Last;
135134

136-
if (Length >= MaxLength)
135+
if (Length > MaxLength)
137136
{
138137
// Adjust position to match max length
139138
const FVector LastValidPos = ExtrudedPoints.Last().Transform.GetLocation();
140-
TargetPosition = LastValidPos + ((TargetPosition - LastValidPos).GetSafeNormal() * (Length - MaxLength));
139+
InPoint.Transform.SetLocation(LastValidPos + ((Metrics.Last - LastValidPos).GetSafeNormal() * (Length - MaxLength)));
141140
}
142141

143142
Insert(InPoint);

Plugins/PCGExtendedToolkit/Source/PCGExtendedToolkit/Private/Paths/PCGExResamplePath.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ namespace PCGExResamplePath
149149
EndIndex = 0;
150150
}
151151

152-
NextPosition = InPoints[EndIndex].Transform.GetLocation();
152+
NextPosition = InPoints[EndIndex].Transform.GetLocation();
153153
DistToNext = FVector::Dist(PrevPosition, NextPosition);
154154

155155
if (Remainder <= DistToNext) { PrevPosition = PrevPosition + (Path->DirToPrevPoint(EndIndex) * -Remainder); }
@@ -192,7 +192,8 @@ namespace PCGExResamplePath
192192

193193
//if (SourcesRange == 1)
194194
//{
195-
const double Weight = FVector::DistSquared(Path->GetPos(Sample.Start), Sample.Location) / FVector::DistSquared(Path->GetPos(Sample.Start), Path->GetPos(Sample.End));
195+
// TODO : Implement proper blending. Division by zero here when there are collocated points
196+
const double Weight = 0.5; //FVector::DistSquared(Path->GetPos(Sample.Start), Sample.Location) / FVector::DistSquared(Path->GetPos(Sample.Start), Path->GetPos(Sample.End));
196197
MetadataBlender->PrepareForBlending(Index);
197198
MetadataBlender->Blend(Index, Sample.Start, Index, Weight);
198199
MetadataBlender->Blend(Index, Sample.End, Index, 1 - Weight);

Plugins/PCGExtendedToolkit/Source/PCGExtendedToolkit/Public/Paths/PCGExExtrudeTensors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ namespace PCGExExtrudeTensors
278278

279279
protected:
280280
bool OnAdvanced(const bool bStop);
281-
bool Extrude(const PCGExTensor::FTensorSample& Sample, const FPCGPoint& InPoint);
281+
bool Extrude(const PCGExTensor::FTensorSample& Sample, FPCGPoint& InPoint);
282282
void StartNewExtrusion();
283283
void Insert(const FPCGPoint& InPoint) const;
284284
};

0 commit comments

Comments
 (0)