2002-10-12 11:37:38 +00:00
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-01-07 19:13:47 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
2011-02-27 20:37:56 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup bli
|
2012-03-13 01:55:25 +00:00
|
|
|
*
|
|
|
|
* A minimalist lib for functions doing stuff with rectangle structs.
|
2011-02-27 20:37:56 +00:00
|
|
|
*/
|
|
|
|
|
2017-08-27 16:01:06 +10:00
|
|
|
#include <stdlib.h>
|
2010-08-25 08:31:52 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-07-12 08:31:23 +00:00
|
|
|
#include <limits.h>
|
|
|
|
#include <float.h>
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
#include "BLI_rect.h"
|
2018-11-07 12:17:58 +11:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
|
|
#include "DNA_vec_types.h"
|
2011-02-14 17:55:27 +00:00
|
|
|
|
2017-08-27 16:01:06 +10:00
|
|
|
/* avoid including BLI_math */
|
|
|
|
static void unit_m4(float m[4][4]);
|
|
|
|
|
2012-07-14 00:33:58 +00:00
|
|
|
/**
|
|
|
|
* Determine if a rect is empty. An empty
|
|
|
|
* rect is one with a zero (or negative)
|
|
|
|
* width or height.
|
|
|
|
*
|
|
|
|
* \return True if \a rect is empty.
|
|
|
|
*/
|
2013-03-09 05:35:49 +00:00
|
|
|
bool BLI_rcti_is_empty(const rcti *rect)
|
2010-02-16 15:59:36 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return ((rect->xmax <= rect->xmin) || (rect->ymax <= rect->ymin));
|
2010-02-16 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
2013-03-09 05:35:49 +00:00
|
|
|
bool BLI_rctf_is_empty(const rctf *rect)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return ((rect->xmax <= rect->xmin) || (rect->ymax <= rect->ymin));
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2013-12-06 18:48:55 +11:00
|
|
|
bool BLI_rcti_isect_x(const rcti *rect, const int x)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (x < rect->xmin) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (x > rect->xmax) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2013-12-06 18:48:55 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BLI_rcti_isect_y(const rcti *rect, const int y)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (y < rect->ymin) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (y > rect->ymax) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2013-12-06 18:48:55 +11:00
|
|
|
}
|
|
|
|
|
2013-03-09 05:35:49 +00:00
|
|
|
bool BLI_rcti_isect_pt(const rcti *rect, const int x, const int y)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (x < rect->xmin) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (x > rect->xmax) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (y < rect->ymin) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (y > rect->ymax) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2013-03-09 05:35:49 +00:00
|
|
|
bool BLI_rcti_isect_pt_v(const rcti *rect, const int xy[2])
|
2012-07-11 18:17:48 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (xy[0] < rect->xmin) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (xy[0] > rect->xmax) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (xy[1] < rect->ymin) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (xy[1] > rect->ymax) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2012-07-11 18:17:48 +00:00
|
|
|
}
|
|
|
|
|
2013-12-06 18:48:55 +11:00
|
|
|
bool BLI_rctf_isect_x(const rctf *rect, const float x)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (x < rect->xmin) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (x > rect->xmax) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2013-12-06 18:48:55 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BLI_rctf_isect_y(const rctf *rect, const float y)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (y < rect->ymin) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (y > rect->ymax) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2013-12-06 18:48:55 +11:00
|
|
|
}
|
|
|
|
|
2013-03-09 05:35:49 +00:00
|
|
|
bool BLI_rctf_isect_pt(const rctf *rect, const float x, const float y)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (x < rect->xmin) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (x > rect->xmax) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (y < rect->ymin) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (y > rect->ymax) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2013-03-09 05:35:49 +00:00
|
|
|
bool BLI_rctf_isect_pt_v(const rctf *rect, const float xy[2])
|
2012-07-11 18:17:48 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (xy[0] < rect->xmin) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (xy[0] > rect->xmax) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (xy[1] < rect->ymin) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (xy[1] > rect->ymax) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2012-07-11 18:17:48 +00:00
|
|
|
}
|
|
|
|
|
File Browser Arrow Keys Navigation
Adds support for selecting/deselecting files in File Browser using the
arrow keys. All directions (up, down, left, right) are possible.
When to Select, When to Deselect?
Standard behaviour is selecting, however if we move into a block of
already selected files (meaning 2+ files are selected) we start
deselecting
Possible Selection Methods
Simple selection (arrow-key): All other files are deselected
Expand selection (Shift+arrow key): Add to/remove from existing
selection
ill-Expand selection (Ctrl+Shift+arrow key): Add to/remove from existing
selection and fill everything in-between
From which file do we start navigating?
From each available selection method (Mouse-, Walk-, All-, Border
Select), we use the last selected file. If there's no selection at all
we use the first (down/right arrow) or last (up/left arrow) file.
(Ideally, the view would automatically be set to the new selection, but
this behaviour overlaps with an other patch I've been working on, so
prefer to do that separately)
(Also tweaks color for highlighted file for better feedback)
D1297, Review done by @campbellbarton, thx a lot :)
2015-06-11 17:20:29 +02:00
|
|
|
/**
|
|
|
|
* \returns shortest distance from \a rect to x/y (0 if inside)
|
2018-01-10 19:57:02 +11:00
|
|
|
*/
|
File Browser Arrow Keys Navigation
Adds support for selecting/deselecting files in File Browser using the
arrow keys. All directions (up, down, left, right) are possible.
When to Select, When to Deselect?
Standard behaviour is selecting, however if we move into a block of
already selected files (meaning 2+ files are selected) we start
deselecting
Possible Selection Methods
Simple selection (arrow-key): All other files are deselected
Expand selection (Shift+arrow key): Add to/remove from existing
selection
ill-Expand selection (Ctrl+Shift+arrow key): Add to/remove from existing
selection and fill everything in-between
From which file do we start navigating?
From each available selection method (Mouse-, Walk-, All-, Border
Select), we use the last selected file. If there's no selection at all
we use the first (down/right arrow) or last (up/left arrow) file.
(Ideally, the view would automatically be set to the new selection, but
this behaviour overlaps with an other patch I've been working on, so
prefer to do that separately)
(Also tweaks color for highlighted file for better feedback)
D1297, Review done by @campbellbarton, thx a lot :)
2015-06-11 17:20:29 +02:00
|
|
|
|
|
|
|
int BLI_rcti_length_x(const rcti *rect, const int x)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (x < rect->xmin) {
|
|
|
|
return rect->xmin - x;
|
|
|
|
}
|
|
|
|
if (x > rect->xmax) {
|
|
|
|
return x - rect->xmax;
|
|
|
|
}
|
|
|
|
return 0;
|
File Browser Arrow Keys Navigation
Adds support for selecting/deselecting files in File Browser using the
arrow keys. All directions (up, down, left, right) are possible.
When to Select, When to Deselect?
Standard behaviour is selecting, however if we move into a block of
already selected files (meaning 2+ files are selected) we start
deselecting
Possible Selection Methods
Simple selection (arrow-key): All other files are deselected
Expand selection (Shift+arrow key): Add to/remove from existing
selection
ill-Expand selection (Ctrl+Shift+arrow key): Add to/remove from existing
selection and fill everything in-between
From which file do we start navigating?
From each available selection method (Mouse-, Walk-, All-, Border
Select), we use the last selected file. If there's no selection at all
we use the first (down/right arrow) or last (up/left arrow) file.
(Ideally, the view would automatically be set to the new selection, but
this behaviour overlaps with an other patch I've been working on, so
prefer to do that separately)
(Also tweaks color for highlighted file for better feedback)
D1297, Review done by @campbellbarton, thx a lot :)
2015-06-11 17:20:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int BLI_rcti_length_y(const rcti *rect, const int y)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (y < rect->ymin) {
|
|
|
|
return rect->ymin - y;
|
|
|
|
}
|
|
|
|
if (y > rect->ymax) {
|
|
|
|
return y - rect->ymax;
|
|
|
|
}
|
|
|
|
return 0;
|
File Browser Arrow Keys Navigation
Adds support for selecting/deselecting files in File Browser using the
arrow keys. All directions (up, down, left, right) are possible.
When to Select, When to Deselect?
Standard behaviour is selecting, however if we move into a block of
already selected files (meaning 2+ files are selected) we start
deselecting
Possible Selection Methods
Simple selection (arrow-key): All other files are deselected
Expand selection (Shift+arrow key): Add to/remove from existing
selection
ill-Expand selection (Ctrl+Shift+arrow key): Add to/remove from existing
selection and fill everything in-between
From which file do we start navigating?
From each available selection method (Mouse-, Walk-, All-, Border
Select), we use the last selected file. If there's no selection at all
we use the first (down/right arrow) or last (up/left arrow) file.
(Ideally, the view would automatically be set to the new selection, but
this behaviour overlaps with an other patch I've been working on, so
prefer to do that separately)
(Also tweaks color for highlighted file for better feedback)
D1297, Review done by @campbellbarton, thx a lot :)
2015-06-11 17:20:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
float BLI_rctf_length_x(const rctf *rect, const float x)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (x < rect->xmin) {
|
|
|
|
return rect->xmin - x;
|
|
|
|
}
|
|
|
|
if (x > rect->xmax) {
|
|
|
|
return x - rect->xmax;
|
|
|
|
}
|
|
|
|
return 0.0f;
|
File Browser Arrow Keys Navigation
Adds support for selecting/deselecting files in File Browser using the
arrow keys. All directions (up, down, left, right) are possible.
When to Select, When to Deselect?
Standard behaviour is selecting, however if we move into a block of
already selected files (meaning 2+ files are selected) we start
deselecting
Possible Selection Methods
Simple selection (arrow-key): All other files are deselected
Expand selection (Shift+arrow key): Add to/remove from existing
selection
ill-Expand selection (Ctrl+Shift+arrow key): Add to/remove from existing
selection and fill everything in-between
From which file do we start navigating?
From each available selection method (Mouse-, Walk-, All-, Border
Select), we use the last selected file. If there's no selection at all
we use the first (down/right arrow) or last (up/left arrow) file.
(Ideally, the view would automatically be set to the new selection, but
this behaviour overlaps with an other patch I've been working on, so
prefer to do that separately)
(Also tweaks color for highlighted file for better feedback)
D1297, Review done by @campbellbarton, thx a lot :)
2015-06-11 17:20:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
float BLI_rctf_length_y(const rctf *rect, const float y)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (y < rect->ymin) {
|
|
|
|
return rect->ymin - y;
|
|
|
|
}
|
|
|
|
if (y > rect->ymax) {
|
|
|
|
return y - rect->ymax;
|
|
|
|
}
|
|
|
|
return 0.0f;
|
File Browser Arrow Keys Navigation
Adds support for selecting/deselecting files in File Browser using the
arrow keys. All directions (up, down, left, right) are possible.
When to Select, When to Deselect?
Standard behaviour is selecting, however if we move into a block of
already selected files (meaning 2+ files are selected) we start
deselecting
Possible Selection Methods
Simple selection (arrow-key): All other files are deselected
Expand selection (Shift+arrow key): Add to/remove from existing
selection
ill-Expand selection (Ctrl+Shift+arrow key): Add to/remove from existing
selection and fill everything in-between
From which file do we start navigating?
From each available selection method (Mouse-, Walk-, All-, Border
Select), we use the last selected file. If there's no selection at all
we use the first (down/right arrow) or last (up/left arrow) file.
(Ideally, the view would automatically be set to the new selection, but
this behaviour overlaps with an other patch I've been working on, so
prefer to do that separately)
(Also tweaks color for highlighted file for better feedback)
D1297, Review done by @campbellbarton, thx a lot :)
2015-06-11 17:20:29 +02:00
|
|
|
}
|
|
|
|
|
2013-06-06 21:43:52 +00:00
|
|
|
/**
|
|
|
|
* is \a rct_b inside \a rct_a
|
|
|
|
*/
|
2018-09-04 17:33:12 +10:00
|
|
|
bool BLI_rctf_inside_rctf(const rctf *rct_a, const rctf *rct_b)
|
2013-06-06 21:43:52 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return ((rct_a->xmin <= rct_b->xmin) && (rct_a->xmax >= rct_b->xmax) &&
|
|
|
|
(rct_a->ymin <= rct_b->ymin) && (rct_a->ymax >= rct_b->ymax));
|
2013-06-06 21:43:52 +00:00
|
|
|
}
|
2018-09-04 17:33:12 +10:00
|
|
|
bool BLI_rcti_inside_rcti(const rcti *rct_a, const rcti *rct_b)
|
2013-06-06 21:43:52 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return ((rct_a->xmin <= rct_b->xmin) && (rct_a->xmax >= rct_b->xmax) &&
|
|
|
|
(rct_a->ymin <= rct_b->ymin) && (rct_a->ymax >= rct_b->ymax));
|
2013-06-06 21:43:52 +00:00
|
|
|
}
|
|
|
|
|
2019-01-15 23:15:58 +11:00
|
|
|
/* based closely on 'isect_seg_seg_v2_int',
|
|
|
|
* but in modified so corner cases are treated as intersections */
|
2012-10-10 01:22:19 +00:00
|
|
|
static int isect_segments_i(const int v1[2], const int v2[2], const int v3[2], const int v4[2])
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
const double div = (double)((v2[0] - v1[0]) * (v4[1] - v3[1]) -
|
|
|
|
(v2[1] - v1[1]) * (v4[0] - v3[0]));
|
|
|
|
if (div == 0.0) {
|
|
|
|
return 1; /* co-linear */
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
const double lambda = (double)((v1[1] - v3[1]) * (v4[0] - v3[0]) -
|
|
|
|
(v1[0] - v3[0]) * (v4[1] - v3[1])) /
|
|
|
|
div;
|
|
|
|
const double mu = (double)((v1[1] - v3[1]) * (v2[0] - v1[0]) -
|
|
|
|
(v1[0] - v3[0]) * (v2[1] - v1[1])) /
|
|
|
|
div;
|
|
|
|
return (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static int isect_segments_fl(const float v1[2],
|
|
|
|
const float v2[2],
|
|
|
|
const float v3[2],
|
|
|
|
const float v4[2])
|
|
|
|
{
|
|
|
|
const double div = (double)((v2[0] - v1[0]) * (v4[1] - v3[1]) -
|
|
|
|
(v2[1] - v1[1]) * (v4[0] - v3[0]));
|
|
|
|
if (div == 0.0) {
|
|
|
|
return 1; /* co-linear */
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
const double lambda = (double)((v1[1] - v3[1]) * (v4[0] - v3[0]) -
|
|
|
|
(v1[0] - v3[0]) * (v4[1] - v3[1])) /
|
|
|
|
div;
|
|
|
|
const double mu = (double)((v1[1] - v3[1]) * (v2[0] - v1[0]) -
|
|
|
|
(v1[0] - v3[0]) * (v2[1] - v1[1])) /
|
|
|
|
div;
|
|
|
|
return (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0);
|
|
|
|
}
|
2012-04-10 07:30:08 +00:00
|
|
|
}
|
|
|
|
|
2013-03-09 05:35:49 +00:00
|
|
|
bool BLI_rcti_isect_segment(const rcti *rect, const int s1[2], const int s2[2])
|
2012-04-10 07:30:08 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* first do outside-bounds check for both points of the segment */
|
|
|
|
if (s1[0] < rect->xmin && s2[0] < rect->xmin) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (s1[0] > rect->xmax && s2[0] > rect->xmax) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (s1[1] < rect->ymin && s2[1] < rect->ymin) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (s1[1] > rect->ymax && s2[1] > rect->ymax) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-07-31 14:25:09 +02:00
|
|
|
/* if either points intersect then we definitely intersect */
|
2019-04-17 06:17:24 +02:00
|
|
|
if (BLI_rcti_isect_pt_v(rect, s1) || BLI_rcti_isect_pt_v(rect, s2)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
2019-07-31 14:25:09 +02:00
|
|
|
/* both points are outside but may intersect the rect */
|
2019-04-17 06:17:24 +02:00
|
|
|
int tvec1[2];
|
|
|
|
int tvec2[2];
|
|
|
|
/* diagonal: [/] */
|
|
|
|
tvec1[0] = rect->xmin;
|
|
|
|
tvec1[1] = rect->ymin;
|
|
|
|
tvec2[0] = rect->xmin;
|
|
|
|
tvec2[1] = rect->ymax;
|
|
|
|
if (isect_segments_i(s1, s2, tvec1, tvec2)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* diagonal: [\] */
|
|
|
|
tvec1[0] = rect->xmin;
|
|
|
|
tvec1[1] = rect->ymax;
|
|
|
|
tvec2[0] = rect->xmax;
|
|
|
|
tvec2[1] = rect->ymin;
|
|
|
|
if (isect_segments_i(s1, s2, tvec1, tvec2)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no intersection */
|
|
|
|
return false;
|
|
|
|
}
|
2012-10-10 01:22:19 +00:00
|
|
|
}
|
|
|
|
|
2013-03-09 05:35:49 +00:00
|
|
|
bool BLI_rctf_isect_segment(const rctf *rect, const float s1[2], const float s2[2])
|
2012-10-10 01:22:19 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* first do outside-bounds check for both points of the segment */
|
|
|
|
if (s1[0] < rect->xmin && s2[0] < rect->xmin) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (s1[0] > rect->xmax && s2[0] > rect->xmax) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (s1[1] < rect->ymin && s2[1] < rect->ymin) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (s1[1] > rect->ymax && s2[1] > rect->ymax) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-07-31 14:25:09 +02:00
|
|
|
/* if either points intersect then we definitely intersect */
|
2019-04-17 06:17:24 +02:00
|
|
|
if (BLI_rctf_isect_pt_v(rect, s1) || BLI_rctf_isect_pt_v(rect, s2)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
2019-07-31 14:25:09 +02:00
|
|
|
/* both points are outside but may intersect the rect */
|
2019-04-17 06:17:24 +02:00
|
|
|
float tvec1[2];
|
|
|
|
float tvec2[2];
|
|
|
|
/* diagonal: [/] */
|
|
|
|
tvec1[0] = rect->xmin;
|
|
|
|
tvec1[1] = rect->ymin;
|
|
|
|
tvec2[0] = rect->xmin;
|
|
|
|
tvec2[1] = rect->ymax;
|
|
|
|
if (isect_segments_fl(s1, s2, tvec1, tvec2)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* diagonal: [\] */
|
|
|
|
tvec1[0] = rect->xmin;
|
|
|
|
tvec1[1] = rect->ymax;
|
|
|
|
tvec2[0] = rect->xmax;
|
|
|
|
tvec2[1] = rect->ymin;
|
|
|
|
if (isect_segments_fl(s1, s2, tvec1, tvec2)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no intersection */
|
|
|
|
return false;
|
|
|
|
}
|
2012-04-10 07:30:08 +00:00
|
|
|
}
|
|
|
|
|
2013-11-06 19:21:42 +00:00
|
|
|
bool BLI_rcti_isect_circle(const rcti *rect, const float xy[2], const float radius)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
float dx, dy;
|
2013-11-06 19:21:42 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (xy[0] >= rect->xmin && xy[0] <= rect->xmax) {
|
|
|
|
dx = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dx = (xy[0] < rect->xmin) ? (rect->xmin - xy[0]) : (xy[0] - rect->xmax);
|
|
|
|
}
|
2013-11-06 19:21:42 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (xy[1] >= rect->ymin && xy[1] <= rect->ymax) {
|
|
|
|
dy = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dy = (xy[1] < rect->ymin) ? (rect->ymin - xy[1]) : (xy[1] - rect->ymax);
|
|
|
|
}
|
2013-11-06 19:21:42 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return dx * dx + dy * dy <= radius * radius;
|
2013-11-06 19:21:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BLI_rctf_isect_circle(const rctf *rect, const float xy[2], const float radius)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
float dx, dy;
|
2013-11-06 19:21:42 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (xy[0] >= rect->xmin && xy[0] <= rect->xmax) {
|
|
|
|
dx = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dx = (xy[0] < rect->xmin) ? (rect->xmin - xy[0]) : (xy[0] - rect->xmax);
|
|
|
|
}
|
2013-11-06 19:21:42 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (xy[1] >= rect->ymin && xy[1] <= rect->ymax) {
|
|
|
|
dy = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dy = (xy[1] < rect->ymin) ? (rect->ymin - xy[1]) : (xy[1] - rect->ymax);
|
|
|
|
}
|
2013-11-06 19:21:42 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return dx * dx + dy * dy <= radius * radius;
|
2013-11-06 19:21:42 +00:00
|
|
|
}
|
|
|
|
|
2012-07-15 00:29:56 +00:00
|
|
|
void BLI_rctf_union(rctf *rct1, const rctf *rct2)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (rct1->xmin > rct2->xmin) {
|
|
|
|
rct1->xmin = rct2->xmin;
|
|
|
|
}
|
|
|
|
if (rct1->xmax < rct2->xmax) {
|
|
|
|
rct1->xmax = rct2->xmax;
|
|
|
|
}
|
|
|
|
if (rct1->ymin > rct2->ymin) {
|
|
|
|
rct1->ymin = rct2->ymin;
|
|
|
|
}
|
|
|
|
if (rct1->ymax < rct2->ymax) {
|
|
|
|
rct1->ymax = rct2->ymax;
|
|
|
|
}
|
2009-02-10 15:38:00 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-07-15 00:29:56 +00:00
|
|
|
void BLI_rcti_union(rcti *rct1, const rcti *rct2)
|
2009-02-10 15:38:00 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (rct1->xmin > rct2->xmin) {
|
|
|
|
rct1->xmin = rct2->xmin;
|
|
|
|
}
|
|
|
|
if (rct1->xmax < rct2->xmax) {
|
|
|
|
rct1->xmax = rct2->xmax;
|
|
|
|
}
|
|
|
|
if (rct1->ymin > rct2->ymin) {
|
|
|
|
rct1->ymin = rct2->ymin;
|
|
|
|
}
|
|
|
|
if (rct1->ymax < rct2->ymax) {
|
|
|
|
rct1->ymax = rct2->ymax;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2012-07-12 08:31:23 +00:00
|
|
|
void BLI_rctf_init(rctf *rect, float xmin, float xmax, float ymin, float ymax)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (xmin <= xmax) {
|
|
|
|
rect->xmin = xmin;
|
|
|
|
rect->xmax = xmax;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rect->xmax = xmin;
|
|
|
|
rect->xmin = xmax;
|
|
|
|
}
|
|
|
|
if (ymin <= ymax) {
|
|
|
|
rect->ymin = ymin;
|
|
|
|
rect->ymax = ymax;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rect->ymax = ymin;
|
|
|
|
rect->ymin = ymax;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
|
2012-07-12 08:31:23 +00:00
|
|
|
void BLI_rcti_init(rcti *rect, int xmin, int xmax, int ymin, int ymax)
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (xmin <= xmax) {
|
|
|
|
rect->xmin = xmin;
|
|
|
|
rect->xmax = xmax;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rect->xmax = xmin;
|
|
|
|
rect->xmin = xmax;
|
|
|
|
}
|
|
|
|
if (ymin <= ymax) {
|
|
|
|
rect->ymin = ymin;
|
|
|
|
rect->ymax = ymax;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rect->ymax = ymin;
|
|
|
|
rect->ymin = ymax;
|
|
|
|
}
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
}
|
|
|
|
|
2017-03-08 23:10:31 +11:00
|
|
|
void BLI_rctf_init_pt_radius(rctf *rect, const float xy[2], float size)
|
2017-03-05 20:51:23 +11:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
rect->xmin = xy[0] - size;
|
|
|
|
rect->xmax = xy[0] + size;
|
|
|
|
rect->ymin = xy[1] - size;
|
|
|
|
rect->ymax = xy[1] + size;
|
2017-03-05 20:51:23 +11:00
|
|
|
}
|
|
|
|
|
2017-03-08 23:10:31 +11:00
|
|
|
void BLI_rcti_init_pt_radius(rcti *rect, const int xy[2], int size)
|
2017-03-05 20:51:23 +11:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
rect->xmin = xy[0] - size;
|
|
|
|
rect->xmax = xy[0] + size;
|
|
|
|
rect->ymin = xy[1] - size;
|
|
|
|
rect->ymax = xy[1] + size;
|
2017-03-05 20:51:23 +11:00
|
|
|
}
|
|
|
|
|
2012-08-07 18:41:47 +00:00
|
|
|
void BLI_rcti_init_minmax(rcti *rect)
|
2012-07-12 08:31:23 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
rect->xmin = rect->ymin = INT_MAX;
|
|
|
|
rect->xmax = rect->ymax = INT_MIN;
|
2012-07-12 08:31:23 +00:00
|
|
|
}
|
|
|
|
|
2012-08-07 18:41:47 +00:00
|
|
|
void BLI_rctf_init_minmax(rctf *rect)
|
2012-07-12 08:31:23 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
rect->xmin = rect->ymin = FLT_MAX;
|
|
|
|
rect->xmax = rect->ymax = -FLT_MAX;
|
2012-07-12 08:31:23 +00:00
|
|
|
}
|
|
|
|
|
2012-08-07 18:41:47 +00:00
|
|
|
void BLI_rcti_do_minmax_v(rcti *rect, const int xy[2])
|
2012-07-12 09:24:17 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (xy[0] < rect->xmin) {
|
|
|
|
rect->xmin = xy[0];
|
|
|
|
}
|
|
|
|
if (xy[0] > rect->xmax) {
|
|
|
|
rect->xmax = xy[0];
|
|
|
|
}
|
|
|
|
if (xy[1] < rect->ymin) {
|
|
|
|
rect->ymin = xy[1];
|
|
|
|
}
|
|
|
|
if (xy[1] > rect->ymax) {
|
|
|
|
rect->ymax = xy[1];
|
|
|
|
}
|
2012-07-12 09:24:17 +00:00
|
|
|
}
|
|
|
|
|
2012-08-07 18:41:47 +00:00
|
|
|
void BLI_rctf_do_minmax_v(rctf *rect, const float xy[2])
|
2012-07-12 09:24:17 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (xy[0] < rect->xmin) {
|
|
|
|
rect->xmin = xy[0];
|
|
|
|
}
|
|
|
|
if (xy[0] > rect->xmax) {
|
|
|
|
rect->xmax = xy[0];
|
|
|
|
}
|
|
|
|
if (xy[1] < rect->ymin) {
|
|
|
|
rect->ymin = xy[1];
|
|
|
|
}
|
|
|
|
if (xy[1] > rect->ymax) {
|
|
|
|
rect->ymax = xy[1];
|
|
|
|
}
|
2012-07-12 09:24:17 +00:00
|
|
|
}
|
|
|
|
|
2014-03-09 15:48:09 +11:00
|
|
|
/* given 2 rectangles - transform a point from one to another */
|
2019-04-17 06:17:24 +02:00
|
|
|
void BLI_rctf_transform_pt_v(const rctf *dst,
|
|
|
|
const rctf *src,
|
|
|
|
float xy_dst[2],
|
|
|
|
const float xy_src[2])
|
2014-03-09 15:48:09 +11:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
xy_dst[0] = ((xy_src[0] - src->xmin) / (src->xmax - src->xmin));
|
|
|
|
xy_dst[0] = dst->xmin + ((dst->xmax - dst->xmin) * xy_dst[0]);
|
2014-03-09 15:48:09 +11:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
xy_dst[1] = ((xy_src[1] - src->ymin) / (src->ymax - src->ymin));
|
|
|
|
xy_dst[1] = dst->ymin + ((dst->ymax - dst->ymin) * xy_dst[1]);
|
2014-03-09 15:48:09 +11:00
|
|
|
}
|
|
|
|
|
2017-08-27 16:01:06 +10:00
|
|
|
/**
|
|
|
|
* Calculate a 4x4 matrix representing the transformation between two rectangles.
|
|
|
|
*
|
2019-04-22 00:54:27 +10:00
|
|
|
* \note Multiplying a vector by this matrix does *not*
|
|
|
|
* give the same value as #BLI_rctf_transform_pt_v.
|
2017-08-27 16:01:06 +10:00
|
|
|
*/
|
|
|
|
void BLI_rctf_transform_calc_m4_pivot_min_ex(
|
2019-04-17 06:17:24 +02:00
|
|
|
const rctf *dst, const rctf *src, float matrix[4][4], uint x, uint y)
|
2017-08-27 16:01:06 +10:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_assert(x < 3 && y < 3);
|
2017-08-27 16:01:06 +10:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
unit_m4(matrix);
|
2017-08-27 16:01:06 +10:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
matrix[x][x] = BLI_rctf_size_x(src) / BLI_rctf_size_x(dst);
|
|
|
|
matrix[y][y] = BLI_rctf_size_y(src) / BLI_rctf_size_y(dst);
|
|
|
|
matrix[3][x] = (src->xmin - dst->xmin) * matrix[x][x];
|
|
|
|
matrix[3][y] = (src->ymin - dst->ymin) * matrix[y][y];
|
2017-08-27 16:01:06 +10:00
|
|
|
}
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
void BLI_rctf_transform_calc_m4_pivot_min(const rctf *dst, const rctf *src, float matrix[4][4])
|
2017-08-27 16:01:06 +10:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_rctf_transform_calc_m4_pivot_min_ex(dst, src, matrix, 0, 1);
|
2017-08-27 16:01:06 +10:00
|
|
|
}
|
|
|
|
|
2012-07-15 00:29:56 +00:00
|
|
|
void BLI_rcti_translate(rcti *rect, int x, int y)
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
rect->xmin += x;
|
|
|
|
rect->ymin += y;
|
|
|
|
rect->xmax += x;
|
|
|
|
rect->ymax += y;
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
}
|
2012-07-15 00:29:56 +00:00
|
|
|
void BLI_rctf_translate(rctf *rect, float x, float y)
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
rect->xmin += x;
|
|
|
|
rect->ymin += y;
|
|
|
|
rect->xmax += x;
|
|
|
|
rect->ymax += y;
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2013-03-19 10:54:52 +00:00
|
|
|
void BLI_rcti_recenter(rcti *rect, int x, int y)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
const int dx = x - BLI_rcti_cent_x(rect);
|
|
|
|
const int dy = y - BLI_rcti_cent_y(rect);
|
|
|
|
BLI_rcti_translate(rect, dx, dy);
|
2013-03-19 10:54:52 +00:00
|
|
|
}
|
|
|
|
void BLI_rctf_recenter(rctf *rect, float x, float y)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
const float dx = x - BLI_rctf_cent_x(rect);
|
|
|
|
const float dy = y - BLI_rctf_cent_y(rect);
|
|
|
|
BLI_rctf_translate(rect, dx, dy);
|
2013-03-19 10:54:52 +00:00
|
|
|
}
|
|
|
|
|
2010-06-17 14:22:54 +00:00
|
|
|
/* change width & height around the central location */
|
2012-07-15 00:29:56 +00:00
|
|
|
void BLI_rcti_resize(rcti *rect, int x, int y)
|
2010-06-17 14:22:54 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
rect->xmin = BLI_rcti_cent_x(rect) - (x / 2);
|
|
|
|
rect->ymin = BLI_rcti_cent_y(rect) - (y / 2);
|
|
|
|
rect->xmax = rect->xmin + x;
|
|
|
|
rect->ymax = rect->ymin + y;
|
2010-06-17 14:22:54 +00:00
|
|
|
}
|
|
|
|
|
2012-07-15 00:29:56 +00:00
|
|
|
void BLI_rctf_resize(rctf *rect, float x, float y)
|
2010-06-17 14:22:54 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
rect->xmin = BLI_rctf_cent_x(rect) - (x * 0.5f);
|
|
|
|
rect->ymin = BLI_rctf_cent_y(rect) - (y * 0.5f);
|
|
|
|
rect->xmax = rect->xmin + x;
|
|
|
|
rect->ymax = rect->ymin + y;
|
2010-06-17 14:22:54 +00:00
|
|
|
}
|
|
|
|
|
2013-01-11 04:34:15 +00:00
|
|
|
void BLI_rcti_scale(rcti *rect, const float scale)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
const int cent_x = BLI_rcti_cent_x(rect);
|
|
|
|
const int cent_y = BLI_rcti_cent_y(rect);
|
|
|
|
const int size_x_half = BLI_rcti_size_x(rect) * (scale * 0.5f);
|
|
|
|
const int size_y_half = BLI_rcti_size_y(rect) * (scale * 0.5f);
|
|
|
|
rect->xmin = cent_x - size_x_half;
|
|
|
|
rect->ymin = cent_y - size_y_half;
|
|
|
|
rect->xmax = cent_x + size_x_half;
|
|
|
|
rect->ymax = cent_y + size_y_half;
|
2013-01-11 04:34:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BLI_rctf_scale(rctf *rect, const float scale)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
const float cent_x = BLI_rctf_cent_x(rect);
|
|
|
|
const float cent_y = BLI_rctf_cent_y(rect);
|
|
|
|
const float size_x_half = BLI_rctf_size_x(rect) * (scale * 0.5f);
|
|
|
|
const float size_y_half = BLI_rctf_size_y(rect) * (scale * 0.5f);
|
|
|
|
rect->xmin = cent_x - size_x_half;
|
|
|
|
rect->ymin = cent_y - size_y_half;
|
|
|
|
rect->xmax = cent_x + size_x_half;
|
|
|
|
rect->ymax = cent_y + size_y_half;
|
2013-01-11 04:34:15 +00:00
|
|
|
}
|
|
|
|
|
2019-05-21 22:27:09 +10:00
|
|
|
void BLI_rctf_pad_y(rctf *rect,
|
|
|
|
const float boundary_size,
|
|
|
|
const float pad_min,
|
|
|
|
const float pad_max)
|
2019-05-21 11:59:10 +02:00
|
|
|
{
|
2019-05-21 22:27:09 +10:00
|
|
|
BLI_assert(pad_max >= 0.0f);
|
|
|
|
BLI_assert(pad_min >= 0.0f);
|
|
|
|
BLI_assert(boundary_size > 0.0f);
|
2019-05-21 11:59:10 +02:00
|
|
|
|
2019-05-21 22:27:09 +10:00
|
|
|
float total_pad = pad_max + pad_min;
|
|
|
|
if (total_pad == 0.0f) {
|
2019-05-21 11:59:10 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-05-21 22:27:09 +10:00
|
|
|
float total_extend = BLI_rctf_size_y(rect) * total_pad / (boundary_size - total_pad);
|
|
|
|
rect->ymax += total_extend * (pad_max / total_pad);
|
|
|
|
rect->ymin -= total_extend * (pad_min / total_pad);
|
2019-05-21 11:59:10 +02:00
|
|
|
}
|
|
|
|
|
2012-08-12 01:07:31 +00:00
|
|
|
void BLI_rctf_interp(rctf *rect, const rctf *rect_a, const rctf *rect_b, const float fac)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
const float ifac = 1.0f - fac;
|
|
|
|
rect->xmin = (rect_a->xmin * ifac) + (rect_b->xmin * fac);
|
|
|
|
rect->xmax = (rect_a->xmax * ifac) + (rect_b->xmax * fac);
|
|
|
|
rect->ymin = (rect_a->ymin * ifac) + (rect_b->ymin * fac);
|
|
|
|
rect->ymax = (rect_a->ymax * ifac) + (rect_b->ymax * fac);
|
2012-08-12 01:07:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* BLI_rcti_interp() not needed yet */
|
|
|
|
|
2015-10-17 00:02:07 +11:00
|
|
|
bool BLI_rctf_clamp_pt_v(const rctf *rect, float xy[2])
|
2012-09-22 12:23:17 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bool changed = false;
|
|
|
|
if (xy[0] < rect->xmin) {
|
|
|
|
xy[0] = rect->xmin;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
if (xy[0] > rect->xmax) {
|
|
|
|
xy[0] = rect->xmax;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
if (xy[1] < rect->ymin) {
|
|
|
|
xy[1] = rect->ymin;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
if (xy[1] > rect->ymax) {
|
|
|
|
xy[1] = rect->ymax;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
return changed;
|
2012-09-22 12:23:17 +00:00
|
|
|
}
|
|
|
|
|
2015-10-17 00:02:07 +11:00
|
|
|
bool BLI_rcti_clamp_pt_v(const rcti *rect, int xy[2])
|
2012-09-22 12:23:17 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bool changed = false;
|
|
|
|
if (xy[0] < rect->xmin) {
|
|
|
|
xy[0] = rect->xmin;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
if (xy[0] > rect->xmax) {
|
|
|
|
xy[0] = rect->xmax;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
if (xy[1] < rect->ymin) {
|
|
|
|
xy[1] = rect->ymin;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
if (xy[1] > rect->ymax) {
|
|
|
|
xy[1] = rect->ymax;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
return changed;
|
2012-09-22 12:23:17 +00:00
|
|
|
}
|
|
|
|
|
2015-10-17 00:03:29 +11:00
|
|
|
/**
|
|
|
|
* Clamp \a rect within \a rect_bounds, setting \a r_xy to the offset.
|
|
|
|
*
|
2019-04-21 01:22:07 +02:00
|
|
|
* Keeps the top left corner within the bounds, which for user interface
|
|
|
|
* elements is typically where the most important information is.
|
|
|
|
*
|
2015-10-17 00:03:29 +11:00
|
|
|
* \return true if a change is made.
|
|
|
|
*/
|
|
|
|
bool BLI_rctf_clamp(rctf *rect, const rctf *rect_bounds, float r_xy[2])
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
r_xy[0] = 0.0f;
|
|
|
|
r_xy[1] = 0.0f;
|
|
|
|
|
2019-04-21 01:22:07 +02:00
|
|
|
if (rect->xmax > rect_bounds->xmax) {
|
|
|
|
float ofs = rect_bounds->xmax - rect->xmax;
|
2019-04-17 06:17:24 +02:00
|
|
|
rect->xmin += ofs;
|
|
|
|
rect->xmax += ofs;
|
|
|
|
r_xy[0] += ofs;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
|
2019-04-21 01:22:07 +02:00
|
|
|
if (rect->xmin < rect_bounds->xmin) {
|
|
|
|
float ofs = rect_bounds->xmin - rect->xmin;
|
2019-04-17 06:17:24 +02:00
|
|
|
rect->xmin += ofs;
|
|
|
|
rect->xmax += ofs;
|
|
|
|
r_xy[0] += ofs;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rect->ymin < rect_bounds->ymin) {
|
|
|
|
float ofs = rect_bounds->ymin - rect->ymin;
|
|
|
|
rect->ymin += ofs;
|
|
|
|
rect->ymax += ofs;
|
|
|
|
r_xy[1] += ofs;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rect->ymax > rect_bounds->ymax) {
|
|
|
|
float ofs = rect_bounds->ymax - rect->ymax;
|
|
|
|
rect->ymin += ofs;
|
|
|
|
rect->ymax += ofs;
|
|
|
|
r_xy[1] += ofs;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return changed;
|
2015-10-17 00:03:29 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BLI_rcti_clamp(rcti *rect, const rcti *rect_bounds, int r_xy[2])
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
r_xy[0] = 0;
|
|
|
|
r_xy[1] = 0;
|
|
|
|
|
2019-04-21 01:22:07 +02:00
|
|
|
if (rect->xmax > rect_bounds->xmax) {
|
|
|
|
int ofs = rect_bounds->xmax - rect->xmax;
|
2019-04-17 06:17:24 +02:00
|
|
|
rect->xmin += ofs;
|
|
|
|
rect->xmax += ofs;
|
|
|
|
r_xy[0] += ofs;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
|
2019-04-21 01:22:07 +02:00
|
|
|
if (rect->xmin < rect_bounds->xmin) {
|
|
|
|
int ofs = rect_bounds->xmin - rect->xmin;
|
2019-04-17 06:17:24 +02:00
|
|
|
rect->xmin += ofs;
|
|
|
|
rect->xmax += ofs;
|
|
|
|
r_xy[0] += ofs;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rect->ymin < rect_bounds->ymin) {
|
|
|
|
int ofs = rect_bounds->ymin - rect->ymin;
|
|
|
|
rect->ymin += ofs;
|
|
|
|
rect->ymax += ofs;
|
|
|
|
r_xy[1] += ofs;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rect->ymax > rect_bounds->ymax) {
|
|
|
|
int ofs = rect_bounds->ymax - rect->ymax;
|
|
|
|
rect->ymin += ofs;
|
|
|
|
rect->ymax += ofs;
|
|
|
|
r_xy[1] += ofs;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return changed;
|
2015-10-17 00:03:29 +11:00
|
|
|
}
|
|
|
|
|
2015-10-17 00:02:07 +11:00
|
|
|
bool BLI_rctf_compare(const rctf *rect_a, const rctf *rect_b, const float limit)
|
2012-08-12 01:07:31 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (fabsf(rect_a->xmin - rect_b->xmin) < limit) {
|
|
|
|
if (fabsf(rect_a->xmax - rect_b->xmax) < limit) {
|
|
|
|
if (fabsf(rect_a->ymin - rect_b->ymin) < limit) {
|
|
|
|
if (fabsf(rect_a->ymax - rect_b->ymax) < limit) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-08-12 01:07:31 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2012-08-12 01:07:31 +00:00
|
|
|
}
|
|
|
|
|
2015-10-17 00:02:07 +11:00
|
|
|
bool BLI_rcti_compare(const rcti *rect_a, const rcti *rect_b)
|
2012-08-12 01:07:31 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (rect_a->xmin == rect_b->xmin) {
|
|
|
|
if (rect_a->xmax == rect_b->xmax) {
|
|
|
|
if (rect_a->ymin == rect_b->ymin) {
|
|
|
|
if (rect_a->ymax == rect_b->ymax) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-08-12 01:07:31 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2012-08-12 01:07:31 +00:00
|
|
|
}
|
|
|
|
|
2013-03-09 05:35:49 +00:00
|
|
|
bool BLI_rctf_isect(const rctf *src1, const rctf *src2, rctf *dest)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
float xmin, xmax;
|
|
|
|
float ymin, ymax;
|
|
|
|
|
|
|
|
xmin = (src1->xmin) > (src2->xmin) ? (src1->xmin) : (src2->xmin);
|
|
|
|
xmax = (src1->xmax) < (src2->xmax) ? (src1->xmax) : (src2->xmax);
|
|
|
|
ymin = (src1->ymin) > (src2->ymin) ? (src1->ymin) : (src2->ymin);
|
|
|
|
ymax = (src1->ymax) < (src2->ymax) ? (src1->ymax) : (src2->ymax);
|
|
|
|
|
|
|
|
if (xmax >= xmin && ymax >= ymin) {
|
|
|
|
if (dest) {
|
|
|
|
dest->xmin = xmin;
|
|
|
|
dest->xmax = xmax;
|
|
|
|
dest->ymin = ymin;
|
|
|
|
dest->ymax = ymax;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (dest) {
|
|
|
|
dest->xmin = 0;
|
|
|
|
dest->xmax = 0;
|
|
|
|
dest->ymin = 0;
|
|
|
|
dest->ymax = 0;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
|
2013-03-09 05:35:49 +00:00
|
|
|
bool BLI_rcti_isect(const rcti *src1, const rcti *src2, rcti *dest)
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
int xmin, xmax;
|
|
|
|
int ymin, ymax;
|
|
|
|
|
|
|
|
xmin = (src1->xmin) > (src2->xmin) ? (src1->xmin) : (src2->xmin);
|
|
|
|
xmax = (src1->xmax) < (src2->xmax) ? (src1->xmax) : (src2->xmax);
|
|
|
|
ymin = (src1->ymin) > (src2->ymin) ? (src1->ymin) : (src2->ymin);
|
|
|
|
ymax = (src1->ymax) < (src2->ymax) ? (src1->ymax) : (src2->ymax);
|
|
|
|
|
|
|
|
if (xmax >= xmin && ymax >= ymin) {
|
|
|
|
if (dest) {
|
|
|
|
dest->xmin = xmin;
|
|
|
|
dest->xmax = xmax;
|
|
|
|
dest->ymin = ymin;
|
|
|
|
dest->ymax = ymax;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (dest) {
|
|
|
|
dest->xmin = 0;
|
|
|
|
dest->xmax = 0;
|
|
|
|
dest->ymin = 0;
|
|
|
|
dest->ymax = 0;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
}
|
2010-08-25 08:31:52 +00:00
|
|
|
|
2012-08-18 20:54:43 +00:00
|
|
|
void BLI_rcti_rctf_copy(rcti *dst, const rctf *src)
|
2010-08-25 08:31:52 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
dst->xmin = floorf(src->xmin + 0.5f);
|
|
|
|
dst->xmax = dst->xmin + floorf(BLI_rctf_size_x(src) + 0.5f);
|
|
|
|
dst->ymin = floorf(src->ymin + 0.5f);
|
|
|
|
dst->ymax = dst->ymin + floorf(BLI_rctf_size_y(src) + 0.5f);
|
2012-08-18 20:54:43 +00:00
|
|
|
}
|
|
|
|
|
2015-08-18 14:16:58 +10:00
|
|
|
void BLI_rcti_rctf_copy_floor(rcti *dst, const rctf *src)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
dst->xmin = floorf(src->xmin);
|
|
|
|
dst->xmax = floorf(src->xmax);
|
|
|
|
dst->ymin = floorf(src->ymin);
|
|
|
|
dst->ymax = floorf(src->ymax);
|
2015-08-18 14:16:58 +10:00
|
|
|
}
|
|
|
|
|
2017-06-23 11:04:58 +03:00
|
|
|
void BLI_rcti_rctf_copy_round(rcti *dst, const rctf *src)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
dst->xmin = floorf(src->xmin + 0.5f);
|
|
|
|
dst->xmax = floorf(src->xmax + 0.5f);
|
|
|
|
dst->ymin = floorf(src->ymin + 0.5f);
|
|
|
|
dst->ymax = floorf(src->ymax + 0.5f);
|
2017-06-23 11:04:58 +03:00
|
|
|
}
|
|
|
|
|
2012-08-18 20:54:43 +00:00
|
|
|
void BLI_rctf_rcti_copy(rctf *dst, const rcti *src)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
dst->xmin = src->xmin;
|
|
|
|
dst->xmax = src->xmax;
|
|
|
|
dst->ymin = src->ymin;
|
|
|
|
dst->ymax = src->ymax;
|
2010-08-25 08:31:52 +00:00
|
|
|
}
|
|
|
|
|
2012-07-11 18:17:48 +00:00
|
|
|
void print_rctf(const char *str, const rctf *rect)
|
2010-08-25 08:31:52 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
printf("%s: xmin %.8f, xmax %.8f, ymin %.8f, ymax %.8f (%.12fx%.12f)\n",
|
|
|
|
str,
|
|
|
|
rect->xmin,
|
|
|
|
rect->xmax,
|
|
|
|
rect->ymin,
|
|
|
|
rect->ymax,
|
|
|
|
BLI_rctf_size_x(rect),
|
|
|
|
BLI_rctf_size_y(rect));
|
2010-08-25 08:31:52 +00:00
|
|
|
}
|
|
|
|
|
2012-07-11 18:17:48 +00:00
|
|
|
void print_rcti(const char *str, const rcti *rect)
|
2010-08-25 08:31:52 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
printf("%s: xmin %d, xmax %d, ymin %d, ymax %d (%dx%d)\n",
|
|
|
|
str,
|
|
|
|
rect->xmin,
|
|
|
|
rect->xmax,
|
|
|
|
rect->ymin,
|
|
|
|
rect->ymax,
|
|
|
|
BLI_rcti_size_x(rect),
|
|
|
|
BLI_rcti_size_y(rect));
|
2010-08-25 08:31:52 +00:00
|
|
|
}
|
2015-03-25 19:46:07 +11:00
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/* Comprehensive math (float only) */
|
|
|
|
|
|
|
|
/** \name Rect math functions
|
|
|
|
* \{ */
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
#define ROTATE_SINCOS(r_vec, mat2, vec) \
|
|
|
|
{ \
|
|
|
|
(r_vec)[0] = (mat2)[1] * (vec)[0] + (+(mat2)[0]) * (vec)[1]; \
|
|
|
|
(r_vec)[1] = (mat2)[0] * (vec)[0] + (-(mat2)[1]) * (vec)[1]; \
|
|
|
|
} \
|
|
|
|
((void)0)
|
2015-03-25 19:46:07 +11:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Expand the rectangle to fit a rotated \a src.
|
|
|
|
*/
|
|
|
|
void BLI_rctf_rotate_expand(rctf *dst, const rctf *src, const float angle)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
const float mat2[2] = {sinf(angle), cosf(angle)};
|
|
|
|
const float cent[2] = {BLI_rctf_cent_x(src), BLI_rctf_cent_y(src)};
|
|
|
|
float corner[2], corner_rot[2], corder_max[2];
|
2015-03-25 19:46:07 +11:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* x is same for both corners */
|
|
|
|
corner[0] = src->xmax - cent[0];
|
|
|
|
corner[1] = src->ymax - cent[1];
|
|
|
|
ROTATE_SINCOS(corner_rot, mat2, corner);
|
|
|
|
corder_max[0] = fabsf(corner_rot[0]);
|
|
|
|
corder_max[1] = fabsf(corner_rot[1]);
|
2015-03-25 19:46:07 +11:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
corner[1] *= -1;
|
|
|
|
ROTATE_SINCOS(corner_rot, mat2, corner);
|
|
|
|
corder_max[0] = MAX2(corder_max[0], fabsf(corner_rot[0]));
|
|
|
|
corder_max[1] = MAX2(corder_max[1], fabsf(corner_rot[1]));
|
2015-03-25 19:46:07 +11:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
dst->xmin = cent[0] - corder_max[0];
|
|
|
|
dst->xmax = cent[0] + corder_max[0];
|
|
|
|
dst->ymin = cent[1] - corder_max[1];
|
|
|
|
dst->ymax = cent[1] + corder_max[1];
|
2015-03-25 19:46:07 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef ROTATE_SINCOS
|
|
|
|
|
|
|
|
/** \} */
|
2017-08-27 16:01:06 +10:00
|
|
|
|
|
|
|
static void unit_m4(float m[4][4])
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
m[0][0] = m[1][1] = m[2][2] = m[3][3] = 1.0f;
|
|
|
|
m[0][1] = m[0][2] = m[0][3] = 0.0f;
|
|
|
|
m[1][0] = m[1][2] = m[1][3] = 0.0f;
|
|
|
|
m[2][0] = m[2][1] = m[2][3] = 0.0f;
|
|
|
|
m[3][0] = m[3][1] = m[3][2] = 0.0f;
|
2017-08-27 16:01:06 +10:00
|
|
|
}
|