Hello.
Suppose I send eventData like:
void SplineEditor::SendEventIndexSelected(int index)
{
using namespace IndexSelected;
VariantMap& eventData = GetEventDataMap();
float data[6];
data[0] = splineVector_[index].x_;
data[1] = splineVector_[index].y_;
data[2] = splineVector_[index].z_;
data[3] = splineOrientVector_[index].x_; // Pan
data[4] = splineOrientVector_[index].y_; // Tilt
data[5] = splineOrientVector_[index].z_; // Roll
eventData[P_DATA]= Variant(data);
SendEvent(E_ITEMSELECTED, eventData);
}
and process/receive eventData by:
void Navigation::HandleSplineItemSelected(StringHash eventType, VariantMap &eventData)
{
uint8_t* data;
data = (uint8_t*)eventData[IndexSelected::P_DATA].GetVoidPtr();
float x = *(float*)&data[0];
float y = *(float*)&data[4];
float z = *(float*)&data[8];
float pa = *(float*)&data[12];
float ta = *(float*)&data[16];
float ra = *(float*)&data[20];
cameraNode_->SetPosition(Vector3(x,y,z));
cameraNode_->SetRotation(Quaternion(ta, pa, ra));
}
Especially the lines:
eventData[P_DATA]= Variant(data);
and
data = (uint8_t*)eventData[IndexSelected::P_DATA].GetVoidPtr();
are somewhat doubtful for me. May it be that simple?
Thanks.