void DynamicEntityNode::DynamicMove(sf::Vector2f Disp, bool SweepBothDirections) { unsigned int CollisionMask = eCollisionGroup::Monster | eCollisionGroup::Static | eCollisionGroup::Player | eCollisionGroup::Pickup; float SweepTmax = 1.5f; if (SweepBothDirections) { if (Disp.x != 0.0f) { HitInfo Hit; GetWorld()->GetQuadTree()->SweepShapeClosest(*GetCollisionShape(), GetWorldTransform(), sf::Vector2f(Disp.x, 0.0f), SweepTmax, CollisionMask, this, Hit); if (Hit.m_pObject) { Disp.x = 0.0f; OnTouch(Hit.m_pObject); } } if (Disp.y != 0.0f) { HitInfo Hit; GetWorld()->GetQuadTree()->SweepShapeClosest(*GetCollisionShape(), GetWorldTransform(), sf::Vector2f(0.0f, Disp.y), SweepTmax, CollisionMask, this, Hit); if (Hit.m_pObject) { Disp.y = 0.0f; OnTouch(Hit.m_pObject); } } } else { HitInfo Hit; GetWorld()->GetQuadTree()->SweepShapeClosest(*GetCollisionShape(), GetWorldTransform(), Disp, SweepTmax, CollisionMask, this, Hit); if (Hit.m_pObject) { Disp.x = 0.0f; Disp.y = 0.0f; OnTouch(Hit.m_pObject); } } Move(Disp); }
void UFlareAsteroidComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); float CollisionSize = GetCollisionShape().GetExtent().Size(); EffectsUpdateTimer += DeltaTime; // Get player ship AFlareGame* Game = Cast<AFlareGame>(GetWorld()->GetAuthGameMode()); FCHECK(Game); AFlarePlayerController* PC = Game->GetPC(); FCHECK(PC); AFlareSpacecraft* ShipPawn = PC->GetShipPawn(); // Update if close to player and visible if (ShipPawn && (ShipPawn->GetActorLocation() - GetComponentLocation()).Size() < 500000 && (GetWorld()->TimeSeconds - LastRenderTime) < 0.5) { if (EffectsUpdateTimer > EffectsUpdatePeriod) { // World data FVector AsteroidLocation = GetComponentLocation(); FVector SunDirection = Game->GetPlanetarium()->GetSunDirection(); SunDirection.Normalize(); // Compute new FX locations for (int32 Index = 0; Index < Effects.Num(); Index++) { FVector RandomDirection = FVector::CrossProduct(SunDirection, EffectsKernels[Index]); RandomDirection.Normalize(); FVector StartPoint = AsteroidLocation + RandomDirection * CollisionSize; // Trace params FHitResult HitResult(ForceInit); FCollisionQueryParams TraceParams(FName(TEXT("Asteroid Trace")), false, NULL); TraceParams.bTraceComplex = true; TraceParams.bReturnPhysicalMaterial = false; ECollisionChannel CollisionChannel = ECollisionChannel::ECC_WorldDynamic; // Trace bool FoundHit = GetWorld()->LineTraceSingleByChannel(HitResult, StartPoint, AsteroidLocation, CollisionChannel, TraceParams); if (FoundHit && HitResult.Component == this && Effects[Index]) { FVector EffectLocation = HitResult.Location; if (!Effects[Index]->IsActive()) { Effects[Index]->Activate(); } Effects[Index]->SetWorldLocation(EffectLocation); Effects[Index]->SetWorldRotation(SunDirection.Rotation()); } else { Effects[Index]->Deactivate(); } } EffectsUpdateTimer = 0; } } // Disable all else { for (int32 Index = 0; Index < Effects.Num(); Index++) { Effects[Index]->Deactivate(); } } }
void RigidBody::getAabb(SimdVector3& aabbMin,SimdVector3& aabbMax) const { GetCollisionShape()->GetAabb(m_worldTransform,aabbMin,aabbMax); }