@@ -18,7 +18,7 @@ struct Modified {
1818 }
1919};
2020
21- using DragFloatFunc = bool (*)(const char *, float * v, float , float , float , const char *, ImGuiSliderFlags);
21+ using DragFloatFunc = bool (*)(char const *, float * v, float , float , float , char const *, ImGuiSliderFlags);
2222
2323constexpr DragFloatFunc drag_float_vtable[] = {
2424 nullptr , &ImGui::DragFloat, &ImGui::DragFloat2, &ImGui::DragFloat3, &ImGui::DragFloat4,
@@ -153,14 +153,14 @@ bool Inspector::inspect(Lights& out_lights) const {
153153bool Inspector::do_inspect (Transform& out_transform, Bool& out_unified_scaling, Bool scaling_toggle) const {
154154 auto ret = Modified{};
155155 auto vec3 = out_transform.position ();
156- if (ret (inspect (" Position" , vec3))) { out_transform.set_position (vec3); }
156+ if (ret (inspect (" Position" , vec3, 0 . 1f ))) { out_transform.set_position (vec3); }
157157 auto quat = out_transform.orientation ();
158158 if (ret (inspect (" Orientation" , quat))) { out_transform.set_orientation (quat); }
159159 vec3 = out_transform.scale ();
160160 if (out_unified_scaling) {
161- if (ret (ImGui::DragFloat (" Scale" , &vec3.x , 0 .1f ))) { out_transform.set_scale ({vec3.x , vec3.x , vec3.x }); }
161+ if (ret (ImGui::DragFloat (" Scale" , &vec3.x , 0 .05f ))) { out_transform.set_scale ({vec3.x , vec3.x , vec3.x }); }
162162 } else {
163- if (ret (inspect (" Scale" , vec3, 0 .1f ))) { out_transform.set_scale (vec3); }
163+ if (ret (inspect (" Scale" , vec3, 0 .05f ))) { out_transform.set_scale (vec3); }
164164 }
165165 if (scaling_toggle) {
166166 ImGui::SameLine ();
@@ -182,16 +182,28 @@ bool SceneInspector::inspect(NotClosed<TreeNode>, LitMaterial& out_material) con
182182 ret (ImGui::SliderFloat (" Metallic" , &out_material.metallic , 0 .0f , 1 .0f ));
183183 ret (ImGui::SliderFloat (" Roughness" , &out_material.roughness , 0 .0f , 1 .0f ));
184184 ret (inspect_rgb (" Albedo" , out_material.albedo ));
185+ if (out_material.emissive ) { ret (inspect_rgb (" Emission" , out_material.emissive_factor )); }
185186 if (out_material.base_colour || out_material.roughness_metallic ) {
186187 auto const ri = ResourceInspector{m_target, m_scene.resources ()};
187188 if (out_material.base_colour ) {
188189 auto const * tex = m_scene.find (*out_material.base_colour );
189190 ri.display (*tex, *out_material.base_colour , " Base Colour: " );
191+ if (ImGui::BeginDragDropTarget ()) {
192+ if (ImGuiPayload const * payload = ImGui::AcceptDragDropPayload (" ID_TEXTURE" )) {
193+ assert (payload->DataSize == sizeof (std::size_t ));
194+ out_material.base_colour = *reinterpret_cast <std::size_t *>(payload->Data );
195+ }
196+ ImGui::EndDragDropTarget ();
197+ }
190198 }
191199 if (out_material.roughness_metallic ) {
192200 auto const * tex = m_scene.find (*out_material.roughness_metallic );
193201 ri.display (*tex, *out_material.roughness_metallic , " Roughness Metallic: " );
194202 }
203+ if (out_material.emissive ) {
204+ auto const * tex = m_scene.find (*out_material.emissive );
205+ ri.display (*tex, *out_material.emissive , " Emissive: " );
206+ }
195207 }
196208 return ret.value ;
197209}
@@ -224,13 +236,24 @@ bool SceneInspector::inspect(Id<Mesh> mesh_id) const {
224236 return ret.value ;
225237}
226238
239+ bool SceneInspector::inspect (Id<Camera> camera_id) const {
240+ auto ret = Modified{};
241+ auto * camera = m_scene.find (camera_id);
242+ if (!camera) { return ret.value ; }
243+ if (ImGui::CollapsingHeader (FixedString{" Camera ({})###Camera" , camera_id}.c_str ())) {
244+ ret (ImGui::DragFloat (" Exposure" , &camera->exposure , 0 .1f , 0 .0f , 10 .0f ));
245+ }
246+ return ret.value ;
247+ }
248+
227249bool SceneInspector::inspect (Id<Node> node_id, Bool& out_unified_scaling) const {
228250 auto ret = Modified{};
229251 auto * node = m_scene.find (node_id);
230252 if (!node) { return false ; }
231253 ret (inspect (node->transform , out_unified_scaling));
232254 ret (inspect (node->instances , out_unified_scaling));
233255 if (auto const * mesh_id = node->find <Id<Mesh>>()) { ret (inspect (*mesh_id)); }
256+ if (auto const * camera_id = node->find <Id<Camera>>()) { ret (inspect (*camera_id)); }
234257 return ret.value ;
235258}
236259
@@ -283,13 +306,20 @@ void ResourceInspector::display(Camera const& camera, std::size_t index, std::st
283306}
284307
285308void ResourceInspector::display (Texture const & texture, std::size_t index, std::string_view prefix) const {
286- if (auto tn = editor::TreeNode{FixedString<128 >{" {}{} ({})" , prefix, texture.name (), index}.c_str ()}) {
309+ auto const name = FixedString<128 >{" {}{} ({})" , prefix, texture.name (), index};
310+ if (auto tn = editor::TreeNode{name.c_str ()}) {
287311 auto const view = texture.view ();
288312 editor::TreeNode::leaf (FixedString{" Extent: {}x{}" , view.extent .width , view.extent .height }.c_str ());
289313 editor::TreeNode::leaf (FixedString{" Mip levels: {}" , texture.mip_levels ()}.c_str ());
290314 auto const cs = texture.colour_space () == ColourSpace::eLinear ? " linear" : " sRGB" ;
291315 editor::TreeNode::leaf (FixedString{" Colour Space: {}" , cs}.c_str ());
292316 }
317+
318+ if (ImGui::BeginDragDropSource ()) {
319+ ImGui::SetDragDropPayload (" ID_TEXTURE" , &index, sizeof (index));
320+ ImGui::Text (" %s" , name.c_str ());
321+ ImGui::EndDragDropSource ();
322+ }
293323}
294324
295325void ResourceInspector::display (Material const & material, std::size_t const index, std::string_view prefix) const {
0 commit comments