126 if (selectedEntityHandle == entt::null || !scene->
GetRegistry().valid(selectedEntityHandle))
128 panel.
Text(
"Select an entity in the Hierarchy to view properties.");
132 entt::registry& registry =
const_cast<entt::registry&
>(scene->
GetRegistry());
134 if (!registry.all_of<
TagComponent>(selectedEntityHandle))
136 registry.emplace<
TagComponent>(selectedEntityHandle,
"Entity");
144 auto& tagComp = registry.get<
TagComponent>(selectedEntityHandle);
150 panel.
InputText(
"##TagInput", &tagComp.tag);
153 panel.
TextColored({ 0.5f, 0.5f, 0.5f, 1.0f },
"UUID: " + std::to_string(
static_cast<uint64_t
>(tagComp.uuid)));
159 bool removeTransform =
false;
160 bool resetTransform =
false;
166 transform.Position = glm::vec3(0.0f);
167 transform.Rotation = glm::vec3(0.0f);
168 transform.Scale = glm::vec3(1.0f);
174 transform.Matrix = transform.GetTransformMatrix();
181 bool removeMesh =
false;
182 bool resetMesh =
false;
191 auto& mesh = registry.get<
MeshComponent>(selectedEntityHandle);
194 mesh.MeshData =
nullptr;
195 mesh.MeshIdentifier.clear();
199 float labelWidth = totalWidth * 0.3f;
200 float fieldWidth = totalWidth * 0.7f;
205 std::string displayLabel =
"None (Mesh)";
206 if (mesh.MeshData && !mesh.MeshIdentifier.empty())
208 displayLabel = mesh.MeshIdentifier;
210 else if (mesh.MeshData)
212 displayLabel =
"Runtime Mesh";
215 if (panel.
Button(displayLabel, glm::vec2(fieldWidth - 4.0f, 22.0f)))
222 static std::string meshSearchFilter;
223 if (meshSearchFilter.capacity() < 128)
224 meshSearchFilter.reserve(128);
227 panel.
InputText(
"##MeshSearch", &meshSearchFilter);
235 std::string Identifier;
238 static const std::vector<MeshOption> builtinMeshes = {
240 {
"Cube",
"builtin://cube" }
243 std::string lowerFilter = meshSearchFilter;
244 std::transform(lowerFilter.begin(), lowerFilter.end(), lowerFilter.begin(), ::tolower);
246 for (
const auto& option : builtinMeshes)
248 std::string lowerName = option.Name;
249 std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), ::tolower);
251 if (!lowerFilter.empty() && lowerName.find(lowerFilter) == std::string::npos)
254 if (panel.
Button(option.Name, glm::vec2(220.0f, 22.0f)))
256 mesh.MeshIdentifier = option.Identifier;
257 if (option.Identifier.empty())
259 mesh.MeshData =
nullptr;
266 meshSearchFilter.clear();
279 bool removeMaterial =
false;
280 bool resetMaterial =
false;
281 DrawComponentHeader(panel,
"Mesh Renderer / Material",
true, removeMaterial, resetMaterial);
292 material.MaterialInstance.reset();
293 material.MaterialIdentifier.clear();
296 auto toProjectPath = [](
const std::string& selected) -> std::string
298 if (selected.empty())
return {};
301 namespace fs = std::filesystem;
302 const fs::path abs = fs::absolute(selected).lexically_normal();
303 const fs::path cwd = fs::current_path();
304 const fs::path relative = fs::relative(abs, cwd);
305 if (!relative.empty() && *relative.begin() !=
"..")
306 return relative.generic_string();
307 return abs.generic_string();
309 catch (
const std::exception&)
315 panel.
Text(
"Material Asset");
316 panel.
Text(material.MaterialIdentifier.empty()
317 ? (material.MaterialInstance ?
"Runtime-only (not saved)" :
"None")
318 : material.MaterialIdentifier);
320 if (panel.
Button(
"Load .fmat"))
323 "Finality Material (*.fmat)\0*.fmat\0All Files (*.*)\0*.*\0");
324 if (!selected.empty())
326 const std::string path = toProjectPath(selected);
330 auto instance = asset->CreateInstance();
333 material.MaterialIdentifier = path;
334 material.MaterialInstance = std::move(instance);
340 if (!material.MaterialIdentifier.empty() && material.MaterialInstance)
346 panel.
Text(
"Type: " + asset->GetDefinition().Type);
347 panel.
Text(
"Shader: " + asset->GetDefinition().FragmentShader);
349 for (
const auto& property : asset->GetDefinition().Properties)
354 if (material.MaterialInstance->TryGetUniform1f(property.Name, value))
356 if (panel.
SliderFloat(property.Name, &value, -10.0f, 10.0f))
357 material.MaterialInstance->SetUniform1f(property.Name, value);
363 if (material.MaterialInstance->TryGetUniformVec4(property.Name, value))
365 float rgba[4] = { value.r, value.g, value.b, value.a };
367 material.MaterialInstance->SetUniformVec4(property.Name,
368 glm::vec4(rgba[0], rgba[1], rgba[2], rgba[3]));
373 if (panel.
Button(
"Save As .fmat"))
375 const std::string defaultName = asset->GetDefinition().Name +
".fmat";
377 "Finality Material (*.fmat)\0*.fmat\0All Files (*.*)\0*.*\0",
378 defaultName.c_str());
379 if (!selected.empty())
381 std::filesystem::path saved(selected);
382 if (saved.extension() !=
".fmat") saved.replace_extension(
".fmat");
383 const auto previous = asset->GetDefinition();
384 asset->UpdateDefaultsFromInstance(*material.MaterialInstance);
386 asset->GetDefinition() = previous;
387 if (savedSuccessfully)
389 material.MaterialIdentifier = toProjectPath(saved.string());
402 bool removeCamera =
false;
403 bool resetCamera =
false;
412 auto& cameraComp = registry.get<
CameraComponent>(selectedEntityHandle);
415 cameraComp.FOV = 45.0f;
416 cameraComp.NearClip = 0.1f;
417 cameraComp.FarClip = 1000.0f;
418 cameraComp.RebuildCamera();
422 panel.
Checkbox(
"Main Camera (Primary)", &cameraComp.IsPrimary);
424 if (cameraComp.IsPrimary && !wasPrimary)
427 for (
auto entity : camView)
429 if (entity != selectedEntityHandle)
436 float prevFOV = cameraComp.FOV;
437 float prevNear = cameraComp.NearClip;
438 float prevFar = cameraComp.FarClip;
441 DrawFloatControl(panel,
"Clipping Near", cameraComp.NearClip, 0.01f, 10.0f);
442 DrawFloatControl(panel,
"Clipping Far", cameraComp.FarClip, 10.0f, 5000.0f);
444 if (cameraComp.FOV != prevFOV || cameraComp.NearClip != prevNear || cameraComp.FarClip != prevFar)
446 cameraComp.RebuildCamera();
455 float buttonWidth = 180.0f;
458 if (panel.
Button(
"Add Component", glm::vec2(buttonWidth, 26.0f)))
465 static std::string componentSearchFilter;
466 if (componentSearchFilter.capacity() < 128)
467 componentSearchFilter.reserve(128);
469 float popupItemWidth = 220.0f;
472 panel.
InputText(
"##CompSearch", &componentSearchFilter);
477 struct ComponentEntry
483 std::vector<ComponentEntry> availableComponents = {
484 {
"Mesh Filter", registry.all_of<
MeshComponent>(selectedEntityHandle) },
489 std::string lowerFilter = componentSearchFilter;
490 std::transform(lowerFilter.begin(), lowerFilter.end(), lowerFilter.begin(), ::tolower);
492 bool anyShown =
false;
494 for (
const auto& entry : availableComponents)
496 if (entry.AlreadyAdded)
499 std::string lowerName = entry.Name;
500 std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), ::tolower);
502 if (!lowerFilter.empty() && lowerName.find(lowerFilter) == std::string::npos)
507 if (panel.
Button(entry.Name, glm::vec2(popupItemWidth, 24.0f)))
509 if (entry.Name ==
"Mesh Filter")
513 else if (entry.Name ==
"Material")
517 else if (entry.Name ==
"Camera")
520 bool hasPrimaryInScene =
false;
521 for (
auto entity : camView)
525 hasPrimaryInScene =
true;
530 auto& newCam = registry.emplace<
CameraComponent>(selectedEntityHandle, 45.0f, 1.778f, 0.1f, 1000.0f);
534 componentSearchFilter.clear();
541 panel.
TextColored({ 0.5f, 0.5f, 0.5f, 1.0f },
"No matching components available.");