Merge branch 'vehicledamage' of https://github.com/acemod/ACE3 into vehicledamage

This commit is contained in:
Nou 2015-05-15 17:22:54 -07:00
commit 38b15d61b3
12 changed files with 81 additions and 39 deletions

View File

@ -17,7 +17,7 @@ GVAR(debug_log) = [];
#endif
#ifdef DEBUG_EXTENSION_DYNLOAD
// This value is used for debug loading of the extension with dynload
GVAR(extensionLibrary) = "z\ace\extensions\build\vd\Debug\ace_vd.dll";
GVAR(extensionLibrary) = "z\ace\extensions\build\vd\Debug\ace_vd_Debug.dll";
#endif
// Extension dispatch events

View File

@ -4,7 +4,6 @@ PARAMS_5(_unit,_selectionName,_damage,_source,_projectile);
private["_currentDmgCount", "_hitpointCount", "_dmgId", "_dmgVarName", "_dmgArray"];
// Disable handledamage for now
if(true) exitWith { 0 };
_hitpointCount = _unit getVariable[QGVAR(hitpointCount), -1];
_currentDmgCount = _unit getVariable[QGVAR(currentDmgCount), -1];

View File

@ -6,8 +6,9 @@
#define __PROJECTILE_CLASS configFile >> "CfgAmmo" >> (_ammo select 4)
private["_impactSurfaceType", "_isDirectHit", "_command", "_model", "_projectileType"];
private["_relProjectilePos", "_relProjectileVelocity", "_projectilePosition", "_relImpactVelPos", "_relImpactVelocity", "_relSurfDirectionPos", "_relSurfaceDirection"];
private["_penetrationOrthogonalDepth", "_penetrationAngleDepth", "_penetrationCosAngle", "_projectileCaliber", "_projectileDensity", "_projectileLength", "_armorDensity"];
EXPLODE_9_PVT((_this select 0),_vehicle,_shooter,_projectile,_impactPosition,_projectileVelocity,_selection,_ammo,_surfaceDirection,_radius);
EXPLODE_9_PVT((_this select 0),_vehicle,_shooter,_projectile,_impactPosition,_impactVelocity,_selection,_ammo,_surfaceDirection,_radius);
_impactSurfaceType = (_this select 0) select 9;
_isDirectHit = (_this select 0) select 10;
TRACE_2("",_impactSurfaceType,_isDirectHit);
@ -33,6 +34,23 @@ if(_projectileLength == 0) then {
_vehicleId = _vehicle getVariable[QGVAR(id), -1];
// The below didn't work
//#define RELATIVE_VECTOR_TEXT(o,x) ([(o worldToModelVisual ((x) call EFUNC(common,ASLToPosition)))] call FUNC(_textVector))
// Get a relative velocity!?!?
_relImpactPosition = _vehicle worldToModelVisual _impactPosition;
_projectilePosition = _vehicle worldToModelVisual (position _projectile);
_relProjectilePos = (position _projectile) vectorAdd (velocity _projectile);
_relProjectileVelocity = _projectilePosition vectorFromTo (_vehicle modelToWorldVisual _relProjectilePos);
_relImpactVelPos = _impactPosition vectorAdd _impactVelocity;
_relImpactVelocity = _relImpactPosition vectorFromTo (_vehicle modelToWorldVisual _relImpactVelPos);
_relSurfDirectionPos = _impactPosition vectorAdd _surfaceDirection;
_relSurfaceDirection = _relImpactPosition vectorFromTo (_vehicle modelToWorldVisual _relSurfDirectionPos);
_command = format["hit:%1,%2,%3,%4,%5,%6,%7,%8,%9,%10,%11,%12,%13,%14,%15,%16,%17,%18",
_vehicleId, // vehicle id registered
// _model, _selection,
@ -42,12 +60,12 @@ _command = format["hit:%1,%2,%3,%4,%5,%6,%7,%8,%9,%10,%11,%12,%13,%14,%15,%16,%1
_projectileType, //projectile type id
(_ammo select 4), _projectileLength, _projectileDiameter, _projectileDensity,
_frastumLength, _frastumDiameter,
VECTOR_TEXT(_projectileVelocity),
RELATIVE_VECTOR_TEXT(_vehicle,getPosASL _projectile),
VECTOR_TEXT(_relProjectileVelocity),
VECTOR_TEXT(_projectilePosition),
VECTOR_TEXT(vectorDir _projectile),
VECTOR_TEXT(_surfaceDirection),
RELATIVE_VECTOR_TEXT(_vehicle,_impactPosition),
VECTOR_TEXT(_projectileVelocity)
VECTOR_TEXT(_relSurfaceDirection),
VECTOR_TEXT(_relImpactPosition),
VECTOR_TEXT(_relImpactVelocity)
];
TRACE_1("", _command);
_result = _command call FUNC(callExtension);

View File

@ -13,7 +13,6 @@
#define CALL_EXT(x) "ace_vd" callExtension x
#define VECTOR_TEXT(x) ([(x)] call FUNC(_textVector))
#define RELATIVE_VECTOR_TEXT(o,x) ([(o worldToModelVisual ((x) call EFUNC(common,ASLToPosition)))] call FUNC(_textVector))
#define DEBUG_EXTENSION_DYNLOAD
#define DEBUG_LOG_EXTENSION

View File

@ -35,10 +35,7 @@ include_directories("common")
if(USE_BULLET)
# Dependencies
#
set(BACKUP_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
set(BACKUP_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(BACKUP_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
add_definitions(-DUSE_DIRECTX)
add_subdirectory(lib/bullet3)
@ -66,10 +63,11 @@ if(USE_BULLET)
set_target_properties(OpenGLWindow PROPERTIES FOLDER Bullet3)
set_target_properties(LinearMath PROPERTIES FOLDER Bullet3)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${BACKUP_ARCHIVE_OUTPUT_DIRECTORY})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BACKUP_LIBRARY_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BACKUP_RUNTIME_OUTPUT_DIRECTORY})
SET (LIBRARY_OUTPUT_PATH "" CACHE PATH "Reset bullet paths")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "")
include_directories(BEFORE "lib/bullet3/src")
endif()
if(USE_DIRECTX)

View File

@ -284,8 +284,7 @@ namespace ace {
_pImmediateContext->ClearRenderTargetView(_pRenderTargetView, Colors::MidnightBlue);
_pImmediateContext->ClearDepthStencilView(_pDepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0);
update_camera();
step();
_pSwapChain->Present(0, 0);
@ -390,6 +389,9 @@ namespace ace {
break;
}
}
update_camera();
} else if (raw->header.dwType == RIM_TYPEMOUSE) {
RAWMOUSE mouseCurrState = raw->data.mouse;
@ -405,8 +407,9 @@ namespace ace {
_camera.camYaw += mouseCurrState.lLastX * 0.005f;
_camera.camPitch += mouseCurrState.lLastY * 0.005f;
_last_mouse_state = mouseCurrState;
}
update_camera();
}
}
delete[] lpb;

