• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Hit函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Hit函数的典型用法代码示例。如果您正苦于以下问题:C++ Hit函数的具体用法?C++ Hit怎么用?C++ Hit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Hit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: intersect

    Hit intersect(const Ray& ray)
    {
        float3 diff = ray.origin - center;
        double a = ray.dir.dot(ray.dir);
        double b = diff.dot(ray.dir) * 2.0;
        double c = diff.dot(diff) - radius * radius;
 
        double discr = b * b - 4.0 * a * c;
        if ( discr < 0 ) 
            return Hit();
        double sqrt_discr = sqrt( discr );
        double t1 = (-b + sqrt_discr)/2.0/a;
        double t2 = (-b - sqrt_discr)/2.0/a;
 
		float t = (t1<t2)?t1:t2;
		if(t < 0)
			t = (t1<t2)?t2:t1;
		if (t < 0)
            return Hit();

		Hit h;
		h.t = t;
		h.material = material;
		h.position = ray.origin + ray.dir * t;
		h.normal = h.position - center;
		h.normal.normalize();

		return h;

    }
开发者ID:emeersman,项目名称:raytracing,代码行数:30,代码来源:main.cpp


示例2: Hit

Hit RayTracer::rayIntersectTriangles(const Vec3f& orig, const Vec3f& dir, int startPrim, int endPrim) const
{
	float umin = 0.0f, vmin = 0.0f, tmin = 1.0f;
	int imin = -1;

	// naive loop over all triangles
	for ( int i = startPrim; i <= endPrim; ++i )
	{
		float t = std::numeric_limits<float>::max(), u, v;
		if ( intersect_triangle1( &orig.x,
								  &dir.x,
								  &(*m_triangles)[i].m_vertices[0]->x,
								  &(*m_triangles)[i].m_vertices[1]->x,
								  &(*m_triangles)[i].m_vertices[2]->x,
								  t, u, v ) )
		{
			if ( t > 0.0f && t < tmin )
			{
				imin = i;
				tmin = t;
				umin = u;
				vmin = v;
			}
		}
	}

	if ( imin != -1 )
		return Hit(&(*m_triangles)[imin], orig + tmin*dir, tmin, umin, vmin);
	else
		return Hit(NULL);
}
开发者ID:Zerphed,项目名称:advanced-computer-graphics-course,代码行数:31,代码来源:RayTracer.cpp


示例3: PrintHandBeginsMessage

// Main function that executes the blackjack game with a new player
void CBlackJack::StartGameWithNewPlayer()
{
  bool playAgain = true;
  PrintHandBeginsMessage(Player.GetName(), Player.GetChips());

  while(playAgain)
    {
      // Ask player for a wager. It returns true if valid wager is returned
      if(GetSetPlayerWager())
	{
	  // Hit the player twice 
	  Hit(Player);
	  Hit(Player);
	  DEBUG_LOG (4, "Hit Player twice");
	  if(Player.IsBlackjack())
	    PrintResult(PLAYER_BLACKJACK, Player.GetName(), 0);

	  // Hit dealer twice
	  Hit(Dealer);
	  Hit(Dealer);
	  DEBUG_LOG (4, "Hit Dealer twice");
	  if(Dealer.IsBlackjack())
	    PrintResult(DEALER_BLACKJACK, Dealer.GetName(), 0);

	  // If dealer or player got blackjack or busted, then game can end here. 
	  // Else, continue playing
	
	  if(!Player.IsBlackjack() && !Player.IsBusted()
	     && !Dealer.IsBlackjack() && !Dealer.IsBusted())
	    {
	      // Display scores
	      Player.PrintScore();
	      Dealer.PrintScore();

	      // Give playing options to player and play
	      PlayerOptionsAndPlay();
	      // Unless player is busted, continue hitting the dealer
	      if(!Player.IsBusted())
		DealerOptionsAndPlay();				
	    }
			
	  // At the end, check for winner, and calculate payout
	  CheckWinnerCalculatePayout();
	}

      // Ask player for another game
      playAgain = EndOption();

    } // end while playAgain

  // Add player's score to high scores
  DEBUG_LOG(1, "Remaining chips " << Player.GetChips());
  HighScoreHandler.AddNewScore(Player.GetName(), Player.GetChips());

  // Reset remaining chips with player
  Player.Reset();

  PrintHandQuitMessage();
}
开发者ID:fenichawla,项目名称:BlackjackGame,代码行数:60,代码来源:Blackjack.cpp


