272 lines
11 KiB
C++
272 lines
11 KiB
C++
// Copyright 2016 Mookie. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "Engine/DataAsset.h"
|
|
#include "EBBulletProperties.generated.h"
|
|
|
|
UENUM(BlueprintType)
|
|
enum class EBulletType : uint8
|
|
{
|
|
BT_FullMetalJacket UMETA(DisplayName = "Full Metal Jacket"),
|
|
BT_HollowPoint UMETA(DisplayName = "Hollow Point"),
|
|
BT_SoftPoint UMETA(DisplayName = "Soft Point"),
|
|
BT_ArmorPiercing UMETA(DisplayName = "Armor Piercing"),
|
|
BT_ArmorPiercingIncendiary UMETA(DisplayName = "Armor Piercing Incendiary"),
|
|
BT_Tracer UMETA(DisplayName = "Tracer"),
|
|
BT_Match UMETA(DisplayName = "Match Grade"),
|
|
BT_Frangible UMETA(DisplayName = "Frangible"),
|
|
BT_LeadRoundNose UMETA(DisplayName = "Lead Round Nose"),
|
|
BT_Wadcutter UMETA(DisplayName = "Wadcutter"),
|
|
BT_SemiWadcutter UMETA(DisplayName = "Semi-Wadcutter"),
|
|
BT_Custom UMETA(DisplayName = "Custom")
|
|
};
|
|
|
|
UENUM(BlueprintType)
|
|
enum class EBulletMaterial : uint8
|
|
{
|
|
BM_Lead UMETA(DisplayName = "Lead"),
|
|
BM_LeadAntimony UMETA(DisplayName = "Lead-Antimony"),
|
|
BM_Copper UMETA(DisplayName = "Copper"),
|
|
BM_CopperJacket UMETA(DisplayName = "Copper Jacket"),
|
|
BM_Brass UMETA(DisplayName = "Brass"),
|
|
BM_Steel UMETA(DisplayName = "Steel"),
|
|
BM_Tungsten UMETA(DisplayName = "Tungsten"),
|
|
BM_Bismuth UMETA(DisplayName = "Bismuth"),
|
|
BM_Zinc UMETA(DisplayName = "Zinc"),
|
|
BM_Custom UMETA(DisplayName = "Custom")
|
|
};
|
|
|
|
USTRUCT(BlueprintType)
|
|
struct FMathematicalBulletProperties
|
|
{
|
|
GENERATED_USTRUCT_BODY()
|
|
|
|
// Basic Properties
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Basic Properties", meta = (ToolTip = "Bullet weight in grains (1 grain = 0.0647989 grams)"))
|
|
float GrainWeight = 55.0f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Basic Properties", meta = (ToolTip = "Bullet diameter in inches"))
|
|
float DiameterInches = 0.224f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Basic Properties", meta = (ToolTip = "Bullet length in inches"))
|
|
float LengthInches = 0.825f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Basic Properties")
|
|
EBulletType BulletType = EBulletType::BT_FullMetalJacket;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Basic Properties")
|
|
EBulletMaterial BulletMaterial = EBulletMaterial::BM_CopperJacket;
|
|
|
|
// Ballistic Coefficient
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Ballistics", meta = (ToolTip = "G1 Ballistic Coefficient"))
|
|
float BallisticCoefficientG1 = 0.151f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Ballistics", meta = (ToolTip = "G7 Ballistic Coefficient"))
|
|
float BallisticCoefficientG7 = 0.076f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Ballistics", meta = (ToolTip = "Use G7 model instead of G1"))
|
|
bool UseG7Model = false;
|
|
|
|
// Sectional Density
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Ballistics", meta = (ToolTip = "Sectional density (calculated automatically if zero)"))
|
|
float SectionalDensity = 0.0f;
|
|
|
|
// Penetration Properties
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Penetration", meta = (ToolTip = "Bullet hardness (HB - Brinell Hardness)"))
|
|
float BulletHardness = 15.0f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Penetration", meta = (ToolTip = "Kinetic energy threshold for penetration (ft-lbs)"))
|
|
float PenetrationEnergyThreshold = 58.0f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Penetration", meta = (ToolTip = "Expansion threshold velocity (fps)"))
|
|
float ExpansionVelocityThreshold = 1800.0f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Penetration", meta = (ToolTip = "Maximum expansion diameter multiplier"))
|
|
float MaxExpansionMultiplier = 1.5f;
|
|
|
|
// Constructor
|
|
FMathematicalBulletProperties()
|
|
{
|
|
GrainWeight = 55.0f;
|
|
DiameterInches = 0.224f;
|
|
LengthInches = 0.825f;
|
|
BulletType = EBulletType::BT_FullMetalJacket;
|
|
BulletMaterial = EBulletMaterial::BM_CopperJacket;
|
|
BallisticCoefficientG1 = 0.151f;
|
|
BallisticCoefficientG7 = 0.076f;
|
|
UseG7Model = false;
|
|
SectionalDensity = 0.0f;
|
|
BulletHardness = 15.0f;
|
|
PenetrationEnergyThreshold = 58.0f;
|
|
ExpansionVelocityThreshold = 1800.0f;
|
|
MaxExpansionMultiplier = 1.5f;
|
|
}
|
|
|
|
// Calculate sectional density if not provided
|
|
float GetSectionalDensity() const
|
|
{
|
|
if (SectionalDensity > 0.0f)
|
|
{
|
|
return SectionalDensity;
|
|
}
|
|
// Traditional SD = Weight(grains) / (7000 * Diameter^2(inches)) - dimensionless
|
|
return GrainWeight / (7000.0f * DiameterInches * DiameterInches);
|
|
}
|
|
|
|
// Calculate sectional density in proper SI units (kg/m²) for mathematical ballistics
|
|
float GetSectionalDensityKgPerM2() const
|
|
{
|
|
float MassKg = GetMassKg();
|
|
float DiameterM = DiameterInches * 0.0254f; // Convert inches to meters
|
|
float CrossSectionM2 = 3.14159f * (DiameterM/2.0f) * (DiameterM/2.0f);
|
|
return MassKg / CrossSectionM2;
|
|
}
|
|
|
|
// Calculate mass in kilograms
|
|
float GetMassKg() const
|
|
{
|
|
// 1 grain = 0.0647989 grams
|
|
return GrainWeight * 0.0647989f / 1000.0f;
|
|
}
|
|
|
|
// Calculate diameter in centimeters
|
|
float GetDiameterCm() const
|
|
{
|
|
// 1 inch = 2.54 cm
|
|
return DiameterInches * 2.54f;
|
|
}
|
|
|
|
// Calculate cross-sectional area in square centimeters
|
|
float GetCrossSectionCm2() const
|
|
{
|
|
float radiusCm = GetDiameterCm() / 2.0f;
|
|
return 3.14159f * radiusCm * radiusCm;
|
|
}
|
|
};
|
|
|
|
USTRUCT(BlueprintType)
|
|
struct FMathematicalMaterialProperties
|
|
{
|
|
GENERATED_USTRUCT_BODY()
|
|
|
|
// Material Properties
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Material Properties", meta = (ToolTip = "Material density in g/cm³"))
|
|
float DensityGPerCm3 = 7.85f; // Steel
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Material Properties", meta = (ToolTip = "Material hardness (HB - Brinell Hardness)"))
|
|
float MaterialHardness = 200.0f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Material Properties", meta = (ToolTip = "Tensile strength in MPa"))
|
|
float TensileStrengthMPa = 400.0f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Material Properties", meta = (ToolTip = "Yield strength in MPa"))
|
|
float YieldStrengthMPa = 250.0f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Material Properties", meta = (ToolTip = "Modulus of elasticity in GPa"))
|
|
float ElasticModulusGPa = 200.0f;
|
|
|
|
// Ballistic Properties
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Ballistic Properties", meta = (ToolTip = "Ballistic limit velocity (fps)"))
|
|
float BallisticLimitVelocity = 2000.0f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Ballistic Properties", meta = (ToolTip = "Perforation coefficient"))
|
|
float PerforationCoefficient = 1.0f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Ballistic Properties", meta = (ToolTip = "Energy absorption coefficient"))
|
|
float EnergyAbsorptionCoefficient = 0.7f;
|
|
|
|
// Spalling Properties
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spalling Properties", meta = (ToolTip = "Enable mathematical spalling calculations"))
|
|
bool EnableMathematicalSpalling = false;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spalling Properties", meta = (EditCondition = "EnableMathematicalSpalling", ToolTip = "Spall strength in MPa (material resistance to spalling)"))
|
|
float SpallStrengthMPa = 150.0f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spalling Properties", meta = (EditCondition = "EnableMathematicalSpalling", ToolTip = "Critical stress factor for spalling initiation"))
|
|
float CriticalStressFactor = 2.5f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spalling Properties", meta = (EditCondition = "EnableMathematicalSpalling", ToolTip = "Fragment velocity efficiency (0-1)"))
|
|
float FragmentVelocityEfficiency = 0.25f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spalling Properties", meta = (EditCondition = "EnableMathematicalSpalling", ToolTip = "Average fragment mass ratio"))
|
|
float AverageFragmentMassRatio = 0.08f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spalling Properties", meta = (EditCondition = "EnableMathematicalSpalling", ToolTip = "Fragment size distribution exponent"))
|
|
float FragmentSizeExponent = -1.6f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spalling Properties", meta = (EditCondition = "EnableMathematicalSpalling", ToolTip = "Maximum fragment count per unit area"))
|
|
float MaxFragmentDensity = 50.0f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Material Properties", meta = (ToolTip = "Poisson ratio (dimensionless)"))
|
|
float PoissonRatio = 0.3f;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Material Properties", meta = (ToolTip = "Longitudinal wave speed in the material (m/s)"))
|
|
float WaveSpeedMPerS = 5900.f; // steel approx
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Material Properties", meta = (ToolTip = "Ultimate tensile strength MPa"))
|
|
float UltimateTensileStrengthMPa = 500.f;
|
|
|
|
// Backing liner efficiency (0-1) for spall liner or composite backing. 1 = no liner, 0 = perfect absorption
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Material Properties", meta = (ToolTip = "Efficiency factor of any backing liner (1.0 = none, lower = more spall reduction)"))
|
|
float BackingLinerEfficiency = 1.0f;
|
|
|
|
// Constructor with default steel properties
|
|
FMathematicalMaterialProperties()
|
|
{
|
|
DensityGPerCm3 = 7.85f; // Steel
|
|
MaterialHardness = 200.0f;
|
|
TensileStrengthMPa = 400.0f;
|
|
YieldStrengthMPa = 250.0f;
|
|
ElasticModulusGPa = 200.0f;
|
|
BallisticLimitVelocity = 2000.0f;
|
|
PerforationCoefficient = 1.0f;
|
|
EnergyAbsorptionCoefficient = 0.7f;
|
|
EnableMathematicalSpalling = false;
|
|
SpallStrengthMPa = 150.0f;
|
|
CriticalStressFactor = 2.5f;
|
|
FragmentVelocityEfficiency = 0.25f;
|
|
AverageFragmentMassRatio = 0.08f;
|
|
FragmentSizeExponent = -1.6f;
|
|
MaxFragmentDensity = 50.0f;
|
|
}
|
|
};
|
|
|
|
UCLASS(BlueprintType)
|
|
class EASYBALLISTICS_API UEBBulletPropertiesAsset : public UDataAsset
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawning", meta = (ToolTip = "The bullet actor to spawn."))
|
|
TSubclassOf<class AEBBullet> BulletClass;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Bullet Properties")
|
|
FMathematicalBulletProperties BulletProperties;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Description")
|
|
FString BulletName = "5.56x45mm NATO";
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Description")
|
|
FString Manufacturer = "Generic";
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Description")
|
|
FString Description = "Standard 5.56x45mm NATO round";
|
|
};
|
|
|
|
UCLASS(BlueprintType)
|
|
class EASYBALLISTICS_API UEBMaterialPropertiesAsset : public UDataAsset
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Material Properties")
|
|
FMathematicalMaterialProperties MaterialProperties;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Description")
|
|
FString MaterialName = "Steel";
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Description")
|
|
FString Description = "Standard structural steel";
|
|
}; |