void AHair::InsertNode() { AMyPlayerController* Controller = GetController(); if (!Controller) return; if (Controller->TargetNodes.Num() != 2) { UE_LOG(LogTemp, Warning, TEXT("Must select two nodes adjacent in index")); return; } AHairNode* Node0 = Controller->TargetNodes[0]; AHairNode* Node1 = Controller->TargetNodes[1]; if (Node0->Segment != Node1->Segment) { UE_LOG(LogTemp, Warning, TEXT("Nodes do not belong to same segment")); return; } //AHairNode* NodeA; //AHairNode* NodeB; if (!(Node0->Index+1 == Node1->Index || Node1->Index+1 == Node0->Index)) { UE_LOG(LogTemp, Warning, TEXT("Non-adjacent indices")); return; } AHairSegment* Segment = Node0->Segment; USplineComponent* Spline = Segment->Spline; float Distance = (Spline->GetDistanceAlongSplineAtSplinePoint(Node0->Index) + Spline->GetDistanceAlongSplineAtSplinePoint(Node1->Index)) / 2.0f; int Index = FMath::Min(Node0->Index, Node1->Index)+1; FVector Loc = Spline->GetLocationAtDistanceAlongSpline(Distance, ESplineCoordinateSpace::World); FRotator Rot = FMath::Lerp(Node0->GetActorRotation(), Node1->GetActorRotation(), 0.5f); SpawnNode(Segment, Index, Loc, Rot); Spline->AddSplinePointAtIndex(Loc, Index, ESplineCoordinateSpace::World); Spline->SetUpVectorAtSplinePoint(Index, UKismetMathLibrary::GetUpVector(Rot), ESplineCoordinateSpace::World); UpdateSegment(Segment); }
// Update. void COGEmitterScrollingRay::Update (unsigned long _ElapsedTime) { if (m_Status == OG_EFFECTSTATUS_INACTIVE || !m_bPosReady) return; bool bAdd = false; float fNewSegScale = 0.0f; std::list<ParticleFormat>::iterator iter = m_BBList.begin(); while (iter != m_BBList.end()) { ParticleFormat& seg = (*iter); if (seg.pos == 0.0f && seg.scale < 1.0f) { float fAdd = m_fSpeed / m_fSegment; if (seg.scale + fAdd > 1.0f) { float fMove = seg.scale + fAdd - 1.0f; bAdd = true; fNewSegScale = fMove; if (ScrollSegment(seg, fMove)) { GetEffectsManager()->ReleaseParticle(seg.verts); iter = m_BBList.erase(iter); continue; } } else { seg.scale += fAdd; seg.start -= fAdd; } } else { if (seg.pos == 0.0f && m_fSpeed > 0.0f) { bAdd = true; fNewSegScale = (m_fSpeed / m_fSegment); } if (ScrollSegment(seg, m_fSpeed)) { GetEffectsManager()->ReleaseParticle(seg.verts); iter = m_BBList.erase(iter); continue; } } UpdateSegment(seg); ++iter; } if (bAdd) { AddSegment(0.0f, fNewSegScale); } }