218 lines
7.6 KiB
C++
218 lines
7.6 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;
|
|
}
|
|
// SD = Weight(grains) / (7000 * Diameter^2(inches))
|
|
return GrainWeight / (7000.0f * DiameterInches * DiameterInches);
|
|
}
|
|
|
|
// 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;
|
|
|
|
// 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;
|
|
}
|
|
};
|
|
|
|
UCLASS(BlueprintType)
|
|
class EASYBALLISTICS_API UEBBulletPropertiesAsset : public UDataAsset
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
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";
|
|
}; |