Skip to content

Commit d8ab3a1

Browse files
committed
Merge branch 'dev' into object-transportation-project-fixes
2 parents 42f179d + 0507d6f commit d8ab3a1

File tree

291 files changed

+12189
-5189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

291 files changed

+12189
-5189
lines changed

.github/workflows/linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Install dependencies
2828
run: |
2929
sudo apt-get update
30-
sudo apt-get install cmake xorg-dev curl
30+
sudo apt-get install cmake xorg-dev curl
3131
3232
- name: Build
3333
run: ./build.sh --jobs 2 --compiler ${{ matrix.config.compiler }}

.github/workflows/updateReadmeButtons.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Update readme buttons
22

3-
on:
3+
on:
44
project_card:
55
types: [created, deleted, moved]
66
project:

.github/workflows/web.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ jobs:
1616
}
1717

1818
steps:
19-
- uses: mymindstorm/setup-emsdk@v9
20-
19+
- uses: mymindstorm/setup-emsdk@v13
20+
2121
- name: Checkout atta
2222
uses: actions/checkout@v2
2323

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ tags
2525
imgui.ini
2626

2727
# Debugging/Profile
28+
.cache/
2829
perf.*
2930
.gdb_history
3031
profile/
32+
compile_commands.json

CMakeLists.txt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.14)
22

3-
project(atta VERSION 0.4.0 LANGUAGES CXX C)
3+
project(atta VERSION 0.3.2 LANGUAGES CXX C)
44

55
OPTION(ATTA_BUILD_TESTS
66
"Set to ON to build also the test executables"
@@ -11,17 +11,18 @@ OPTION(ATTA_WEB_BUILD_MODULE
1111
OPTION(ATTA_BUILD_DOCS
1212
"Build the documentation"
1313
OFF)
14-
option(ATTA_STATIC_PROJECT_FILE
15-
"Project to be linked statically to atta"
14+
option(ATTA_STATIC_PROJECT_FILE
15+
"Project to be linked statically to atta"
1616
"")
17-
option(ATTA_PROFILE
18-
"Set to ON to enable code profiling"
17+
option(ATTA_PROFILE
18+
"Set to ON to enable code profiling"
1919
ON)
2020

2121
set(CMAKE_CXX_STANDARD 17)
2222
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2323
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
2424
set(ATTA_VERSION_SAFE atta-${CMAKE_PROJECT_VERSION})
25+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
2526

2627
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/atta/cmakeConfig.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/atta/cmakeConfig.h)
2728

@@ -82,7 +83,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL Emscripten)#----- Web build
8283
set(ATTA_BUILD_TESTS OFF CACHE INTERNAL "" FORCE)
8384

8485
# Configure emscripten link flags
85-
set(EMSCRIPTEN_LINK_PROPERTIES "-s USE_WEBGL2=1 -s USE_GLFW=3")
86+
set(EMSCRIPTEN_LINK_PROPERTIES "-s USE_WEBGL2=1 -s USE_GLFW=3 -s GL_ENABLE_GET_PROC_ADDRESS")
8687
set(EMSCRIPTEN_LINK_PROPERTIES "${EMSCRIPTEN_LINK_PROPERTIES} -s ALLOW_MEMORY_GROWTH=1 -s FORCE_FILESYSTEM=1")
8788
set(EMSCRIPTEN_LINK_PROPERTIES "${EMSCRIPTEN_LINK_PROPERTIES} -s NO_DISABLE_EXCEPTION_CATCHING -s EXIT_RUNTIME=1")
8889
set(EMSCRIPTEN_LINK_PROPERTIES "${EMSCRIPTEN_LINK_PROPERTIES} --preload-file ${CMAKE_CURRENT_SOURCE_DIR}/resources@/resources/")
@@ -123,7 +124,7 @@ if(CMAKE_BUILD_TYPE MATCHES Debug)
123124
list(APPEND ATTA_OPTIONS -Wno-unused-parameter)
124125
# Script C linkage
125126
list(APPEND ATTA_OPTIONS -Wno-return-type-c-linkage)
126-
# Math anonymous union
127+
# Math anonymous union
127128
#list(APPEND ATTA_OPTIONS -Wno-nested-anon-types -Wno-gnu-anonymous-struct)
128129
# Glad opengl definitions
129130
#list(APPEND ATTA_OPTIONS -Wno-macro-redefined)
@@ -218,7 +219,7 @@ if(ATTA_STATIC_PROJECT)
218219
endif()
219220

220221
configure_file(
221-
"${CMAKE_CURRENT_SOURCE_DIR}/src/atta/script/scripts.h.in"
222+
"${CMAKE_CURRENT_SOURCE_DIR}/src/atta/script/scripts.h.in"
222223
"${CMAKE_CURRENT_SOURCE_DIR}/src/atta/script/scripts.h"
223224
)
224225

@@ -236,7 +237,7 @@ if(NOT (ATTA_SYSTEM_NAME MATCHES "Web") AND NOT ATTA_STATIC_PROJECT_FILE)
236237
########## Install files ##########
237238

238239
# Install atta executable
239-
install(TARGETS atta
240+
install(TARGETS atta
240241
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
241242
PRIVATE_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${ATTA_VERSION_SAFE}
242243
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${ATTA_VERSION_SAFE}

src/atta/atta.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ void Atta::loop() {
135135

136136
file::update();
137137
graphics::update();
138+
resource::update();
138139
}
139140

140141
void Atta::step() {

src/atta/cmakeConfig.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99

1010
#ifdef ATTA_OS_WEB
1111
#define ATTA_DIR "/"
12+
#define ATTA_BUILD_DIR "/"
1213
#else
1314
#define ATTA_DIR "@CMAKE_SOURCE_DIR@"
15+
#define ATTA_BUILD_DIR "@CMAKE_BINARY_DIR@"
1416
#endif
1517

1618
#define ATTA_VERSION "@CMAKE_PROJECT_VERSION@"

src/atta/component/components/cameraSensor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const uint8_t* CameraSensor::getImage() {
6464
if (cameraInfo.component == this)
6565
return cameraInfo.data.data();
6666
ASSERT(false, "(component::CameraSensor) Could not get camera frame from sensor::Manager.");
67+
return nullptr;
6768
}
6869

6970
} // namespace atta::component

src/atta/component/components/material.cpp

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212

1313
namespace atta::component {
1414

15-
void renderComboImage(std::string attribute, StringId& image) {
16-
bool isImage = (image != resource::Material::emptyImage);
15+
bool renderComboImage(std::string attribute, StringId& image) {
16+
bool isImage = (image != StringId());
17+
bool updated = false;
1718
std::string imguiId = attribute;
1819
if (isImage) {
1920
std::string selectedName = image.getString();
@@ -24,17 +25,22 @@ void renderComboImage(std::string attribute, StringId& image) {
2425
if (imageStr == "")
2526
imageStr = "##";
2627
const bool selected = (rImage == image);
27-
if (ImGui::Selectable(imageStr.c_str(), selected))
28+
if (ImGui::Selectable(imageStr.c_str(), selected)) {
2829
image = rImage;
30+
updated = true;
31+
}
2932
if (selected)
3033
ImGui::SetItemDefaultFocus();
3134
}
3235
ImGui::EndCombo();
3336
}
3437
}
3538

36-
if (ImGui::Checkbox(("Is image##IsImage" + imguiId).c_str(), &isImage))
37-
image = isImage ? "textures/white.jpg"_sid : resource::Material::emptyImage;
39+
if (ImGui::Checkbox(("Is image##IsImage" + imguiId).c_str(), &isImage)) {
40+
image = isImage ? "textures/white.png"_sid : StringId();
41+
updated = true;
42+
}
43+
return updated;
3844
}
3945

4046
void materialRenderImGui(void* data, std::string imguiId) {
@@ -132,29 +138,50 @@ void materialRenderImGui(void* data, std::string imguiId) {
132138
//---------- Edit ----------//
133139
ImGui::Text("Color");
134140
if (!m->colorIsImage()) {
135-
ImGui::SliderFloat("R##ColorR", &m->color.x, 0.0f, 1.0f);
136-
ImGui::SliderFloat("G##ColorG", &m->color.y, 0.0f, 1.0f);
137-
ImGui::SliderFloat("B##ColorB", &m->color.z, 0.0f, 1.0f);
141+
vec3 color = m->getColor();
142+
bool updated = false;
143+
if (ImGui::SliderFloat("R##ColorR", &color.x, 0.0f, 1.0f))
144+
updated = true;
145+
if (ImGui::SliderFloat("G##ColorG", &color.y, 0.0f, 1.0f))
146+
updated = true;
147+
if (ImGui::SliderFloat("B##ColorB", &color.z, 0.0f, 1.0f))
148+
updated = true;
149+
if (updated)
150+
m->setColor(color);
138151
}
139-
renderComboImage("Color", m->colorImage);
152+
StringId colorImage = m->getColorImage();
153+
if (renderComboImage("Color", colorImage))
154+
m->setColorImage(colorImage);
140155

141156
ImGui::Text("Roughness");
142157
if (!m->roughnessIsImage()) {
143-
ImGui::SliderFloat("##Roughness", &m->roughness, 0.0f, 1.0f);
158+
float roughness = m->getRoughness();
159+
if (ImGui::SliderFloat("##Roughness", &roughness, 0.0f, 1.0f))
160+
m->setRoughness(roughness);
144161
}
145-
renderComboImage("Roughness", m->roughnessImage);
162+
StringId roughnessImage = m->getRoughnessImage();
163+
if (renderComboImage("Roughness", roughnessImage))
164+
m->setRoughnessImage(roughnessImage);
146165

147166
ImGui::Text("Metallic");
148167
if (!m->metallicIsImage()) {
149-
ImGui::SliderFloat("##Metallic", &m->metallic, 0.0f, 1.0f);
168+
float metallic = m->getMetallic();
169+
if (ImGui::SliderFloat("##Metallic", &metallic, 0.0f, 1.0f))
170+
m->setMetallic(metallic);
150171
}
151-
renderComboImage("Metallic", m->metallicImage);
172+
StringId metallicImage = m->getMetallicImage();
173+
if (renderComboImage("Metallic", metallicImage))
174+
m->setMetallicImage(metallicImage);
152175

153176
ImGui::Text("AO");
154177
if (!m->aoIsImage()) {
155-
ImGui::SliderFloat("##AO", &m->ao, 0.0f, 1.0f);
178+
float ao = m->getAo();
179+
if (ImGui::SliderFloat("##AO", &ao, 0.0f, 1.0f))
180+
m->setAo(ao);
156181
}
157-
renderComboImage("AO", m->aoImage);
182+
StringId aoImage = m->getAoImage();
183+
if (renderComboImage("AO", aoImage))
184+
m->setAoImage(aoImage);
158185
}
159186

160187
template <>

src/atta/component/manager.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ void Manager::createDefaultImpl() {
6969
cube.add<Name>()->set("Cube");
7070
cube.add<Mesh>()->set("meshes/cube.obj");
7171

72-
resource::Material* rmt = resource::create<resource::Material>("Material", resource::Material::CreateInfo{});
73-
rmt->color = {0.5, 0.5, 0.5};
72+
resource::Material::CreateInfo mInfo{};
73+
mInfo.color = {0.5, 0.5, 0.5};
74+
resource::Material* rmt = resource::create<resource::Material>("Material", mInfo);
7475
cube.add<Material>()->set(rmt);
7576

7677
// Light entity

0 commit comments

Comments
 (0)