AryanpurTech / BlueEngine

Blue Engine is a general-purpose and easy-to-use graphics engine written in rust.
Apache License 2.0
316 stars 14 forks source link

Updating scale does not immediately update the scale until the update position is called #21

Closed rustylabs closed 1 year ago

rustylabs commented 1 year ago

Here is my code for updating position and scale

ui.label("Position");
                                ui.horizontal(|ui|
                                {
                                    // Has user moved the shape or not
                                    let mut update_position = false;

                                    for position in object.1.position.iter_mut()
                                    {
                                        ui.label(format!("{}:", position.axis as char));

                                        // Use Response::changed or whatever to determine if the value has been changed
                                        if ui.add(egui::DragValue::new(&mut position.value).speed(editor_settings.slider_speed)).changed()
                                        {
                                            //println!("Changed!");
                                            update_position = true;
                                        }

                                    }
                                    // Updates the shape's position if the user has changed its value
                                    if update_position == true
                                    {
                                        //println!("update_position: {update_position}");
                                        gameengine_objects
                                            .get_mut(&object.0.label.0)
                                            //.get_mut("Object 0")
                                            .unwrap()
                                            .position(object.1.position[0].value, object.1.position[1].value, object.1.position[2].value);
                                    }

                                });
                                ui.separator();

                                ui.label("Scale");
                                ui.horizontal(|ui|
                                {
                                    let mut update_scale = false;

                                    for scale in object.1.scale.iter_mut()
                                    {
                                        ui.label(format!("{}:", scale.axis as char));
                                        if ui.add(egui::DragValue::new(&mut scale.value).speed(editor_settings.slider_speed)).changed()
                                        {
                                            update_scale = true;
                                        }
                                    }

                                    if update_scale == true
                                    {
                                        println!("object.0.label.0: {}", object.0.label.0);
                                        gameengine_objects
                                            .get_mut(&object.0.label.0)
                                            .unwrap()
                                            .scale(object.1.scale[0].value, object.1.scale[1].value, object.1.scale[2].value);
                                    }
                                });

image

So as you can see if I am only moving the scale, it will only update the shape's scale and nothing else. If I am only moving the position, then it will only update the position.

The issue is that if I update the scale property, the scale change does not come into effect until I changed the position.

Here is a gif to explain to you what is going on:

cmd_6zGYPIiDGB

ElhamAryanpur commented 1 year ago

image it doesn't scale on position for me tho

ElhamAryanpur commented 1 year ago

ohhhhhhhh, ok ok, I see the problem

ElhamAryanpur commented 1 year ago

fixed with https://github.com/rustylabs/blue_flame/pull/4