In-game debug rendering.

This commit is contained in:
jaynus 2015-05-16 12:19:59 -07:00
parent d25144e75a
commit cc0e9341bf
7 changed files with 104 additions and 17 deletions

View File

@ -5,6 +5,15 @@
// Extension dispatch commands
[QGVAR(setAnimationNames), FUNC(setAnimationNames)] call EFUNC(common,addEventHandler);
// Trigger and start fetching results
[FUNC(monitorResultsPFH), 0, []] call CBA_fnc_addPerFrameHandler;
#ifdef DEBUG_DRAW_LINES
// Debug functionality
[QGVAR(draw_face), FUNC(debug_drawFace)] call EFUNC(common,addEventHandler);
[FUNC(debug_drawLinesPFH), 0, []] call CBA_fnc_addPerFrameHandler;
#endif

View File

@ -12,17 +12,6 @@ PREP(callExtension);
GVAR(async) = true;
GVAR(ready) = false;
#ifdef DEBUG_LOG_EXTENSION
GVAR(debug_log) = [];
PREP(debug_exportLogClipboard);
PREP(debug_exportLogFile);
PREP(debug_animateCurrentVehicle);
#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_Debug.dll";
#endif
// Extension dispatch events
PREP(setAnimationNames);
@ -41,18 +30,36 @@ PREP(doHit);
GVAR(vehicle_id) = 0;
GVAR(vehicles) = HASH_CREATE;
// Begin Debug functions
// **************************
#ifdef DEBUG_LOG_EXTENSION
GVAR(debug_log) = [];
PREP(debug_exportLogClipboard);
PREP(debug_exportLogFile);
PREP(debug_animateCurrentVehicle);
#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_Debug.dll";
#endif
#ifdef DEBUG_DRAW_LINES
GVAR(debug_lines) = [];
PREP(debug_drawFace);
PREP(debug_drawLinesPFH);
#endif
// **************************
// End debug functions
FUNC(_textVector) = {
private["_str"];
_str = format["%1;%2;%3", ((_this select 0) select 0), ((_this select 0) select 1), ((_this select 0) select 2)];
_str
};
#ifdef DEBUG_LOG_EXTENSION
#endif
[] call FUNC(initializeExtension);
ADDON = true;

View File

@ -0,0 +1,24 @@
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
private["_id", "_vehicle", "_vehicleData"];
TRACE_1("enter", _this);
_id = parseNumber (_this select 0);
_this deleteAt 0;
_vehicleData = HASH_GET(GVAR(vehicles),_id);
if(isNil "_vehicleData") exitWith { false };
_vehicle = _vehicleData select 0;
_points = [];
for [{_i=0}, {_i<(count _this)-1}, {_i=_i+3}] do {
_points pushBack (_vehicle modelToWorldVisual
[ parseNumber (_this select _i),
parseNumber (_this select (_i+2)),
parseNumber (_this select (_i+1))+2.5
]);
};
//TRACE_1("", _points);
GVAR(debug_lines) pushBack [(ASLToATL (_points select 0)), (ASLToATL (_points select 1))];
GVAR(debug_lines) pushBack [(ASLToATL (_points select 1)), (ASLToATL (_points select 2))];
GVAR(debug_lines) pushBack [(ASLToATL (_points select 2)), (ASLToATL (_points select 0))];

View File

@ -0,0 +1,5 @@
#include "script_component.hpp"
{
drawLine3D [(_x select 0), (_x select 1), [1,1,1,1]];
} forEach GVAR(debug_lines);

View File

@ -16,5 +16,6 @@
#define DEBUG_EXTENSION_DYNLOAD
#define DEBUG_LOG_EXTENSION
#define DEBUG_DRAW_LINES
//#define DEBUG_EXTENSION_DYNLOAD_RELOAD
//#define DEBUG_VEHICLEDAMAGE_RENDER

View File

@ -49,6 +49,7 @@ namespace ace {
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));
add("test_get_draw", std::bind(&ace::vehicledamage::controller::_test_get_draw, this, std::placeholders::_1, std::placeholders::_2));
#endif
#if defined(DEVEL) && defined(USE_DIRECTX)
@ -74,12 +75,27 @@ namespace ace {
}
bool controller::reset(const arguments &_args, std::string & result) {
_ready = false;
vehicles.clear();
if (!ace::model_collection::get().ready()) {
ace::model_collection::get().init();
}
{
std::lock_guard<std::mutex> lock(_results_lock);
std::lock_guard<std::mutex> lock(_messages_lock);
while (!_results.empty()) {
_results.pop();
}
while (!_messages.empty()) {
_messages.pop();
}
}
_ready = true;
return true;
}
@ -262,6 +278,30 @@ namespace ace {
}
#endif
#ifdef _DEBUG
bool controller::_test_get_draw(const arguments &_args, std::string & results) {
if (_args.size() < 1) return false;
uint32_t id = static_cast<uint32_t>(_args[0]);
if (vehicles.find(id) == vehicles.end())
return false;
vehicle_p _vehicle = vehicles[id];
_vehicle->simulate();
for (auto & face : _vehicle->object->lods[_vehicle->fire_lod]->faces ) {
std::stringstream ss;
ss << "draw_face:" << id;
ss << "," << face->vertices[0]->x() << "," << face->vertices[0]->y() << "," << face->vertices[0]->z();
ss << "," << face->vertices[1]->x() << "," << face->vertices[1]->y() << "," << face->vertices[1]->z();
ss << "," << face->vertices[2]->x() << "," << face->vertices[2]->y() << "," << face->vertices[2]->z();
this->push_result(ss.str());
}
return false;
}
bool controller::_test_raycast(const arguments &_args, std::string & result) {
ace::simulation::object * _object = new ace::simulation::object(model_collection::get().models[0].model, false);
std::shared_ptr<ace::simulation::object> _object_ptr(_object);

View File

@ -37,6 +37,7 @@ namespace ace {
bool get_thickness(const arguments &, std::string &);
bool selection_position(const arguments &, std::string &);
#ifdef _DEBUG
bool _test_get_draw(const arguments &, std::string &);
bool _test_raycast(const arguments &, std::string &);
bool _test_selection(const arguments &, std::string &);
#endif