Skip to content

Commit

Permalink
[hide] Fix render props inconcistencies between prefab and fx editor
Browse files Browse the repository at this point in the history
  • Loading branch information
EspeuteClement committed Nov 21, 2024
1 parent 4880988 commit a871da2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 42 deletions.
3 changes: 2 additions & 1 deletion hide/comp/SceneEditor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4373,10 +4373,11 @@ class SceneEditor {
if( newRenderProps == null )
newRenderProps = renderProps[0];

scene.s3d.renderer.props = scene.s3d.renderer.getDefaultProps();

if (newRenderProps != previousRenderProps) {
if (previousRenderProps != null)
removeInstance(previousRenderProps);
scene.s3d.renderer.props = scene.s3d.renderer.getDefaultProps();
lastRenderProps = newRenderProps;
if (lastRenderProps != null) {
if (renderPropsRoot != null) {
Expand Down
41 changes: 0 additions & 41 deletions hide/view/FXEditor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,6 @@ class FXEditor extends hide.view.FileView {
var treePanel : hide.comp.ResizablePanel;
var animPanel : hide.comp.ResizablePanel;
var leftAnimPanel : hide.comp.ResizablePanel;
var light : h3d.scene.fwd.DirLight;
var lightDirection = new h3d.Vector( 1, 2, -4 );

var scene(get, null): hide.comp.Scene;
function get_scene() return sceneEditor.scene;
Expand Down Expand Up @@ -577,13 +575,6 @@ class FXEditor extends hide.view.FileView {
setRenderPropsEditionVisibility(Ide.inst.currentConfig.get("sceneeditor.renderprops.edit", false));
}
public function onSceneReady() {
light = sceneEditor.scene.s3d.find(function(o) return Std.downcast(o, h3d.scene.fwd.DirLight));
if( light == null ) {
light = new h3d.scene.fwd.DirLight(scene.s3d);
light.enableSpecular = true;
} else
light = null;

var axis = new h3d.scene.Graphics(scene.s3d);
axis.z = 0.001;
axis.lineStyle(2,0xFF0000); axis.lineTo(1,0,0);
Expand Down Expand Up @@ -629,30 +620,6 @@ class FXEditor extends hide.view.FileView {

tools.makeToolbar(toolsDefs, config, keys);

function renderProps() {
properties.clear();
var renderer = scene.s3d.renderer;
var group = new Element('<div class="group" name="Renderer"></div>');
renderer.editProps().appendTo(group);
properties.add(group, renderer.props, function(_) {
renderer.refreshProps();
if( !properties.isTempChange ) renderProps();
});
var lprops = {
power : Math.sqrt(light.color.r),
enable: true
};
var group = new Element('<div class="group" name="Light">
<dl>
<dt>Power</dt><dd><input type="range" min="0" max="4" field="power"/></dd>
</dl>
</div>');
properties.add(group, lprops, function(_) {
var p = lprops.power * lprops.power;
light.color.set(p, p, p);
});
}
tools.addButton("gears", "Renderer Properties", renderProps);
tools.addToggle("refresh", "refresh", "Auto synchronize", function(b) {
autoSync = b;
});
Expand Down Expand Up @@ -1818,14 +1785,6 @@ class FXEditor extends hide.view.FileView {
}

var cam = scene.s3d.camera;
if( light != null ) {
var angle = Math.atan2(cam.target.y - cam.pos.y, cam.target.x - cam.pos.x);
light.setDirection(new h3d.Vector(
Math.cos(angle) * lightDirection.x - Math.sin(angle) * lightDirection.y,
Math.sin(angle) * lightDirection.x + Math.cos(angle) * lightDirection.y,
lightDirection.z
));
}
if( autoSync && (currentVersion != undo.currentID || lastSyncChange != properties.lastChange) ) {
save();
lastSyncChange = properties.lastChange;
Expand Down

0 comments on commit a871da2

Please sign in to comment.