Ejemplo n.º 1
0
    private void ApplyRadialDamage(NvBlastActor actor, Vector3 localPosition, float minRadius, float maxRadius, float compressive)
    {
        _fractureBuffers.chunkFractureCount = _cubeAsset.solverAssetDesc.chunkCount;
        _fractureBuffers.bondFractureCount  = _cubeAsset.solverAssetDesc.bondCount;

        NvBlastExtRadialDamageDesc desc = new NvBlastExtRadialDamageDesc();

        desc.minRadius = minRadius;
        desc.maxRadius = maxRadius;
        desc.damage    = compressive;
        desc.p0        = localPosition.x;
        desc.p1        = localPosition.y;
        desc.p2        = localPosition.z;

        IntPtr dam = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NvBlastExtRadialDamageDesc)));

        Marshal.StructureToPtr(desc, dam, false);

        var damP = new NvBlastDamageProgram()
        {
            graphShaderFunction    = NvBlastExtShadersWrapper.NvBlastExtFalloffGraphShader,
            subgraphShaderFunction = NvBlastExtShadersWrapper.NvBlastExtFalloffSubgraphShader
        };
        var programParams = new NvBlastExtProgramParams()
        {
            damageDescBuffer = dam,
            material         = IntPtr.Zero,
            accelerator      = IntPtr.Zero
        };

        actor.GenerateFracture(_fractureBuffers, damP, programParams);
        actor.ApplyFracture(_fractureBuffers);
        if (_fractureBuffers.bondFractureCount + _fractureBuffers.chunkFractureCount > 0)
        {
            Split(actor);
        }

        Marshal.FreeHGlobal(dam);
    }
Ejemplo n.º 2
0
 public void GenerateFracture(NvBlastFractureBuffers buffers, NvBlastDamageProgram program, NvBlastExtProgramParams programParams)
 {
     NvBlastActorGenerateFracture(buffers, ptr, program, programParams, NvBlastWrapper.Log, null);
 }
Ejemplo n.º 3
0
 static extern void NvBlastActorGenerateFracture(NvBlastFractureBuffers commandBuffers, IntPtr actor, NvBlastDamageProgram program, NvBlastExtProgramParams programParams, NvBlastWrapper.NvBlastLog logFn, NvBlastTimers timers);