示例4: rayVsTriangle

Hit RenderDevice::rayTraceNode(const Ray &ray, u32 nodeIndex)
{
    // Handle Leaf
    if(nodes[nodeIndex].isLeaf())
    {
        f32 hit;
        f32 closestHit = MAXFLOAT;
        u32 triangleIndex=0;
        vec3 hitBaryCoords;
        vec3 baryCoords;

        for(u32 i=nodes[nodeIndex].getIndex(); i < nodes[nodeIndex].getIndex()+nodes[nodeIndex].getSize(); ++i)
        {
            if(i != ray.originID) {
                hit = rayVsTriangle(ray,faces[i],hitBaryCoords);
                if(hit > 0.0 && hit < closestHit)
                {
                    closestHit = hit;
                    triangleIndex = i;
                    baryCoords = hitBaryCoords;
                }
            }
        }
        if(closestHit < MAXFLOAT)
        {
            return Hit(closestHit, triangleIndex, baryCoords);
        }
    }
    else
    {
        Hit leaf_left_hit(MAXFLOAT,0);
        Hit leaf_right_hit(MAXFLOAT,0);

		if(rayVsAABB(ray,nodes[nodes[nodeIndex].getLeft()].aabb) < MAXFLOAT) {
            leaf_left_hit = rayTraceNode(ray,nodes[nodeIndex].getLeft());
		}
		if(rayVsAABB(ray,nodes[nodes[nodeIndex].getRight()].aabb) < MAXFLOAT) {
            leaf_right_hit = rayTraceNode(ray,nodes[nodeIndex].getRight());
		}

		if(leaf_left_hit < leaf_right_hit) {
			return leaf_left_hit;
		} else if (leaf_right_hit.distance < MAXFLOAT) {
			return leaf_right_hit;
		}
    }
    return Hit(MAXFLOAT,0);
}
开发者ID:eriha891,项目名称:RTFW,代码行数:48,代码来源:RenderDevice.cpp


示例5: ToBasePlayer

//-----------------------------------------------------------------------------
// Animation event handlers
//-----------------------------------------------------------------------------
void CWeaponZMFists::HandleAnimEventMeleeHit( CBaseCombatCharacter *pOperator )
{
	//do the trace stuff here so we can pass it to the Hit() function
	trace_t traceHit;

	// Try a ray
	CBasePlayer *pOwner = ToBasePlayer(pOperator);
	if ( !pOwner )
		return;

	Vector swingStart = pOwner->Weapon_ShootPosition( );
	Vector forward;

	pOwner->EyeVectors( &forward, NULL, NULL );

	Vector swingEnd = swingStart + forward * GetRange();

#ifndef CLIENT_DLL
	CHL2MP_Player *pPlayer = ToHL2MPPlayer( GetPlayerOwner() );
	// Move other players back to history positions based on local player's lag
	lagcompensation->StartLagCompensation( pPlayer, pPlayer->GetCurrentCommand() );
#endif
	UTIL_TraceLine( swingStart, swingEnd, MASK_SHOT_HULL, pOwner, COLLISION_GROUP_NONE, &traceHit );
	Hit( traceHit, ACT_VM_HITCENTER);
#ifndef CLIENT_DLL
	// Move other players back to history positions based on local player's lag
	lagcompensation->FinishLagCompensation( pPlayer );
#endif
}
开发者ID:TotallyMehis,项目名称:ZM-Updated,代码行数:32,代码来源:weapon_zm_fists.cpp


示例6: TraceParams

AActor* USCarryObjectComponent::GetActorInView()
{
	APawn* PawnOwner = Cast<APawn>(GetOwner());
	AController* Controller = PawnOwner->Controller;
	if (Controller == nullptr)
	{
		return nullptr;
	}

	FVector CamLoc;
	FRotator CamRot;
	Controller->GetPlayerViewPoint(CamLoc, CamRot);

	const FVector TraceStart = CamLoc;
	const FVector Direction = CamRot.Vector();
	const FVector TraceEnd = TraceStart + (Direction * MaxPickupDistance);

	FCollisionQueryParams TraceParams(TEXT("TraceActor"), true, PawnOwner);
	TraceParams.bTraceAsyncScene = true;
	TraceParams.bReturnPhysicalMaterial = false;
	TraceParams.bTraceComplex = false;

	FHitResult Hit(ForceInit);
	GetWorld()->LineTraceSingle(Hit, TraceStart, TraceEnd, ECC_Visibility, TraceParams);

	//DrawDebugLine(GetWorld(), TraceStart, TraceEnd, FColor::Red, false, 1.0f);

	return Hit.GetActor();
}
开发者ID:Magicmay,项目名称:EpicSurvivalGameSeries,代码行数:29,代码来源:SCarryObjectComponent.cpp