View File

@ -3,5 +3,16 @@ init:
debug_render:
register_vehicle:\A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, 1, 4046.21;3902.56;5.075
#set_animation_state:1,damageHide, 0, Wheel_kolL1, 0, Wheel_koloL1, 0, Wheel_podkoloL1, 1, Wheel_kolP1, 0, Wheel_koloP1, 0, Wheel_podkoloP1, 1, Wheel_kolL2, 0, Wheel_kolP2, 0, Wheel_koloL2, 0, Wheel_koloL3, 0, Wheel_koloL4, 0, Wheel_koloL5, 0, Wheel_koloL6, 0, Wheel_koloL7, 0, Wheel_koloP2, 0, Wheel_koloP3, 0, Wheel_koloP4, 0, Wheel_koloP5, 0, Wheel_koloP6, 0, Wheel_koloP7, 0, Wheel_podkoloL2, 1, Wheel_podkoloL3, 1, Wheel_podkoloL4, 1, Wheel_podkoloL5, 0, Wheel_podkoloL6, 0, Wheel_podkoloP2, 1, Wheel_podkoloP3, 1, Wheel_podkoloP4, 1, Wheel_podkoloP5, 0, Wheel_podkoloP6, 1, podkoloL1_hide_damage, 0, podkoloL2_hide_damage, 0, podkoloL3_hide_damage, 0, podkoloL4_hide_damage, 0, podkoloL5_hide_damage, 0, podkoloL6_hide_damage, 0, podkoloL7_hide_damage, 0, podkoloL8_hide_damage, 0, podkoloP1_hide_damage, 0, podkoloP2_hide_damage, 0, podkoloP3_hide_damage, 0, podkoloP4_hide_damage, 0, podkoloP5_hide_damage, 0, podkoloP6_hide_damage, 0, podkoloP7_hide_damage, 0, podkoloP8_hide_damage, 0, damageVez, 0, MainTurret, -3, MainGun, 0, Recoil, 0, ObsTurret, -0, ObsGun, 0, MainGunOptics, 0, Wheel_podkoloP7, 0, Wheel_podkoloL7, 0, HatchDriver, 0, HatchCommander, 0, HatchGunner, 0, damageVezVelitele, 0, poklop_commander_damage, 0, poklop_gunner_damage, 0, poklop_driver_damage, 0, zaslehROT_HMG, 101, zaslehROT_coax, 16, cannon_muzzle_flash, 0, zaslehROT_cannon, 956, HideHull, 1, HideTurret, 1, LockMuzzle, 0
#hit:1,1,2,3,4,5,6,7,8,9,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,11,1,1,1,1,1,1
set_vehicle_state:1,0;-20;0,0;0;0,0;0;0
#set_vehicle_state:1,0;-20;0,0;0;0,0;0;0
hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, BALLS, 0.984808;0.173648;-0.000321539, 0.000336425;-5.62874e-005;1, 0, B_65x39_Caseless, 32893, 6706, 11300, 0, 0, 0.000173648;-0.000984808;-1.13852e-007, 1.90674;-2.97705;-1.01589, 9.3088e-005;0.999998;0.00182291, 0.997565;0.0697389;0.00040539, 2.1709;-3.00732;3.9504, 0.996985;0.0775994;0.000355178
hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, BALLS, 0.984808;0.173648;-0.000321539, 0.000336425;-5.62874e-005;1, 0, B_65x39_Caseless, 32893, 6706, 11300, 0, 0, 0.000173648;-0.000984808;-1.13852e-007, 1.90674;-2.97705;-1.01589, 9.3088e-005;0.999998;0.00182291, 0.997565;0.0697387;0.000405358, 1.90527;-2.97852;3.94798, 0.997251;0.0740926;0.000152842
hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, BALLS, 0.984803;0.173649;-0.00285841, 0.00294448;-0.000238045;0.999996, 0, B_65x39_Caseless, 32893, 6706, 11300, 0, 0, 7.61759e-005;-0.000997094;-4.61654e-007, 1.77954;-2.83154;-0.219069, -0.0380967;0.999228;0.00961505, 0.997566;0.069721;-0.00105282, 1.7749;-2.8457;4.74479, 0.996762;0.0804012;-0.000602539
hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, BALLS, 0.984803;0.173649;-0.00284932, 0.00294109;-0.000271166;0.999995, 0, B_65x39_Caseless, 32893, 6706, 11300, 0, 0, 0.000173647;-0.000984808;-7.73569e-007, 1.82178;-1.9292;-0.268372, -0.0288651;0.999542;0.00905338, 0.997581;0.0695041;-0.00106295, 1.81689;-1.94336;4.69548, 0.996832;0.079526;-0.000653841
hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, BALLS, 0.984803;0.173649;-0.00284391, 0.00293735;-0.000281132;0.999996, 0, B_65x39_Caseless, 32893, 6706, 11300, 0, 0, 0.000173647;-0.000984808;-7.85849e-007, 1.84595;-2.57471;-2.50434, -0.0354257;0.999277;-0.0138109, 0.997571;0.0696509;-0.00106625, 1.84106;-2.58887;2.45951, 0.99678;0.0801495;-0.00236906
hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, BALLS, 0.984803;0.173649;-0.00284275, 0.00293741;-0.000288139;0.999996, 0, B_65x39_Caseless, 32893, 6706, 11300, 0, 0, 0.000173647;-0.000984808;-7.92519e-007, 1.90674;-2.85693;-0.816221, -0.0381079;0.999267;0.00357182, 0.997566;0.069714;-0.00106831, 2.16724;-2.90381;4.15556, 0.996761;0.08041;-0.00106769
hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, BALLS, 0.984803;0.173649;-0.00284275, 0.00293741;-0.000288139;0.999996, 0, B_65x39_Caseless, 32893, 6706, 11300, 0, 0, 0.000173647;-0.000984808;-7.92519e-007, 1.90674;-2.85693;-0.816221, -0.0381079;0.999267;0.00357182, 0.997566;0.0697129;-0.00106831, 1.90186;-2.87109;4.14763, 0.997275;0.0737539;-0.00188146
hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, BALLS, 0.984803;0.173649;-0.002843, 0.00293819;-0.000291138;0.999996, 0, B_65x39_Caseless, 32893, 6706, 11300, 0, 0, 0.000173647;-0.000984808;-7.95372e-007, 1.67578;-2.15332;-2.30106, -0.0313568;0.99944;-0.0117081, 0.997577;0.0695593;-0.00107051, 1.6709;-2.16797;2.6628, 0.996812;0.0797612;-0.00221558
hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, BALLS, 0.984803;0.173649;-0.00284299, 0.00293839;-0.0002923;0.999996, 2, Sh_120mm_APFSDS_Tracer_Yellow, 65, 27, 0, 0, 0, -94.1198;1574.74;-13.4215, -3.81567;-2.31543;-0.841839, -0.0666772;0.997769;-0.00347184, 0.997565;0.0697371;-0.00107085, 2.16748;-3.00537;4.17418, 0.995139;0.0984623;-0.00199962
hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, BALLS, 0.984803;0.173649;-0.00284299, 0.00293839;-0.0002923;0.999996, 2, Sh_120mm_APFSDS_Tracer_Yellow, 65, 27, 0, 0, 0, -94.1198;1574.74;-13.4215, -3.81567;-2.31543;-0.841839, -0.0666772;0.997769;-0.00347184, 0.997565;0.069737;-0.00107086, 1.90186;-2.97705;4.17292, 0.995158;0.0982686;-0.00206677
hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, BALLS, 0.984803;0.173649;-0.00284299, 0.00293839;-0.0002923;0.999996, 2, Sh_120mm_APFSDS_Tracer_Yellow, 65, 27, 0, 0, 0, -94.1198;1574.74;-13.4215, -3.81567;-2.31543;-0.841839, -0.0666772;0.997769;-0.00347184, 0.997565;0.0697312;-0.00107094, -1.75977;-2.56689;4.15401, 0.995311;0.0967058;-0.00210695
hit:1, \A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, BALLS, 0.984803;0.173649;-0.00284299, 0.00293839;-0.0002923;0.999996, 2, Sh_120mm_APFSDS_Tracer_Yellow, 65, 27, 0, 0, 0, -94.1198;1574.74;-13.4215, -3.81567;-2.31543;-0.841839, -0.0666772;0.997769;-0.00347184, 0.997565;0.0697306;-0.00107095, -2.08813;-2.5293;4.15127, 0.995439;0.0953656;-0.00261482

