- [Warp, Area Warp] Fix default anchor position not the same as surface dimension.

This commit is contained in:
Tanasart 2023-09-02 10:43:33 +02:00
parent d0d753e9fe
commit 7ad45363c7
4 changed files with 52 additions and 72 deletions

View file

@ -2,9 +2,9 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
name = "3D Camera"; name = "3D Camera";
batch_output = true; batch_output = true;
object = new __3dCamera_object(); object = new __3dCamera_object();
camera = new __3dCamera(); camera = new __3dCamera();
lookat = new __3dGizmoSphere(0.5, c_ltgray, 1); lookat = new __3dGizmoSphere(0.5, c_ltgray, 1);
lookLine = noone; lookLine = noone;
lookRad = new __3dGizmoCircleZ(0.5, c_yellow, 0.5); lookRad = new __3dGizmoCircleZ(0.5, c_yellow, 0.5);

View file

@ -36,7 +36,7 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
input_display_list = [ input_display_list = [
["Output", true], 9, 6, 10, ["Output", true], 9, 6, 10,
["Text", false], 0, 7, 8, 5, ["Text", false], 0, 7, 8, 5,
["Font properties", false], 1, 2, 3, 4 ["Font properties", false], 1, 2, 3,
]; ];
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
@ -46,30 +46,22 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
_font_current = ""; _font_current = "";
_size_current = 0; _size_current = 0;
_aa_current = false; _aa_current = false;
_rang_current = [0, 0];
static generateFont = function(_path, _size, _aa, _range) { static generateFont = function(_path, _size, _aa) {
if(PROJECT.animator.is_playing) return; if(PROJECT.animator.is_playing) return;
if(_path == _font_current && _size == _size_current && _aa == _aa_current) return;
if(_path == _font_current &&
_size == _size_current &&
_aa == _aa_current &&
_rang_current[0] == _range[0] &&
_rang_current[1] == _range[1]) return;
_font_current = _path; _font_current = _path;
_size_current = _size; _size_current = _size;
_aa_current = _aa; _aa_current = _aa;
_rang_current[0] = _range[0];
_rang_current[1] = _range[1];
if(file_exists(_path)) { if(!file_exists(_path)) return;
if(font != f_p0 && font_exists(font))
font_delete(font); if(font != f_p0 && font_exists(font))
font_delete(font);
font_add_enable_aa(_aa); font_add_enable_aa(_aa);
font = font_add(_path, _size, false, false, _range[0], _range[1]); font = font_add(_path, _size, false, false, 0, 0);
}
} }
static processData = function(_outSurf, _data, _output_index, _array_index) { static processData = function(_outSurf, _data, _output_index, _array_index) {
@ -77,7 +69,6 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
var _font = _data[1]; var _font = _data[1];
var _size = _data[2]; var _size = _data[2];
var _aa = _data[3]; var _aa = _data[3];
var _range = _data[4];
var _col = _data[5]; var _col = _data[5];
var _dim_type = _data[9]; var _dim_type = _data[9];
@ -88,7 +79,7 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
var ww, hh; var ww, hh;
generateFont(_font, _size, _aa, _range); generateFont(_font, _size, _aa);
draw_set_font(font); draw_set_font(font);
if(_dim_type == 0) { if(_dim_type == 0) {
@ -105,7 +96,7 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
surface_set_target(_outSurf); surface_set_target(_outSurf);
DRAW_CLEAR DRAW_CLEAR
BLEND_OVERRIDE; BLEND_ALPHA
if(_dim[0] != 0 && _dim[1] != 0) { if(_dim[0] != 0 && _dim[1] != 0) {
var _hali = _data[7]; var _hali = _data[7];

View file

@ -37,7 +37,26 @@ function Node_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
drag_my = 0; drag_my = 0;
drag_s = [[0, 0], [0, 0]]; drag_s = [[0, 0], [0, 0]];
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { attributes[? "initalset"] = false;
static onValueFromUpdate = function(index) { #region
if(index == 0 && attributes[? "initalset"] == false) {
var _surf = inputs[| 0].getValue();
if(!is_surface(_surf)) return;
var _sw = surface_get_width(_surf);
var _sh = surface_get_height(_surf);
inputs[| 1].setValue([ 0, 0 ]);
inputs[| 2].setValue([ _sw, 0 ]);
inputs[| 3].setValue([ 0, _sh ]);
inputs[| 4].setValue([ _sw, _sh ]);
attributes[? "initalset"] = true;
}
} #endregion
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
if(array_length(current_data) < ds_list_size(inputs)) return; if(array_length(current_data) < ds_list_size(inputs)) return;
var _surf = outputs[| 0].getValue(); var _surf = outputs[| 0].getValue();
@ -171,9 +190,9 @@ function Node_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
inputs[| 2].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); inputs[| 2].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
inputs[| 3].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); inputs[| 3].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
inputs[| 4].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); inputs[| 4].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
} } #endregion
static processData = function(_outSurf, _data, _output_index, _array_index) { static processData = function(_outSurf, _data, _output_index, _array_index) { #region
var tl = _data[1]; var tl = _data[1];
var tr = _data[2]; var tr = _data[2];
var bl = _data[3]; var bl = _data[3];
@ -204,51 +223,6 @@ function Node_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
surface_reset_shader(); surface_reset_shader();
} }
//surface_set_shader(_outSurf);
//shader_set_interpolation(_data[0]);
// draw_set_color(c_white);
// var tex = surface_get_texture(_data[0]);
// draw_primitive_begin_texture(pr_trianglestrip, tex);
// var res = 4;
// var _i0, _i1, _j0, _j1;
// var tl_x = tl[0];
// var tl_y = tl[1];
// var tr_x = tr[0];
// var tr_y = tr[1];
// var bl_x = bl[0];
// var bl_y = bl[1];
// var br_x = br[0];
// var br_y = br[1];
// for( var i = 0; i < res; i++ ) {
// for( var j = 0; j < res; j++ ) {
// _i0 = i / res;
// _i1 = (i + 1) / res;
// _j0 = j / res;
// _j1 = (j + 1) / res;
// var _tlx = lerp(lerp(tl_x, tr_x, _i0), lerp(bl_x, br_x, _i0), _j0);
// var _tly = lerp(lerp(tl_y, tr_y, _i0), lerp(bl_y, br_y, _i0), _j0);
// var _trx = lerp(lerp(tl_x, tr_x, _i1), lerp(bl_x, br_x, _i1), _j0);
// var _try = lerp(lerp(tl_y, tr_y, _i1), lerp(bl_y, br_y, _i1), _j0);
// var _blx = lerp(lerp(tl_x, tr_x, _i0), lerp(bl_x, br_x, _i0), _j1);
// var _bly = lerp(lerp(tl_y, tr_y, _i0), lerp(bl_y, br_y, _i0), _j1);
// var _brx = lerp(lerp(tl_x, tr_x, _i1), lerp(bl_x, br_x, _i1), _j1);
// var _bry = lerp(lerp(tl_y, tr_y, _i1), lerp(bl_y, br_y, _i1), _j1);
// draw_vertex_texture(_tlx, _tly, _i0, _j0);
// draw_vertex_texture(_trx, _try, _i1, _j0);
// draw_vertex_texture(_blx, _bly, _i0, _j1);
// draw_vertex_texture(_brx, _bry, _i1, _j1);
// }
// }
// draw_primitive_end();
//surface_reset_shader();
return _outSurf; return _outSurf;
} } #endregion
} }

View file

@ -19,6 +19,21 @@ function Node_Wrap_Area(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
attribute_surface_depth(); attribute_surface_depth();
attribute_interpolation(); attribute_interpolation();
attributes[? "initalset"] = false;
static onValueFromUpdate = function(index) { #region
if(index == 0 && attributes[? "initalset"] == false) {
var _surf = inputs[| 0].getValue();
if(!is_surface(_surf)) return;
var _sw = surface_get_width(_surf);
var _sh = surface_get_height(_surf);
inputs[| 1].setValue([ _sw / 2, _sh / 2, _sw / 2, _sh / 2, AREA_SHAPE.rectangle ]);
attributes[? "initalset"] = true;
}
} #endregion
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) {
inputs[| 1].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); inputs[| 1].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
} }