| @@ -63,7 +63,7 @@ inline float eucmodf(float a, float base) { | |||||
| If min < max, returns max | If min < max, returns max | ||||
| */ | */ | ||||
| inline float clampf(float x, float min, float max) { | inline float clampf(float x, float min, float max) { | ||||
| return fmaxf(min, fminf(max, x)); | |||||
| return x > max ? max : x < min ? min : x; | |||||
| } | } | ||||
| /** If the magnitude of x if less than eps, return 0 */ | /** If the magnitude of x if less than eps, return 0 */ | ||||
| @@ -89,14 +89,6 @@ json_t *RackWidget::toJson() { | |||||
| json_t *versionJ = json_string(gApplicationVersion.c_str()); | json_t *versionJ = json_string(gApplicationVersion.c_str()); | ||||
| json_object_set_new(rootJ, "version", versionJ); | json_object_set_new(rootJ, "version", versionJ); | ||||
| // wireOpacity | |||||
| json_t *wireOpacityJ = json_real(dynamic_cast<RackScene*>(gScene)->toolbar->wireOpacitySlider->value); | |||||
| json_object_set_new(rootJ, "wireOpacity", wireOpacityJ); | |||||
| // wireTension | |||||
| json_t *wireTensionJ = json_real(dynamic_cast<RackScene*>(gScene)->toolbar->wireTensionSlider->value); | |||||
| json_object_set_new(rootJ, "wireTension", wireTensionJ); | |||||
| // modules | // modules | ||||
| json_t *modulesJ = json_array(); | json_t *modulesJ = json_array(); | ||||
| std::map<ModuleWidget*, int> moduleIds; | std::map<ModuleWidget*, int> moduleIds; | ||||
| @@ -162,16 +154,6 @@ void RackWidget::fromJson(json_t *rootJ) { | |||||
| printf("JSON version mismatch, attempting to convert JSON version %s to %s\n", version, gApplicationVersion.c_str()); | printf("JSON version mismatch, attempting to convert JSON version %s to %s\n", version, gApplicationVersion.c_str()); | ||||
| } | } | ||||
| // wireOpacity | |||||
| json_t *wireOpacityJ = json_object_get(rootJ, "wireOpacity"); | |||||
| if (wireOpacityJ) | |||||
| dynamic_cast<RackScene*>(gScene)->toolbar->wireOpacitySlider->value = json_number_value(wireOpacityJ); | |||||
| // wireTension | |||||
| json_t *wireTensionJ = json_object_get(rootJ, "wireTension"); | |||||
| if (wireTensionJ) | |||||
| dynamic_cast<RackScene*>(gScene)->toolbar->wireTensionSlider->value = json_number_value(wireTensionJ); | |||||
| // modules | // modules | ||||
| std::map<int, ModuleWidget*> moduleWidgets; | std::map<int, ModuleWidget*> moduleWidgets; | ||||
| json_t *modulesJ = json_object_get(rootJ, "modules"); | json_t *modulesJ = json_object_get(rootJ, "modules"); | ||||
| @@ -18,12 +18,12 @@ static json_t *settingsToJson() { | |||||
| // opacity | // opacity | ||||
| float opacity = dynamic_cast<RackScene*>(gScene)->toolbar->wireOpacitySlider->value; | float opacity = dynamic_cast<RackScene*>(gScene)->toolbar->wireOpacitySlider->value; | ||||
| json_t *opacityJ = json_real(opacity); | json_t *opacityJ = json_real(opacity); | ||||
| json_object_set_new(rootJ, "opacity", opacityJ); | |||||
| json_object_set_new(rootJ, "wireOpacity", opacityJ); | |||||
| // tension | // tension | ||||
| float tension = dynamic_cast<RackScene*>(gScene)->toolbar->wireTensionSlider->value; | float tension = dynamic_cast<RackScene*>(gScene)->toolbar->wireTensionSlider->value; | ||||
| json_t *tensionJ = json_real(tension); | json_t *tensionJ = json_real(tension); | ||||
| json_object_set_new(rootJ, "tension", tensionJ); | |||||
| json_object_set_new(rootJ, "wireTension", tensionJ); | |||||
| return rootJ; | return rootJ; | ||||
| } | } | ||||
| @@ -35,12 +35,12 @@ static void settingsFromJson(json_t *rootJ) { | |||||
| gToken = json_string_value(tokenJ); | gToken = json_string_value(tokenJ); | ||||
| // opacity | // opacity | ||||
| json_t *opacityJ = json_object_get(rootJ, "opacity"); | |||||
| json_t *opacityJ = json_object_get(rootJ, "wireOpacity"); | |||||
| if (opacityJ) | if (opacityJ) | ||||
| dynamic_cast<RackScene*>(gScene)->toolbar->wireOpacitySlider->value = json_number_value(opacityJ); | dynamic_cast<RackScene*>(gScene)->toolbar->wireOpacitySlider->value = json_number_value(opacityJ); | ||||
| // tension | // tension | ||||
| json_t *tensionJ = json_object_get(rootJ, "tension"); | |||||
| json_t *tensionJ = json_object_get(rootJ, "wireTension"); | |||||
| if (tensionJ) | if (tensionJ) | ||||
| dynamic_cast<RackScene*>(gScene)->toolbar->wireTensionSlider->value = json_number_value(tensionJ); | dynamic_cast<RackScene*>(gScene)->toolbar->wireTensionSlider->value = json_number_value(tensionJ); | ||||
| } | } | ||||