View File

@ -46,11 +46,7 @@ namespace ace {
// @TODO: This is moving it in the bullet world for handling multiple collisions, instead our raytests need to ignore ALL but this type. How do we do that?
// For now this only works for single-object collisions then
// Set 3d world bullet position based on game position
btTransform transform = bt_object->getWorldTransform();
transform.setOrigin(btVector3(position_.x(), position_.y(), position_.z()));
bt_object->setWorldTransform(transform);
controller::get().bt_world->addCollisionObject(bt_object.get());
}
base_vehicle::~base_vehicle() {

View File

@ -45,6 +45,7 @@ namespace ace {
add("selection_position", std::bind(&ace::vehicledamage::controller::selection_position, this, std::placeholders::_1, std::placeholders::_2));
#ifdef _DEBUG
add("bullet_debug", std::bind(&ace::vehicledamage::controller::_debug_render_bullet, this, std::placeholders::_1, std::placeholders::_2));
add("debug_render", std::bind(&ace::vehicledamage::controller::_debug_render, this, std::placeholders::_1, std::placeholders::_2));
add("test_raycast", std::bind(&ace::vehicledamage::controller::_test_raycast, this, std::placeholders::_1, std::placeholders::_2));
add("test_selection", std::bind(&ace::vehicledamage::controller::_test_selection, this, std::placeholders::_1, std::placeholders::_2));
@ -252,6 +253,11 @@ namespace ace {
bool controller::_debug_render(const arguments &_args, std::string & result) {
_debug_display->render_thread(1024, 768, false);
return true;
}
bool controller::_debug_render_bullet(const arguments &_args, std::string & result) {
_debug_display->_enable_bullet_debug = true;
return true;
}
#endif

View File

@ -43,6 +43,7 @@ namespace ace {
#if defined(DEVEL) && defined(USE_DIRECTX)
bool _debug_render(const arguments &, std::string &);
bool _debug_render_bullet(const arguments &, std::string &);
std::unique_ptr<debug::penetration_display> _debug_display;
#endif

View File

@ -7,7 +7,7 @@
namespace ace {
namespace vehicledamage {
namespace debug {
penetration_display::penetration_display() :
penetration_display::penetration_display() : _enable_bullet_debug(false),
dispatcher() {
_active_vehicle = nullptr;
@ -26,13 +26,13 @@ namespace ace {
btVector3 vectorFrom(5, 20, 0);
btVector3 vectorTo = _vehicle->second->bt_object->getWorldTransform().getOrigin();
btVector3 direction = vectorTo - vectorFrom;
btVector3 direction = vectorFrom - vectorTo;
XMVECTORF32 eyePos = { vectorFrom.x(), vectorFrom.y(), vectorFrom.z() };
XMVECTORF32 eyeDir = { direction.x(), direction.y(), direction.z() };
XMVECTORF32 up = { 0.f, 1.f, 0.f };
XMStoreFloat4x4(&_View, XMMatrixLookAtLH(eyePos, eyeDir, up));
XMStoreFloat4x4(&_View, XMMatrixLookAtLH(eyePos, XMVectorZero(), up));
return true;
}
@ -111,24 +111,25 @@ namespace ace {
_Batch->End();
// Draw the bullet world
// The BT debug drawing is a single batch
_Batch->Begin();
ace::vehicledamage::controller::get().bt_world->debugDrawWorld();
_Batch->End();
if (_enable_bullet_debug) {
_Batch->Begin();
ace::vehicledamage::controller::get().bt_world->debugDrawWorld();
_Batch->End();
}
if (_active_vehicle) {
DrawObject(_active_vehicle->fire_lod, *_Batch, *_active_vehicle->object, Colors::GhostWhite);
}
if (_active_hits.size() > 0) {
DrawHits(0, *_Batch, Colors::Red);
DrawHits(0, *_Batch, Colors::Yellow);
for (auto & hit : _active_hits) {
std::vector<ace::vector3<float>> collisions;
_active_vehicle->surface_raycast(hit->impactposition, hit->impactvelocity, collisions);
DrawCollisions(collisions, *_Batch, Colors::Purple);
//_active_vehicle->surface_raycast(hit->impactposition, hit->impactvelocity, collisions);
//DrawCollisions(collisions, *_Batch, Colors::Purple);
}
}
@ -166,10 +167,11 @@ namespace ace {
batch.Begin();
for (gamehit_p & hit : _active_hits) {
ace::vector3<float> hit_from, hit_to;
ace::vector3<float> hit_from, hit_to, hit_surface;
hit_from = hit->impactposition;
hit_to = hit_from + (hit->impactvelocity * 0.01f);
hit_to = hit_from + hit->impactvelocity;
hit_surface = hit_from + hit->surface;
XMVECTORF32 from = { hit_from.x(), hit_from.y(), hit_from.z() };
XMVECTORF32 to = { hit_to.x(), hit_to.y(), hit_to.z() };
@ -178,6 +180,13 @@ namespace ace {
VertexPositionColor v2(to, color);
batch.DrawLine(v1, v2);
XMVECTORF32 surface_direction = { hit_surface.x(), hit_surface.y(), hit_surface.z() };
VertexPositionColor v1_surf(from, Colors::LightGreen);
VertexPositionColor v2_surf(surface_direction, Colors::LightGreen);
batch.DrawLine(v1_surf, v2_surf);
}

View File

@ -65,6 +65,8 @@ namespace ace {
vehicle_p _active_vehicle;
std::vector<gamehit_p> _active_hits;
bool _enable_bullet_debug;
void DrawHits(uint32_t lod, PrimitiveBatch<VertexPositionColor>& batch, GXMVECTOR color);
void DrawCollisions(const std::vector<ace::vector3<float>> & collisions, PrimitiveBatch<VertexPositionColor>& batch, GXMVECTOR color);
void DrawObject(uint32_t lod, PrimitiveBatch<VertexPositionColor>& batch, ace::simulation::object & obj, GXMVECTOR color);