示例7: Hit

Hit Plane::intersect(const Ray &ray)
{
	double denom, t, denomAbs;
	Point pos;
	Vector N, vec10 = position0 - position1, vec12 = position2 - position1;
	// calculate normal of plane
	N = vec10.cross(vec12);
	N.normalize();
	
	// calculate denominator and calculate the absolute value
	denom = N.dot(ray.D);
	if (denom < 0){
		denomAbs = denom * -1;
	} else{
		denomAbs = denom;
	}
	// if the absolute value < epsilon, no hit
	if (denomAbs > 1e-6) {
		// calculate distance to possible intersection
		t = (position0-ray.O).dot(N)/denom;
		// point of intersection
		pos = ray.O + ray.D*t;
		
		// if t is negative, no intersection
		if (t<0 )  return Hit::NO_HIT();
		// if the plane is set to finite, the intersection is compared to min and max coordinates. If it is too big or small, not hit
		#ifdef FINITE
		if(!(pos.x >= minX && pos.x <= maxX) || !(pos.y >= minY && pos.y <= maxY) || !(pos.z >= minZ && pos.z <= maxZ)) return Hit::NO_HIT();
		#endif
	}else{
		return Hit::NO_HIT();
	}
    return Hit(t,N);
}
开发者ID:DanielsWrath,项目名称:ComputerGraphics,代码行数:34,代码来源:plane.cpp


示例8: Hit

void Player::HandleCollision(Sprite* sprite, Level* level) {
    ActionType hitAction;
    
    if (currAction == STAND) {
        hitAction = prevAction;
    } else {
        hitAction = currAction;
    }
    
    if (attacking) {
        sound.setBuffer(hit);
        sprite->Hit(hitAction, level);
    }
    else {
        if (dynamic_cast<Princess*>(sprite)) {
            sound.setBuffer(kiss);
            level->SetStatus(Level::COMPLETE);
        } else {
            sound.setBuffer(no);
            Hit(sprite->GetAction(), level);
        }
    }
    
    sound.play();
}
开发者ID:danielbreves,项目名称:HeroMustSavePrincess,代码行数:25,代码来源:Player.cpp


示例9: TraceParams

AInventoryItem* APlayerCharacter::GetUsableItemInView()
{
	FVector camLoc;
	FRotator camRot;

	if (Controller == NULL)
		return NULL;

	Controller->GetPlayerViewPoint(camLoc, camRot);
	const FVector start_trace = camLoc;
	const FVector direction = camRot.Vector();
	const FVector end_trace = start_trace + (direction * MaxUseDist);

	FCollisionQueryParams TraceParams(FName(TEXT("")), true, this);
	TraceParams.bTraceAsyncScene = true;
	TraceParams.bReturnPhysicalMaterial = false;
	TraceParams.bTraceComplex = true;

	FHitResult Hit(ForceInit);
	GetWorld()->LineTraceSingleByChannel(Hit, start_trace, end_trace, ECollisionChannel::ECC_EngineTraceChannel1, TraceParams);

	//DrawDebugLine(GetWorld(), start_trace, end_trace, FColor(255, 0, 0), false, -1, 0, 12.333);

	return Cast<AInventoryItem>(Hit.GetActor());
}
开发者ID:jackdurnford,项目名称:MidnightSnag,代码行数:25,代码来源:PlayerCharacter.cpp


示例10: TraceParams

AUsableActor* AXtremeJanitorCharacter::GetUsableInView()
{
	FVector CamLoc;
	FRotator CamRot;

	if (Controller == NULL)
		return NULL;

	Controller->GetPlayerViewPoint(CamLoc, CamRot);
	const FVector TraceStart = CamLoc;
	const FVector Direction = CamRot.Vector();
	const FVector TraceEnd = TraceStart + (Direction * MaxUseDistance);

	FCollisionQueryParams TraceParams(FName(TEXT("TraceUsableActor")), true, this);
	TraceParams.bTraceAsyncScene = true;
	TraceParams.bReturnPhysicalMaterial = false;
	TraceParams.bTraceComplex = true;

	FHitResult Hit(ForceInit);
	GetWorld()->LineTraceSingleByChannel(Hit, TraceStart, TraceEnd, ECC_Visibility, TraceParams);

	// Cette ligne sera en commentaire plus tard
	DrawDebugLine(GetWorld(), TraceStart, TraceEnd, FColor::Red, false, 1.0f);

	return Cast<AUsableActor>(Hit.GetActor());
}
开发者ID:MelBeee,项目名称:UE4_FinalProject_A15,代码行数:26,代码来源:XtremeJanitorCharacter.cpp


