Skip to content

Commit

Permalink
+ nicer progress bar
Browse files Browse the repository at this point in the history
+ serialization of activity origin info
  • Loading branch information
chrxh committed Oct 17, 2024
1 parent ba20380 commit 2938c8c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 73 deletions.
2 changes: 1 addition & 1 deletion source/EngineInterface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ add_library(EngineInterface
SelectionShallowData.h
SerializerService.cpp
SerializerService.h
SerializedSimulation.h
Settings.h
ShallowUpdateSelectionData.h
ShapeGenerator.cpp
ShapeGenerator.h
SerializedSimulation.h
SimulationFacade.h
SimulationParameters.cpp
SimulationParameters.h
Expand Down
28 changes: 15 additions & 13 deletions source/EngineInterface/SerializerService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,9 @@ namespace
auto constexpr Id_Cell_GenomeComplexity = 17;
//auto constexpr Id_Cell_AncestorMutationId = 18;
auto constexpr Id_Cell_DetectedByCreatureId = 19;

auto constexpr Id_Activity_Origin = 0;
auto constexpr Id_Activity_TargetX = 1;
auto constexpr Id_Activity_TargetY = 2;
auto constexpr Id_Cell_Activity_Origin = 20;
auto constexpr Id_Cell_Activity_TargetX = 21;
auto constexpr Id_Cell_Activity_TargetY = 22;

auto constexpr Id_Neuron_ActivationFunctions = 0;

Expand Down Expand Up @@ -538,11 +537,13 @@ namespace cereal
{
ar(data.cellId, data.distance, data.angleFromPrevious);
}

template <class Archive>
void serialize(Archive& ar, ActivityDescription& data)
void loadSave(SerializationTask task, Archive& ar, ActivityDescription& data)
{
ar(data.channels);
}
SPLIT_SERIALIZATION(ActivityDescription)

template <class Archive>
void loadSave(SerializationTask task, Archive& ar, NeuronDescription& data)
Expand Down Expand Up @@ -802,17 +803,18 @@ namespace cereal
loadSave<float>(task, auxiliaries, Id_Cell_GenomeComplexity, data.genomeComplexity, defaultObject.genomeComplexity);
loadSave(task, auxiliaries, Id_Cell_DetectedByCreatureId, data.detectedByCreatureId, defaultObject.detectedByCreatureId);
loadSave<uint8_t>(task, auxiliaries, Id_Cell_CellFunctionUsed, data.cellFunctionUsed, defaultObject.cellFunctionUsed);
loadSave(task, auxiliaries, Id_Cell_Activity_Origin, data.activity.origin, defaultObject.activity.origin);
loadSave(task, auxiliaries, Id_Cell_Activity_TargetX, data.activity.targetX, defaultObject.activity.targetX);
loadSave(task, auxiliaries, Id_Cell_Activity_TargetY, data.activity.targetY, defaultObject.activity.targetY);
auto activityClone = data.activity;
processLoadSaveMap(task, ar, auxiliaries);

ar(data.id, data.connections, data.pos, data.vel, data.energy, data.maxConnections, data.cellFunction, data.activity, data.metadata);

//#TODO
//ActivityDescription defaultActivity;
//auxiliaries = getLoadSaveMap(task, ar);
//loadSave<ActivityOrigin>(task, auxiliaries, Id_Activity_Origin, data.activity.origin, defaultObject.activity.origin);
//loadSave<float>(task, auxiliaries, Id_Activity_TargetX, data.activity.targetX, defaultObject.activity.targetX);
//loadSave<float>(task, auxiliaries, Id_Activity_TargetY, data.activity.targetY, defaultObject.activity.targetY);
//processLoadSaveMap(task, ar, auxiliaries);
if (task == SerializationTask::Load) {
data.activity.origin = activityClone.origin;
data.activity.targetX = activityClone.targetX;
data.activity.targetY = activityClone.targetY;
}

//compatibility with older versions
//>>>
Expand Down
73 changes: 14 additions & 59 deletions source/Gui/OverlayMessageController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,70 +69,25 @@ void OverlayMessageController::processLoadingBar()

auto viewSize = toRealVector2D(Viewport::get().getViewSize());
auto width = viewSize.x / 6 + 1.0f;
auto height = scale(20.0f);
auto height = scale(10.0f);
auto center = ImVec2{viewSize.x / 2, viewSize.y - scale(60.0f)};
drawList->AddRectFilled(
ImVec2{center.x - width / 2, center.y - height / 2}, ImVec2{center.x + width / 2, center.y + height / 2},
ImColor::HSV(0.66f, 1.0f, 0.25f, 0.8f));
//drawList->AddRectFilledMultiColor(
// ImVec2{center.x - width / 2, center.y - height / 2},
// ImVec2{center.x + width / 2, center.y},
// ImColor::HSV(0.66f, 0.5f, 0.65f, 1.0f),
// ImColor::HSV(0.66f, 0.5f, 0.65f, 1.0f),
// ImColor::HSV(0.66f, 0.5f, 0.65f, 0.0f),
// ImColor::HSV(0.66f, 0.5f, 0.65f, 0.0f));

//drawList->AddRectFilledMultiColor(
// ImVec2{center.x - width / 2, center.y},
// ImVec2{center.x + width / 2, center.y + height / 2},
// ImColor::HSV(0.66f, 0.5f, 0.65f, 0.0f),
// ImColor::HSV(0.66f, 0.5f, 0.65f, 0.0f),
// ImColor::HSV(0.66f, 0.5f, 0.65f, 1.0f),
// ImColor::HSV(0.66f, 0.5f, 0.65f, 1.0f));

auto progressWidth = width * 2 / 5;
auto progressStart = (toInt(duration) / 10 + toInt(width - progressWidth)) % toInt(width);
auto progressEnd = (toInt(duration) / 10) % toInt(width);
if (progressStart < progressEnd) {
drawList->AddRectFilledMultiColor(
ImVec2{center.x - width / 2 + toFloat(progressStart), center.y - height / 2},
ImVec2{center.x - width / 2 + toFloat(progressEnd), center.y + height / 2},
ImColor::HSV(0.66f, 0.8f, 1.0f, 1.0f),
ImColor::HSV(0.66f, 0.8f, 0.6f, 1.0f),
ImColor::HSV(0.66f, 0.8f, 0.2f, 1.0f),
ImColor::HSV(0.66f, 0.8f, 0.6f, 1.0f));
} else {
{
auto factor = toFloat(progressEnd) / progressWidth;
auto brightness1 = 1.0f * factor + 0.6f * (1.0f - factor);
auto brightness2 = 0.6f * factor + 0.2f * (1.0f - factor);
drawList->AddRectFilledMultiColor(
ImVec2{center.x - width / 2, center.y - height / 2},
ImVec2{center.x - width / 2 + toFloat(progressEnd), center.y + height / 2},
ImColor::HSV(0.66f, 0.8f, brightness1, 1.0f),
ImColor::HSV(0.66f, 0.8f, 0.6f, 1.0f),
ImColor::HSV(0.66f, 0.8f, 0.2f, 1.0f),
ImColor::HSV(0.66f, 0.8f, brightness2, 1.0f));
}
{
auto factor = (width - toFloat(progressStart)) / progressWidth;
auto brightness3 = 1.0f * (1.0f - factor) + 0.6f * factor;
auto brightness4 = 0.6f * (1.0f - factor) + 0.2f * factor;
drawList->AddRectFilledMultiColor(
ImVec2{center.x - width / 2 + toFloat(progressStart), center.y - height / 2},
ImVec2{center.x + width / 2, center.y + height / 2},
ImColor::HSV(0.66f, 0.8f, 1.0f, 1.0f),
ImColor::HSV(0.66f, 0.8f, brightness3, 1.0f),
ImColor::HSV(0.66f, 0.8f, brightness4, 1.0f),
ImColor::HSV(0.66f, 0.8f, 0.6f, 1.0f));
}

auto constexpr N = 40;
for (int i = 0; i < N; ++i) {
auto amplitude1 = sin(toFloat(i) * 10.0f / toFloat(N) - duration / 240.0f) / 1;
auto amplitude2 = sin(toFloat(i) * 14.0f / toFloat(N) - duration / 135.0f) / 1;
//auto hue = toFloat((i * 1000 / N + toInt(duration)) % 3000) / 4500.0f;
//hue = hue < 0.33f ? 0.66f + hue : 0.66f + 0.66f - hue;

drawList->AddRectFilled(
ImVec2{center.x - width / 2 + toFloat(i) / N * width, center.y + height / 2 - amplitude1 * height},

Check failure on line 83 in source/Gui/OverlayMessageController.cpp

View workflow job for this annotation

GitHub Actions / build

narrowing conversion of ‘(((double)(center.ImVec2::y + (height / (float)2))) - (amplitude1 * ((double)height)))’ from ‘double’ to ‘float’ [-Werror=narrowing]
ImVec2{center.x - width / 2 + toFloat(i + 1) / N * width - scale(3), center.y + height / 2 - amplitude2 * height / 2},

Check failure on line 84 in source/Gui/OverlayMessageController.cpp

View workflow job for this annotation

GitHub Actions / build

narrowing conversion of ‘(((double)(center.ImVec2::y + (height / (float)2))) - ((amplitude2 * ((double)height)) / (double)2))’ from ‘double’ to ‘float’ [-Werror=narrowing]
ImColor::HSV(0, 0.1f, 0.35f, 0.6f));
}
drawList->AddRect(
ImVec2{center.x - width / 2, center.y - height / 2}, ImVec2{center.x + width / 2, center.y + height / 2}, ImColor::HSV(0.66f, 0.8f, 0.6f, 1.0f));
drawList->AddText(
StyleRepository::get().getReefMediumFont(),
scale(16.0f),
{center.x - scale(25.0f), center.y - scale(10.0f)},
{center.x - scale(28.0f), center.y - scale(15.0f)},
ImColor::HSV(0, 0, 1, 0.7f),
"Processing");

Expand Down

0 comments on commit 2938c8c

Please sign in to comment.