Updated observation logic
This commit is contained in:
@@ -134,40 +134,63 @@ UAISense_Sight::EVisibilityResult ANakedDesireCharacter::CanBeSeenFrom(const FCa
|
||||
FVector& OutSeenLocation, int32& OutNumberOfLoSChecksPerformed, int32& OutNumberOfAsyncLosCheckRequested,
|
||||
float& OutSightStrength, int32* UserData, const FOnPendingVisibilityQueryProcessedDelegate* Delegate)
|
||||
{
|
||||
const FVector StartLocation = Context.ObserverLocation;
|
||||
const FVector BoobsBoneLocation = GetMesh()->GetBoneLocation(FName(TEXT("boobs_root")));
|
||||
const FVector PelvisBoneLocation = GetMesh()->GetBoneLocation(FName(TEXT("pelvis")));
|
||||
|
||||
OutNumberOfLoSChecksPerformed++;
|
||||
|
||||
FHitResult BoobsHitResult;
|
||||
const bool BoobsHit = CheckSight(StartLocation, BoobsBoneLocation, BoobsHitResult, Context.IgnoreActor);
|
||||
|
||||
FHitResult PelvisHitResult;
|
||||
const bool PelvisHit = CheckSight(StartLocation, PelvisBoneLocation, PelvisHitResult, Context.IgnoreActor);
|
||||
bool bTopVisible = false;
|
||||
bool bBottomVisible = false;
|
||||
const float Exposure = ComputeObservedExposure(Context.ObserverLocation, Context.IgnoreActor, bTopVisible, bBottomVisible);
|
||||
|
||||
if ((!BoobsHit || BoobsHitResult.GetActor() == this) && ClothingManager->IsBodyPartExposed(EBodyPart::Boobs))
|
||||
// An observer perceives the player only when a revealing body part is within their line of sight.
|
||||
if (Exposure > 0.0f)
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("Boobs hit"));
|
||||
OutSeenLocation = BoobsBoneLocation;
|
||||
const bool bSeenTop = bTopVisible && RevealAmount(EBodyPart::Boobs) > 0.0f;
|
||||
OutSeenLocation = GetMesh()->GetBoneLocation(FName(bSeenTop ? TEXT("boobs_root") : TEXT("pelvis")));
|
||||
OutSightStrength = 1.0f;
|
||||
return UAISense_Sight::EVisibilityResult::Visible;
|
||||
}
|
||||
|
||||
if ((!PelvisHit || PelvisHitResult.GetActor() == this) &&
|
||||
(ClothingManager->IsBodyPartExposed(EBodyPart::Ass) || ClothingManager->IsBodyPartExposed(EBodyPart::Genitals)))
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("Pelvis hit"));
|
||||
OutSeenLocation = PelvisBoneLocation;
|
||||
OutSightStrength = 1.0f;
|
||||
return UAISense_Sight::EVisibilityResult::Visible;
|
||||
}
|
||||
|
||||
UE_LOG(LogTemp, Warning, TEXT("Not visoble"));
|
||||
|
||||
return UAISense_Sight::EVisibilityResult::NotVisible;
|
||||
}
|
||||
|
||||
float ANakedDesireCharacter::GetObservedExposureFrom(const FVector& ObserverLocation, const AActor* IgnoreActor)
|
||||
{
|
||||
bool bTopVisible = false;
|
||||
bool bBottomVisible = false;
|
||||
return ComputeObservedExposure(ObserverLocation, IgnoreActor, bTopVisible, bBottomVisible);
|
||||
}
|
||||
|
||||
float ANakedDesireCharacter::ComputeObservedExposure(const FVector& ObserverLocation, const AActor* IgnoreActor,
|
||||
bool& bOutTopVisible, bool& bOutBottomVisible)
|
||||
{
|
||||
const FVector BoobsBoneLocation = GetMesh()->GetBoneLocation(FName(TEXT("boobs_root")));
|
||||
const FVector PelvisBoneLocation = GetMesh()->GetBoneLocation(FName(TEXT("pelvis")));
|
||||
|
||||
float Exposure = 0.0f;
|
||||
|
||||
// Top region -> Boobs. A region is "visible" when its LOS trace is unobstructed (or only hits self).
|
||||
FHitResult TopHit;
|
||||
bOutTopVisible = !CheckSight(ObserverLocation, BoobsBoneLocation, TopHit, IgnoreActor) || TopHit.GetActor() == this;
|
||||
if (bOutTopVisible)
|
||||
Exposure += RevealAmount(EBodyPart::Boobs);
|
||||
|
||||
// Bottom region (pelvis) -> Ass + Genitals; one trace gates both lower parts.
|
||||
FHitResult BottomHit;
|
||||
bOutBottomVisible = !CheckSight(ObserverLocation, PelvisBoneLocation, BottomHit, IgnoreActor) || BottomHit.GetActor() == this;
|
||||
if (bOutBottomVisible)
|
||||
{
|
||||
Exposure += RevealAmount(EBodyPart::Ass);
|
||||
Exposure += RevealAmount(EBodyPart::Genitals);
|
||||
}
|
||||
|
||||
return Exposure;
|
||||
}
|
||||
|
||||
float ANakedDesireCharacter::RevealAmount(const EBodyPart BodyPart)
|
||||
{
|
||||
const float Coverage = ClothingManager->GetEffectiveCoverage(BodyPart);
|
||||
return Coverage < ObservationRevealThreshold ? (1.0f - Coverage) : 0.0f;
|
||||
}
|
||||
|
||||
bool ANakedDesireCharacter::CheckSight(const FVector& StartLocation, const FVector& EndLocation, FHitResult& HitResult,
|
||||
const AActor* IgnoreActor)
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "GameFramework/Character.h"
|
||||
#include "InputAction.h"
|
||||
#include "InputMappingContext.h"
|
||||
#include "NakedDesire/Clothing/BodyPart.h"
|
||||
#include "NakedDesire/Global/Gait.h"
|
||||
#include "NakedDesire/Global/NakedDesireUserSettings.h"
|
||||
#include "NakedDesire/Global/Stance.h"
|
||||
@@ -121,7 +122,18 @@ public:
|
||||
virtual void NotifyControllerChanged() override;
|
||||
virtual void BeginPlay() override;
|
||||
virtual UAISense_Sight::EVisibilityResult CanBeSeenFrom(const FCanBeSeenFromContext& Context, FVector& OutSeenLocation, int32& OutNumberOfLoSChecksPerformed, int32& OutNumberOfAsyncLosCheckRequested, float& OutSightStrength, int32* UserData = nullptr, const FOnPendingVisibilityQueryProcessedDelegate* Delegate = nullptr) override;
|
||||
|
||||
|
||||
// Player exposure as read by an observer at ObserverLocation, in [0, 3]: the sum over the
|
||||
// LOS-visible body regions (top -> Boobs, bottom -> Ass + Genitals) of (1 - effective coverage)
|
||||
// for parts below ObservationRevealThreshold. 0 means nothing revealing is visible to them.
|
||||
// Queried per observing NPC each tick by UStatsManager to drive embarrassment (GDD §7.1).
|
||||
float GetObservedExposureFrom(const FVector& ObserverLocation, const AActor* IgnoreActor);
|
||||
|
||||
// Below this effective coverage [0,1] a body part reads as "revealing": observers notice it and
|
||||
// it contributes to embarrassment. At or above it the part is treated as decently covered.
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Observation")
|
||||
float ObservationRevealThreshold = 0.9f;
|
||||
|
||||
private:
|
||||
EGait Gait = EGait::Walk;
|
||||
EStance Stance = EStance::Stand;
|
||||
@@ -135,6 +147,14 @@ private:
|
||||
void OnInteractPress(const FInputActionValue& Value);
|
||||
|
||||
bool CheckSight(const FVector& StartLocation, const FVector& EndLocation, FHitResult& HitResult, const AActor* IgnoreActor);
|
||||
|
||||
// Traces observer->boobs_root and observer->pelvis for line of sight (top / bottom regions),
|
||||
// then sums (1 - coverage) over the revealing parts in each LOS-visible region. The out-bools
|
||||
// report raw line of sight per region (before coverage), used to pick a seen location.
|
||||
float ComputeObservedExposure(const FVector& ObserverLocation, const AActor* IgnoreActor, bool& bOutTopVisible, bool& bOutBottomVisible);
|
||||
|
||||
// (1 - effective coverage) when BodyPart is below ObservationRevealThreshold, else 0.
|
||||
float RevealAmount(EBodyPart BodyPart);
|
||||
|
||||
UFUNCTION(Exec)
|
||||
void LogTest();
|
||||
|
||||
Reference in New Issue
Block a user