示例11: GetMap

void Fire::Process()
{
    auto enm = GetMap()->GetEnemyHolder()->GetNearest(this->pixel_x(), this->pixel_y(), 7, 
                                                     [this](Enemy* e) 
        /*I AM KING OF SPACES*/                      {
                                                         return !e->IsRocketFriend()
                                                                && e != this;
                                                     });

    ++length_;

    if (enm != nullptr)
    {
        ProcessSpeed(enm->pixel_x(), enm->pixel_y(), 1);
        if ((abs(enm->pixel_x() - pixel_x()) + abs(enm->pixel_y() - pixel_y())) < 48)
        {
            enm->Hit(1);
        }
    }
    ProcessMove();

    state_w_ = (length_ / 5) % 6;

    if (length_ > 30)
        GetMap()->GetEnemyHolder()->AddToDelete(this);
}
开发者ID:kremius,项目名称:space-dworf-strategy,代码行数:26,代码来源:enemy.cpp


示例12:

const HitList & QueryConnector::evaluateHits(HitList & hl) const
{
    if (evaluate()) {
        hl.push_back(Hit(1, 0, 0, 1));
    }
    return hl;
}
开发者ID:songhtdo,项目名称:vespa,代码行数:7,代码来源:query.cpp


示例13: GetInputAxisValue

void ATP_TwinStickPawn::Tick(float DeltaSeconds)
{
	// Find movement direction
	const float ForwardValue = GetInputAxisValue(MoveForwardBinding);
	const float RightValue = GetInputAxisValue(MoveRightBinding);

	// Clamp max size so that (X=1, Y=1) doesn't cause faster movement in diagonal directions
	const FVector MoveDirection = FVector(ForwardValue, RightValue, 0.f).GetClampedToMaxSize(1.0f);

	// Calculate  movement
	const FVector Movement = MoveDirection * MoveSpeed * DeltaSeconds;

	// If non-zero size, move this actor
	if (Movement.SizeSquared() > 0.0f)
	{
		const FRotator NewRotation = Movement.Rotation();
		FHitResult Hit(1.f);
		RootComponent->MoveComponent(Movement, NewRotation, true, &Hit);
		
		if (Hit.IsValidBlockingHit())
		{
			const FVector Normal2D = Hit.Normal.GetSafeNormal2D();
			const FVector Deflection = FVector::VectorPlaneProject(Movement, Normal2D) * (1.f - Hit.Time);
			RootComponent->MoveComponent(Deflection, NewRotation, true);
		}
	}
	
	// Create fire direction vector
	const float FireForwardValue = GetInputAxisValue(FireForwardBinding);
	const float FireRightValue = GetInputAxisValue(FireRightBinding);
	const FVector FireDirection = FVector(FireForwardValue, FireRightValue, 0.f);

	// Try and fire a shot
	FireShot(FireDirection);
}
开发者ID:colwalder,项目名称:unrealengine,代码行数:35,代码来源:TP_TwinStickPawn.cpp


示例14: Hit

Hit BVH::BVHLeaf::trace(const AABB_Ray & aabb_ray, const Ray & ray, Amount minT)
{
   if(object.bounds.intersect(aabb_ray)){
      return object.geometry->intersectTransform(ray,minT);
   }
   return Hit(ray);
}
开发者ID:kyle-piddington,项目名称:PovTracer,代码行数:7,代码来源:BVH.cpp


示例15: Hit

