Beispiel #1
0
PNL_END
#endif

PNL_BEGIN

void pnlRandNormal(floatVector* vls, floatVector &mean, floatVector &sigma )
{
    int myid = PAR_OMP_NUM_CURR_THREAD;
    
    int nEl = mean.size();
    vls->resize(nEl);
    if( nEl > 1 )
    {
        floatVector normVls(nEl);
        //vsRngGaussian( VSL_METHOD_SGAUSSIAN_BOXMULLER2, g_RNG[myid].m_vslStream, nEl, &normVls.front(), 0, 1 );
        pnlRandNormal(nEl,&normVls.front(), 0, 1);
        
        CxMat matNormVls  = cxMat( nEl, 1, CX_32FC1, &normVls.front() ); 
        
        CxMat matMean = cxMat( nEl, 1, CX_32FC1, &mean.front() );
        CxMat matCov  = cxMat( nEl, nEl, CX_32FC1, &sigma.front() );
        
        floatVector evecData( nEl*nEl );
        CxMat evecMat = cxMat( nEl, nEl, CX_32FC1, &evecData.front() );
        
        floatVector evalData( nEl*nEl );
        CxMat evalMat = cxMat( nEl, nEl,  CX_32FC1, &evalData.front() );
        
        
        cxSVD( &matCov, &evalMat, &evecMat,  NULL, CX_SVD_MODIFY_A   ); 
        
        int i;
        for( i = 0; i < nEl; i++)
        {
            evalData[i*(nEl+1)] = float( sqrt( evalData[i*(nEl+1)] ) );
        }
        
        
        CxMat *prodMat1 = cxCreateMat( nEl, nEl, CX_32FC1 );
        cxMatMul( &evecMat, &evalMat, prodMat1 );
        
        
        CxMat matResultVls  = cxMat( nEl, 1, CX_32FC1, &(vls->front()) ); 
        
        cxMatMulAdd( prodMat1, &matNormVls, &matMean, &matResultVls );
        cxReleaseMat( &prodMat1 );
        
    }
    else
    {
        
        //vsRngGaussian( VSL_METHOD_SGAUSSIAN_BOXMULLER2, g_RNG[myid].m_vslStream, 1,
        //    &(vls->front()), mean.front(), sigma.front() );
        vls->front() = pnlRandNormal( mean.front(), sigma.front() );
    }
}
void UGAAttributeComponent::ModifyAttributesOnSelf(const FGAAttributeData& EvalData, const FGAEffectContext& Context,
	const FGameplayTagContainer& EffectTags, FGAEffectHandle& HandleIn)
{
	//incoming
	ModifiedAttribute.Mods.Empty();
	FGAAttributeData FinalData = DefaultAttributes->PreModifyAttribute(EvalData);
	FGAAttributeBase* attr = DefaultAttributes->GetAttribute(FinalData.Attribute);
	float newValue = 0;
	if (attr)
	{
		if (HandleIn.IsValid())
		{
			DefaultAttributes->SetAttributeAdditiveBonus(FinalData.Attribute, FinalData.Value);
		}
	}
	else
	{
		//newValue = DefaultAttributes->AttributeOperation(FinalData.Attribute, FinalData.Value, FinalData.Mod);
		FGAEvalData evalData(FinalData.Attribute, FinalData.Mod, FinalData.AttributeTag, FinalData.Value);
		float finalValue = DefaultAttributes->UpdateAttributes(evalData, FinalData.Value);
		FGAModifiedAttribute ModdedAttrRep;
		ModdedAttrRep.Attribute = FinalData.Attribute;
		ModdedAttrRep.InstigatorLocation = Context.Instigator->GetActorLocation();
		ModdedAttrRep.TargetLocation = Context.TargetHitLocation;//AttributeIn.Target->GetActorLocation();
		ModdedAttrRep.ModifiedByValue = finalValue;
		ModdedAttrRep.ReplicationCounter = FMath::RandRange(0,255);
		ModdedAttrRep.Causer = Context.InstigatorComp;
		ModifiedAttribute.ForceUpdate++;
		ModifiedAttribute.Mods.Add(ModdedAttrRep);
	}
	if (GetNetMode() == ENetMode::NM_Standalone)
	{
		for (FGAModifiedAttribute& attr : ModifiedAttribute.Mods)
		{
			Context.InstigatorComp->OnAttributeModifed.Broadcast(attr);
		}
	}
}