I have been looking at the Rollercoaster plugin code that TeddyO(not me) orginally wrote for 4.7 and earlier. In it, he had to "nasty hack" (as he puts it) his code to gain access to the protected variables of Landscape Spline Info. I thought fine! As long as it works, everyone is happy. It compiles alright in 4.6 and 4.7 so I thought that I would recompile his code for 4.8. Guess what, it failed. It seems that two more variables have been included in the protected shield, namely:
Here are snippets of the code where the variables are used:
So, my question is threefold:
1) Why are these variables protected now when before 4.8 they were not?
2) Is there another way of accessing these variables without the "nasty hack" of pointer arithmetic?
3) I am researching on reinterpret_cast as a viable candidate if nothing else is available. Would that work?
Please help. Thanks in advance
Code:
Error 3 error C2248: 'ULandscapeSplinesComponent::ControlPoints' : cannot access protected member declared in class 'ULandscapeSplinesComponent' C:\Users\TedGame\Documents\Unreal Projects\RollerBuild4_8\Plugins\RollercoasterPlugin\Source \RollercoasterPlugin\Private\RollercoasterPlayerController.cpp 114 1 RollerBuild4_8 Error 4 error C2248: 'ULandscapeSplinesComponent::Segments' : cannot access protected member declared in class 'ULandscapeSplinesComponent' C:\Users\TedGame\Documents\Unreal Projects\RollerBuild4_8\Plugins\RollercoasterPlugin\Source \RollercoasterPlugin\Private\RollercoasterPlayerController.cpp 120 1 RollerBuild4_8
Here are snippets of the code where the variables are used:
Code:
if (GetPawn()) { for (TObjectIterator<ULandscapeSplinesComponent> ObjIt; ObjIt; ++ObjIt) { TrackSplines = *ObjIt; ULandscapeSplineControlPoint* ClosestControlPoint = nullptr; //Find the controlpoint closest to the player start point FVector PlayerStartLocation = GetPawn()->GetActorLocation() - TrackSplines->GetOwner()->GetActorLocation(); float ClosestDistSq = FLT_MAX; for (int32 i = 0; i < TrackSplines->ControlPoints.Num(); i++) { float DistSq = (TrackSplines->ControlPoints[i]->Location - PlayerStartLocation).SizeSquared(); if (DistSq < ClosestDistSq) { ClosestDistSq = DistSq; ClosestControlPoint = TrackSplines->ControlPoints[i]; } } //Build up an ordered list of track segments (the TrackSplines->Segments array can be in random order) bool bTrackHasErrors = false; OrderedSegments.Empty(TrackSplines->Segments.Num()); ULandscapeSplineControlPoint* CurrentControlPoint = ClosestControlPoint;
1) Why are these variables protected now when before 4.8 they were not?
2) Is there another way of accessing these variables without the "nasty hack" of pointer arithmetic?
3) I am researching on reinterpret_cast as a viable candidate if nothing else is available. Would that work?
Please help. Thanks in advance
Comment