Pass and register reversed model. More scientific notation float limitation handling.

This commit is contained in:
jaynus 2015-05-15 22:51:23 -07:00
parent fe462826b6
commit 1b93c89c28
6 changed files with 17 additions and 12 deletions

View File

@ -2,16 +2,17 @@
#include "script_component.hpp"
PARAMS_1(_vehicle);
private["_id", "_model","_vehicleData"];
private["_id", "_model","_vehicleData", "_reversed"];
if(GVAR(Enabled) < 1) exitWith {};
_id = GVAR(vehicle_id);
GVAR(vehicle_id) = _id + 1;
_model = getText (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "model");
_reversed = getNumber (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "reversed");
if(_model != "") then {
_value = format["register_vehicle:%1,%2,%3",_model,_id,VECTOR_TEXT(getPosASL _vehicle)];
_value = format["register_vehicle:%1,%2,%3,%4",_model,_id,_reversed,VECTOR_TEXT(getPosASL _vehicle)];
TRACE_1("", _value);
_result = _value call FUNC(callExtension);
_vehicle setVariable[QGVAR(id), _id, false];

View File

@ -14,7 +14,8 @@ namespace ace {
const std::string & as_string() const { return _args[_index]; }
operator const std::string &() const { return as_string(); }
float as_float() const { float res = 0.0f; std::istringstream iss(_args[_index]); iss >> res; return res; }
float to_float(const std::string & val) const { float res = 0.0f; std::istringstream iss(val); iss >> res; return res; }
float as_float() const { return to_float(_args[_index]); }
operator float() const { return as_float(); }
int as_int() const { return atoi(_args[_index].c_str()); }
@ -25,9 +26,9 @@ namespace ace {
ace::vector3<float> as_vector() const {
std::vector<std::string> t = ace::split(_args[_index], ';');
return ace::vector3<float>(atof(t[0].c_str()),
atof(t[1].c_str()),
atof(t[2].c_str()));
return ace::vector3<float>(to_float(t[0]),
to_float(t[1]),
to_float(t[2]));
}
operator ace::vector3<float>() const { return as_vector(); }
@ -49,15 +50,14 @@ namespace ace {
const argument_accessor operator[] (int index) const { return argument_accessor(index, _args); }
float to_float(const std::string & val) const { float res = 0.0f; std::istringstream iss(val); iss >> res; return res; }
const std::string & as_string(uint32_t _index) const { return _args[_index]; }
float as_float(uint32_t _index) const { return atof(_args[_index].c_str()); }
float as_float(uint32_t _index) const { return to_float(_args[_index]); }
int as_int(uint32_t _index) const { return atoi(_args[_index].c_str()); }
int as_uint32(uint32_t _index) const { return (uint32_t)atoi(_args[_index].c_str()); }
ace::vector3<float> as_vector(uint32_t _index) const {
std::vector<std::string> t = ace::split(_args[_index], ';');
return ace::vector3<float>(atof(t[0].c_str()),
atof(t[1].c_str()),
atof(t[2].c_str()));
return ace::vector3<float>(to_float(t[0]), to_float(t[1]), to_float(t[3]));
}
const std::string & get() const {

View File

@ -387,7 +387,7 @@ ace::simulation::object::object()
{
}
ace::simulation::object::object(const ace::p3d::model_p model)
ace::simulation::object::object(const ace::p3d::model_p model) : reversed(false)
{
for (ace::p3d::lod_p p3d_lod : model->lods) {
lod_p new_lod = std::make_shared<lod>(p3d_lod, model);

View File

@ -205,6 +205,8 @@ namespace ace {
object(const ace::p3d::model_p);
~object();
bool reversed;
std::vector<lod_p> lods;
std::vector<animation_p> animations;

View File

@ -8,7 +8,7 @@ using namespace ace::simulation;
namespace ace {
namespace vehicledamage {
base_vehicle::base_vehicle(uint32_t id, ace::simulation::object_p object_, ace::vector3<float> position_) : id(id), object(object_) {
base_vehicle::base_vehicle(uint32_t id, ace::simulation::object_p object_, bool reversed, ace::vector3<float> position_) : id(id), object(object_) {
bt_mesh = std::make_shared<btTriangleMesh>();
fire_lod = -1;

View File

@ -114,6 +114,8 @@ namespace ace {
vehicle_p _vehicle = std::make_shared<vehicle>(static_cast<uint32_t>(_args[1]), _object, _args[2]);
vehicles[static_cast<uint32_t>(_args[1])] = _vehicle;
_vehicle->object->reversed = (static_cast<int>(_args[2]) != 0 ? true : false);
// For results on a valid vehicle registration, we return its animation names for that given vehicle
std::stringstream _animationNames;
_animationNames << _vehicle->id;