// does the recursive (shadow rays & recursive/glossy rays) work
Vec3f RayTracer::TraceRay(const Ray &ray, Hit &hit, int bounce_count) const
{
        hit = Hit();
        bool intersect = CastRay(ray,hit,false);

        Vec3f answer(args->background_color_linear);

        if (intersect == true) {
                const Material *m = hit.getMaterial();
                assert (m != NULL);

                // rays coming from the light source are set to white, don't bother to ray trace further.
                if (m->getEmittedColor().Length() > 0.001) {
                        answer = Vec3f(1,1,1);
                } else {
                        // ambient light
                        answer = args->ambient_light_linear *
                                 m->getDiffuseColor(hit.get_s(),hit.get_t());

                        // Shadows
                        answer += shadows(ray, hit);

                        // Reflections
                        Vec3f reflectiveColor = m->getReflectiveColor();
                        double roughness = m->getRoughness();
                        if (bounce_count > 0 && reflectiveColor.Length() > MIN_COLOR_LEN) {
                        	answer += reflectiveColor * reflections(ray, hit, bounce_count, roughness);
                        }
                }
        }

        return answer;
}
开发者ID:linkinpark342,项目名称:parashader,代码行数:34,代码来源:raytracer.cpp


示例16: Vec3Df

Hit ComplexObject::intersectBoundingBox(Vec3Df origin, Vec3Df dest) {
  // Our implementation is based on the ray-box intersection algorithm
  // as proposed here: http://people.csail.mit.edu/amy/papers/box-jgt.pdf

  // This section should be stored in a ray datastructure where it's cached
  Vec3Df direction = dest - origin;
  Vec3Df inverseDirection = Vec3Df(1/direction[0], 1/direction[1], 1/direction[2]);
  int sign[3];
  sign[0] = (inverseDirection[0] < 0);
  sign[1] = (inverseDirection[1] < 0);
  sign[2] = (inverseDirection[2] < 0);

  // Intersection algorithm
  float xMin, yMin, zMin, xMax, yMax, zMax;
  xMin = (bounds[  sign[0]  ][0] - origin[0]) * inverseDirection[0];
  xMax = (bounds[ 1-sign[0] ][0] - origin[0]) * inverseDirection[0];
  yMin = (bounds[  sign[1]  ][1] - origin[1]) * inverseDirection[1];
  yMax = (bounds[ 1-sign[1] ][1] - origin[1]) * inverseDirection[1];
  zMin = (bounds[  sign[2]  ][2] - origin[2]) * inverseDirection[2];
  zMax = (bounds[ 1-sign[2] ][2] - origin[2]) * inverseDirection[2];
  if ( (xMin > yMax) || (yMin > xMax) ) return noHit;
  if (yMin > xMin) xMin = yMin;
  if (yMax < xMax) xMax = yMax;
  if ( (xMin > zMax) || (zMin > xMax) ) return noHit;
  if (zMin > xMin) xMin = zMin;
  if (zMax < xMax) xMax = zMax;
  return Hit(1, Vec3Df(xMin, yMin, zMin), nullVector, defaultMaterial);
}
开发者ID:thijser,项目名称:Computer-Graphics-raytracing,代码行数:28,代码来源:complexObject.cpp


示例17: vec3

std::vector<Hit>& Scene::getHitList(Ray* ray)
{
#ifdef _DEBUG_SCENE	
	std::cout << "\n+++++++++++++++++++++++++++++++++++++++++++++++++++\n";
	std::cout << "\nFrom: " << __FILE__;
	std::cout << "trying to get hit list\n";
	std::cout << "\n+++++++++++++++++++++++++++++++++++++++++++++++++++\n";
#endif	
	
	// interect all objects and check if there is an intersection and store result in hit list
	for (int i = 0; i < mObjectList.size(); i++) {
		double intersectD = mObjectList[i]->intersectObject(ray);				
		
		if (intersectD != NO_INTERSECTION) {
			vec3 intersectPoint = ray->getRayOrigin() + vec3(ray->getRayDirection().x * intersectD, 
												             ray->getRayDirection().y * intersectD,
													         ray->getRayDirection().z * intersectD);	
													         			
			mHitList.push_back( Hit(mObjectList[i], intersectD, intersectPoint) );
		} else {		
#ifdef _DEBUG_SCENE	
			std::cout << "\n+++++++++++++++++++++++++++++++++++++++++++++++++++\n";
			std::cout << "\nFrom: " << __FILE__;
			std::cout << "\nObject: " << OBJ_STR[mObjectList[i]->getObjectType()] << " does not intersect!";
			std::cout << "\n+++++++++++++++++++++++++++++++++++++++++++++++++++\n";
#endif			
		}		
	}
	
	return mHitList;
}
开发者ID:myk45,项目名称:DaRay,代码行数:31,代码来源:Scene.cpp


