Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
chrxh committed Nov 29, 2023
2 parents e35176c + b2e149a commit e76550f
Show file tree
Hide file tree
Showing 14 changed files with 116 additions and 69 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Further information and artwork:
An Nvidia graphics card with compute capability 6.0 or higher is needed. Please check [https://en.wikipedia.org/wiki/CUDA#GPUs_supported](https://en.wikipedia.org/wiki/CUDA#GPUs_supported).

# 💽 Installer
Installer for Windows: [alien-installer.msi](https://alien-project.org/media/files/alien-installer.msi) (Updated: 2023-11-25)
Installer for Windows: [alien-installer.msi](https://alien-project.org/media/files/alien-installer.msi) (Updated: 2023-11-29)

In the case that the program crashes for an unknown reason, please refer to the troubleshooting section in [alien-project.org/downloads.html](https://alien-project.org/downloads.html).

Expand Down
7 changes: 7 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Release notes

## [4.4.3] - 2023-11-29
### Added
- show text background when rendering is disabled

### Fixed
- fixed insertion mutation behavior that led to undesirably high repetitions and made this mutation type more or less useless

## [4.4.2] - 2023-11-25
### Added
- external energy source, which is controllable by two new parameters
Expand Down
2 changes: 1 addition & 1 deletion source/Base/Resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Const
{
std::string const ProgramVersion = "4.4.2";
std::string const ProgramVersion = "4.4.3";
std::string const DiscordLink = "https://discord.gg/7bjyZdXXQ2";

std::string const BasePath = "resources/";
Expand Down
4 changes: 4 additions & 0 deletions source/EngineGpuKernels/GenomeDecoder.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,10 @@ __inline__ __device__ void GenomeDecoder::setRandomCellFunctionData(
if (cellFunction == CellFunction_Constructor || cellFunction == CellFunction_Injector) {
auto cellFunctionFixedBytes = cellFunction == CellFunction_Constructor ? Const::ConstructorFixedBytes : Const::InjectorFixedBytes;
genome[nodeAddress + cellFunctionFixedBytes] = makeSelfCopy ? 1 : 0;

auto subGenomeRelPos = getCellFunctionDataSize(cellFunction, makeSelfCopy, 0);
genome[nodeAddress + subGenomeRelPos + Const::GenomeHeaderNumRepetitionsPos] = 1;

if (!makeSelfCopy) {
writeWord(genome, nodeAddress + cellFunctionFixedBytes + 1, subGenomeSize);
}
Expand Down
19 changes: 10 additions & 9 deletions source/Gui/AlienImGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1671,9 +1671,9 @@ void AlienImGui::BasicInputColorMatrix(BasicInputColorMatrixParameters<T> const&
auto startPos = ImGui::GetCursorPos();

ImGui::SetCursorPos({startPos.x - scale(48), startPos.y + scale(105)});
RotateStart();
RotateStart(ImGui::GetWindowDrawList());
ImGui::Text("[host color]");
RotateEnd(90.0f);
RotateEnd(90.0f, ImGui::GetWindowDrawList());

ImGui::SetCursorPos(startPos);

Expand Down Expand Up @@ -1798,16 +1798,16 @@ void AlienImGui::BasicInputColorMatrix(BasicInputColorMatrixParameters<T> const&

//RotateStart, RotationCenter, etc. are taken from https://gist.github.com/carasuca/e72aacadcf6cf8139de46f97158f790f
//>>>>>>>>>>
void AlienImGui::RotateStart()
void AlienImGui::RotateStart(ImDrawList* drawList)
{
_rotationStartIndex = ImGui::GetWindowDrawList()->VtxBuffer.Size;
_rotationStartIndex = ImGui::GetBackgroundDrawList()->VtxBuffer.Size;
}

ImVec2 AlienImGui::RotationCenter()
ImVec2 AlienImGui::RotationCenter(ImDrawList* drawList)
{
ImVec2 l(FLT_MAX, FLT_MAX), u(-FLT_MAX, -FLT_MAX); // bounds

const auto& buf = ImGui::GetWindowDrawList()->VtxBuffer;
const auto& buf = ImGui::GetBackgroundDrawList()->VtxBuffer;
for (int i = _rotationStartIndex; i < buf.Size; i++)
l = ImMin(l, buf[i].pos), u = ImMax(u, buf[i].pos);

Expand All @@ -1822,17 +1822,18 @@ namespace
}
}

void AlienImGui::RotateEnd(float angle)
void AlienImGui::RotateEnd(float angle, ImDrawList* drawList)
{
auto center = RotationCenter();
auto center = RotationCenter(drawList);
float s = sin((angle + 90.0f) * Const::DegToRad), c = cos((angle + 90.0f) * Const::DegToRad);
center = ImRotate(center, s, c) - center;

auto& buf = ImGui::GetWindowDrawList()->VtxBuffer;
auto& buf = ImGui::GetBackgroundDrawList()->VtxBuffer;
for (int i = _rotationStartIndex; i < buf.Size; i++) {
buf[i].pos = ImRotate(buf[i].pos, s, c) - center;
}
}

//<<<<<<<<<<

int AlienImGui::DynamicTableLayout::calcNumColumns(float tableWidth, float columnWidth)
Expand Down
7 changes: 4 additions & 3 deletions source/Gui/AlienImGui.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ class AlienImGui
int _elementNumber = 0;
};

static void RotateStart(ImDrawList* drawList);
static void RotateEnd(float angle, ImDrawList* drawList);

private:

template <typename Parameter, typename T>
Expand All @@ -340,9 +343,7 @@ class AlienImGui
template <typename T>
static void BasicInputColorMatrix(BasicInputColorMatrixParameters<T> const& parameters, T (&value)[MAX_COLORS][MAX_COLORS]);

static void RotateStart();
static ImVec2 RotationCenter();
static void RotateEnd(float angle);
static ImVec2 RotationCenter(ImDrawList* drawList);

static std::unordered_set<unsigned int> _basicSilderExpanded;
static int _rotationStartIndex;
Expand Down
11 changes: 3 additions & 8 deletions source/Gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ void _MainWindow::processLoadingControls()
processControllers();

_uiController->process();
_simulationView->processControls();
_simulationView->processControls(_renderSimulation);
_startupController->process();

ImGui::PopStyleVar(2);
Expand All @@ -331,7 +331,7 @@ void _MainWindow::processFinishedLoading()
processWindows();
processControllers();
_uiController->process();
_simulationView->processControls();
_simulationView->processControls(_renderSimulation);

ImGui::PopStyleVar(2);

Expand All @@ -343,12 +343,7 @@ void _MainWindow::renderSimulation()
int display_w, display_h;
glfwGetFramebufferSize(_window, &display_w, &display_h);
glViewport(0, 0, display_w, display_h);
if (_renderSimulation) {
_simulationView->draw();
} else {
glClearColor(0, 0, 0.1f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
}
_simulationView->draw(_renderSimulation);
ImGui::Render();

_fpsController->processForceFps(WindowController::getInstance().getFps());
Expand Down
2 changes: 1 addition & 1 deletion source/Gui/SimulationParametersWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ void _SimulationParametersWindow::processBase(
if (ImGui::TreeNodeEx("External energy source", treeNodeOpenFlags)) {
AlienImGui::SliderFloat(
AlienImGui::SliderFloatParameters()
.name("External energy for constructors")
.name("External energy amount")
.textWidth(RightColumnWidth)
.colorDependence(true)
.min(0.0f)
Expand Down
112 changes: 72 additions & 40 deletions source/Gui/SimulationView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,51 +278,83 @@ void _SimulationView::processEvents()
_prevMousePosInt = mousePosInt;
}

void _SimulationView::draw()
void _SimulationView::draw(bool renderSimulation)
{
processEvents();

updateImageFromSimulation();

_shader->use();

GLint currentFbo;
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &currentFbo);

glBindFramebuffer(GL_FRAMEBUFFER, _fbo1);
_shader->setInt("phase", 0);
glBindVertexArray(_vao);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, _textureSimulationId);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);

glBindFramebuffer(GL_FRAMEBUFFER, _fbo2);
_shader->setInt("phase", 1);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, _textureSimulationId);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, _textureFramebufferId1);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, _textureFramebufferId2);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
if (renderSimulation) {
processEvents();

updateImageFromSimulation();

_shader->use();

GLint currentFbo;
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &currentFbo);

glBindFramebuffer(GL_FRAMEBUFFER, _fbo1);
_shader->setInt("phase", 0);
glBindVertexArray(_vao);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, _textureSimulationId);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);

glBindFramebuffer(GL_FRAMEBUFFER, _fbo2);
_shader->setInt("phase", 1);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, _textureSimulationId);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, _textureFramebufferId1);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, _textureFramebufferId2);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);

glBindFramebuffer(GL_FRAMEBUFFER, currentFbo);
_shader->setInt("phase", 2);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, _textureFramebufferId2);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
} else {
glClearColor(0, 0, 0.1f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);

glBindFramebuffer(GL_FRAMEBUFFER, currentFbo);
_shader->setInt("phase", 2);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, _textureFramebufferId2);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
auto textWidth = scale(300.0f);
auto textHeight = scale(80.0f);
ImDrawList* drawList = ImGui::GetBackgroundDrawList();
auto styleRep = StyleRepository::getInstance();
auto right = ImGui::GetMainViewport()->Pos.x + ImGui::GetMainViewport()->Size.x;
auto bottom = ImGui::GetMainViewport()->Pos.y + ImGui::GetMainViewport()->Size.y;
auto maxLength = std::max(right, bottom);

AlienImGui::RotateStart(ImGui::GetBackgroundDrawList());
auto font = styleRep.getReefLargeFont();
auto text = "Rendering disabled";
ImVec4 clipRect(-100000.0f, -100000.0f, 100000.0f, 100000.0f);
for (int i = 0; toFloat(i) * textWidth < maxLength * 2; ++i) {
for (int j = 0; toFloat(j) * textHeight < maxLength * 2; ++j) {
font->RenderText(
drawList,
scale(34.0f),
{toFloat(i) * textWidth - maxLength / 2, toFloat(j) * textHeight - maxLength / 2},
Const::RenderingDisabledTextColor,
clipRect,
text,
text + strlen(text),
NULL,
false);
}
}
AlienImGui::RotateEnd(45.0f, ImGui::GetBackgroundDrawList());
}
}

void _SimulationView::processControls()
void _SimulationView::processControls(bool renderSimulation)
{
ImGuiViewport* viewport = ImGui::GetMainViewport();
auto mainMenubarHeight = StyleRepository::getInstance().scale(22);
auto scrollbarThickness = 17; //fixed
_scrollbarX->process(
{{viewport->Pos.x, viewport->Size.y - scrollbarThickness}, {viewport->Size.x - 1 - scrollbarThickness, 1}});
_scrollbarY->process(
{{viewport->Size.x - scrollbarThickness, viewport->Pos.y + mainMenubarHeight},
{1, viewport->Size.y - 1 - scrollbarThickness}});
if (renderSimulation) {
ImGuiViewport* viewport = ImGui::GetMainViewport();
auto mainMenubarHeight = StyleRepository::getInstance().scale(22);
auto scrollbarThickness = 17; //fixed
_scrollbarX->process({{viewport->Pos.x, viewport->Size.y - scrollbarThickness}, {viewport->Size.x - 1 - scrollbarThickness, 1}});
_scrollbarY->process({{viewport->Size.x - scrollbarThickness, viewport->Pos.y + mainMenubarHeight}, {1, viewport->Size.y - 1 - scrollbarThickness}});
}
}

bool _SimulationView::isOverlayActive() const
Expand Down
4 changes: 2 additions & 2 deletions source/Gui/SimulationView.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class _SimulationView

void resize(IntVector2D const& viewportSize);

void draw();
void processControls();
void draw(bool renderSimulation);
void processControls(bool renderSimulation);

bool isOverlayActive() const;
void setOverlayActive(bool active);
Expand Down
4 changes: 2 additions & 2 deletions source/Gui/StartupController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ void _StartupController::processWindow()
auto millisecSinceStartup = std::chrono::duration_cast<std::chrono::milliseconds>(now - *_startupTimepoint).count();

ImDrawList* drawList = ImGui::GetBackgroundDrawList();
ImColor textColor = Const::ProgramVersionColor;
ImColor textColor = Const::ProgramVersionTextColor;
textColor.Value.w *= ImGui::GetStyle().Alpha;

ImColor loadingTextColor = Const::ProgramVersionColor;
ImColor loadingTextColor = Const::ProgramVersionTextColor;
loadingTextColor.Value.w *= ImGui::GetStyle().Alpha * 0.5f;

//draw 'Initializing' text if it fits
Expand Down
4 changes: 3 additions & 1 deletion source/Gui/StyleRepository.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

namespace Const
{
ImColor const ProgramVersionColor = ImColor::HSV(0.5f, 0.1f, 1.0f, 1.0f);
ImColor const ProgramVersionTextColor = ImColor::HSV(0.5f, 0.1f, 1.0f, 1.0f);

ImColor const RenderingDisabledTextColor = ImColor::HSV(0.5f, 0.1f, 1.0f, 0.2f);

int64_t const SimulationSliderColor_Base = 0xff4c4c4c;
int64_t const SimulationSliderColor_Active = 0xff6c6c6c;
Expand Down
5 changes: 5 additions & 0 deletions source/Gui/TemporalControlWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ void _TemporalControlWindow::applySnapshot(Snapshot const& snapshot)
for (int i = 0; i < MAX_COLORS; ++i) {
parameters.cellFunctionConstructorExternalEnergy[i] = origParameters.cellFunctionConstructorExternalEnergy[i];
}
if (parameters.cellMaxAgeBalancer || origParameters.cellMaxAgeBalancer) {
for (int i = 0; i < MAX_COLORS; ++i) {
parameters.cellMaxAge[i] = origParameters.cellMaxAge[i];
}
}
_simController->setCurrentTimestep(snapshot.timestep);
_simController->setSimulationData(snapshot.data);
_simController->setSimulationParameters(parameters);
Expand Down
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "alien",
"version": "4.4.2",
"version": "4.4.3",
"dependencies": [
{
"name": "glew",
Expand Down

0 comments on commit e76550f

Please sign in to comment.