History

Fixed default render states for laser pointers

ksuprynowicz committed 3 years ago

Commit b0e030a1 parent 4062d801 file · +36 −31Browse files

Showing the changes to interface/src/raypick/PointerScriptingInterface.cpp (1 of 1 file). Show all

Unified · Split

interface/src/raypick/PointerScriptingInterface.cpp+36−31
@@ -569,42 +569,47 @@ bool rayPointerPropertiesFromScriptValue(const ScriptValue& value, RayPointerPro · 568 unmodified lines
569 // This copies properties from script value, but also converts entity properties of entities used in render states569 // This copies properties from script value, but also converts entity properties of entities used in render states
570 // from JS objects into EntityItemProperties570 // from JS objects into EntityItemProperties
571 out.properties = value.engine()->fromScriptValue<QVariantMap>(value);571 out.properties = value.engine()->fromScriptValue<QVariantMap>(value);
572 if (out.properties["renderStates"].canConvert<QVariantList>()) {572 QList<QString> renderStatesNames;
573 QVariantList renderStates = out.properties["renderStates"].value<QVariantList>();573 renderStatesNames.append("renderStates");
574 for( int i = 0; i < renderStates.length(); i++) {574 renderStatesNames.append("defaultRenderStates");
575 if (renderStates[i].canConvert<QVariantMap>()) {575 for (auto renderStatesName = renderStatesNames.cbegin(); renderStatesName!=renderStatesNames.cend(); renderStatesName++) {
576 QVariantMap stateMap = renderStates[i].value<QVariantMap>();576 if (out.properties[*renderStatesName].canConvert<QVariantList>()) {
577 if (stateMap["name"].canConvert<QString>()) {577 QVariantList renderStates = out.properties[*renderStatesName].value<QVariantList>();
578 stateMap["name"].value<QString>();578 for (int i = 0; i < renderStates.length(); i++) {
579 }579 if (renderStates[i].canConvert<QVariantMap>()) {
580 if (stateMap["start"].isValid()) {580 QVariantMap stateMap = renderStates[i].value<QVariantMap>();
581 ScriptValue start = value.property("renderStates").property(i).property("start");581 if (stateMap["name"].canConvert<QString>()) {
582 EntityItemProperties startProperties;582 stateMap["name"].value<QString>();
583 startProperties.copyFromScriptValue(start, false);583 }
584 stateMap.insert("startPropertyIndex", QVariant(out.entityProperties.length()));584 if (stateMap["start"].isValid()) {
585 out.entityProperties.append(startProperties);585 ScriptValue start = value.property(*renderStatesName).property(i).property("start");
586 }586 EntityItemProperties startProperties;
587 startProperties.copyFromScriptValue(start, false);
588 stateMap.insert("startPropertyIndex", QVariant(out.entityProperties.length()));
589 out.entityProperties.append(startProperties);
590 }
587 591
588 if (stateMap["path"].isValid()) {592 if (stateMap["path"].isValid()) {
589 ScriptValue path = value.property("renderStates").property(i).property("path");593 ScriptValue path = value.property(*renderStatesName).property(i).property("path");
590 EntityItemProperties pathProperties;594 EntityItemProperties pathProperties;
591 pathProperties.copyFromScriptValue(path, false);595 pathProperties.copyFromScriptValue(path, false);
592 stateMap.insert("pathPropertyIndex", QVariant(out.entityProperties.length()));596 stateMap.insert("pathPropertyIndex", QVariant(out.entityProperties.length()));
593 out.entityProperties.append(pathProperties);597 out.entityProperties.append(pathProperties);
594 }598 }
595 599
596 if (stateMap["end"].isValid()) {600 if (stateMap["end"].isValid()) {
597 ScriptValue end = value.property("renderStates").property(i).property("end");601 ScriptValue end = value.property(*renderStatesName).property(i).property("end");
598 EntityItemProperties endProperties;602 EntityItemProperties endProperties;
599 endProperties.copyFromScriptValue(end, false);603 endProperties.copyFromScriptValue(end, false);
600 stateMap.insert("endPropertyIndex", QVariant(out.entityProperties.length()));604 stateMap.insert("endPropertyIndex", QVariant(out.entityProperties.length()));
601 out.entityProperties.append(endProperties);605 out.entityProperties.append(endProperties);
606 }
607 // V8TODO: Check if path is a polyline and if values are valid
608 renderStates[i].setValue(stateMap);
602 }609 }
603 // V8TODO: Check if path is a polyline and if values are valid
604 renderStates[i].setValue(stateMap);
605 }610 }
611 out.properties[*renderStatesName].setValue(renderStates);
606 }612 }
607 out.properties["renderStates"].setValue(renderStates);
608 }613 }
609 qDebug() << "rayPointerPropertiesFromScriptValue" << out.properties;614 qDebug() << "rayPointerPropertiesFromScriptValue" << out.properties;
610 return true;615 return true;