示例18: GetShipIndicesWeakestFirst

ShipBattle::Hits ShipBattle::GetHitsToDestroy(const Group& group, Dice& dice, int toHit) const
{
	const auto shipIndices = GetShipIndicesWeakestFirst(group);

	Hits hits;
	for (int shipIndex : shipIndices)
	{
		int lives = group.lifeCounts[shipIndex];
		Dice used = dice.Remove(lives, toHit);
		if (used.empty())
			break; // Can't destroy any more ships in this group. 

		// We can destroy this ship. 
		int damage = used.GetDamage();
		if (damage > lives) // Don't want to waste damage. Can we destroy a healthier ship? 
		{
			for (int shipIndex2 : shipIndices)
				if (group.lifeCounts[shipIndex2] == damage)
				{
					// We can destroy this one with no waste. 
					shipIndex = shipIndex2;
					lives = damage;
					break;
				}
		}

		hits.push_back(Hit(group.shipType, shipIndex, used));
	}
	return hits;
}
开发者ID:molip,项目名称:Eclipsoid,代码行数:30,代码来源:ShipBattle.cpp


示例19: Hit

FHitResult UGTTraceBase::SingleLineRangedTrace(const FVector& StartTrace, const FVector& EndTrace)
{
	FHitResult Hit(ForceInit);
	UWorld* world = GetWorld();
	if (!TraceInterface->GetGamePawn())
		return Hit;

	static FName PowerTag = FName(TEXT("SingleLineTrace"));
	FCollisionQueryParams TraceParams(PowerTag, false, TraceInterface->GetGamePawn());
	TraceParams.bTraceComplex = false;
	TraceParams.bTraceAsyncScene = false;
	TraceParams.bReturnPhysicalMaterial = true;
	
	if (bIgnoreSelf)
	{
		TraceParams.AddIgnoredActor(TraceInterface->GetGamePawn());
	}

	bool traceResult = GetWorld()->LineTraceSingle(Hit, StartTrace, EndTrace, TraceParams, CollisionObjectParams);
	if (bDrawDebug)
	{
		if (traceResult && Hit.bBlockingHit)
		{
			::DrawDebugLine(world, StartTrace, Hit.ImpactPoint, FColor::Red, false, 2);
			::DrawDebugLine(world, Hit.ImpactPoint, EndTrace, FColor::Green, false, 2);
			::DrawDebugPoint(world, Hit.ImpactPoint, 7, FColor::Red, false, 2);
		}
		else
		{
			::DrawDebugPoint(world, Hit.ImpactPoint, 15, FColor::Red, false, 2);
		}
	}
	return Hit;
}
开发者ID:Chooka,项目名称:ActionRPGGame,代码行数:34,代码来源:GTTraceBase.cpp


示例20: TraceParams

AActor* USCarryObjectComponent::GetActorInView()
{
	APawn* PawnOwner = Cast<APawn>(GetOwner());
	AController* Controller = PawnOwner->Controller;
	if (Controller == nullptr)
	{
		return nullptr;
	}

	FVector CamLoc;
	FRotator CamRot;
	Controller->GetPlayerViewPoint(CamLoc, CamRot);

	const FVector TraceStart = CamLoc;
	const FVector Direction = CamRot.Vector();
	const FVector TraceEnd = TraceStart + (Direction * MaxPickupDistance);

	FCollisionQueryParams TraceParams(TEXT("TraceActor"), true, PawnOwner);
	TraceParams.bTraceAsyncScene = true;
	TraceParams.bReturnPhysicalMaterial = false;
	TraceParams.bTraceComplex = false;

	FHitResult Hit(ForceInit);
	GetWorld()->LineTraceSingleByChannel(Hit, TraceStart, TraceEnd, ECC_Visibility, TraceParams);

	/* Check to see if we hit a staticmesh component that has physics simulation enabled */
	UStaticMeshComponent* MeshComp = Cast<UStaticMeshComponent>(Hit.GetComponent());
	if (MeshComp && MeshComp->IsSimulatingPhysics())
	{
		return Hit.GetActor();
	}

	return nullptr;
}
开发者ID:ntorkildson,项目名称:EpicSurvivalGameSeries,代码行数:34,代码来源:SCarryObjectComponent.cpp



注:本文中的Hit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ HootException函数代码示例发布时间:2022-05-30
下一篇:
C++ HiiSetString函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap