Mergin trunk into soc-2011-tomato up to rev 50188

All reverted commits should be merged again.

--
svn merge -r50173:50188 ^/trunk/blender
This commit is contained in:
Sergey Sharybin
2012-08-24 14:11:04 +00:00
8 changed files with 222 additions and 39 deletions

View File

@@ -182,7 +182,8 @@ static int find_nearest_diff_point(const bContext *C, Mask *mask, const float no
static void setup_vertex_point(const bContext *C, Mask *mask, MaskSpline *spline, MaskSplinePoint *new_point,
const float point_co[2], const float tangent[2], const float u,
MaskSplinePoint *reference_point, const short reference_adjacent)
MaskSplinePoint *reference_point, const short reference_adjacent,
const float view_zoom)
{
ScrArea *sa = CTX_wm_area(C);
@@ -225,8 +226,8 @@ static void setup_vertex_point(const bContext *C, Mask *mask, MaskSpline *spline
/* initial offset for handles */
if (spline->tot_point == 1) {
/* first point of splien is aligned horizontally */
bezt->vec[0][0] -= len / width;
bezt->vec[2][0] += len / width;
bezt->vec[0][0] -= len / maxi(width, height) * view_zoom;
bezt->vec[2][0] += len / maxi(width, height) * view_zoom;
}
else if (tangent) {
float vec[2];
@@ -391,7 +392,7 @@ static int add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2]
new_point = &spline->points[point_index + 1];
setup_vertex_point(C, mask, spline, new_point, co, tangent, u, NULL, TRUE);
setup_vertex_point(C, mask, spline, new_point, co, tangent, u, NULL, TRUE, 1.0f);
/* TODO - we could pass the spline! */
BKE_mask_layer_shape_changed_add(masklay, BKE_mask_layer_shape_spline_to_index(masklay, spline) + point_index + 1, TRUE, TRUE);
@@ -490,7 +491,7 @@ static int add_vertex_extrude(const bContext *C, Mask *mask, MaskLayer *masklay,
masklay->act_point = new_point;
setup_vertex_point(C, mask, spline, new_point, co, NULL, 0.5f, ref_point, FALSE);
setup_vertex_point(C, mask, spline, new_point, co, NULL, 0.5f, ref_point, FALSE, 1.0f);
if (masklay->splines_shapes.first) {
point_index = (((int)(new_point - spline->points) + 0) % spline->tot_point);
@@ -512,6 +513,7 @@ static int add_vertex_new(const bContext *C, Mask *mask, MaskLayer *masklay, con
MaskSpline *spline;
MaskSplinePoint *point;
MaskSplinePoint *new_point = NULL, *ref_point = NULL;
float view_zoom;
if (!masklay) {
/* if there's no masklay currently operationg on, create new one */
@@ -536,7 +538,26 @@ static int add_vertex_new(const bContext *C, Mask *mask, MaskLayer *masklay, con
masklay->act_point = new_point;
setup_vertex_point(C, mask, spline, new_point, co, NULL, 0.5f, ref_point, FALSE);
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
/* calc view zoom in a simplistic way */
float co_a[2];
float co_b[2];
int mval_a[2] = {0, 0};
int mval_b[2] = {1, 1};
ED_mask_mouse_pos(sa, ar, mval_a, co_a);
ED_mask_mouse_pos(sa, ar, mval_b, co_b);
view_zoom = ((co_b[0] - co_a[0]) + (co_b[1] - co_a[1])) / 2.0f;
/* scale up - arbitrarty but works well in the view */
view_zoom *= 200.0f;
}
setup_vertex_point(C, mask, spline, new_point, co, NULL, 0.5f, ref_point, FALSE, view_zoom);
{
int point_index = (((int)(new_point - spline->points) + 0) % spline->tot_point);

View File

@@ -1135,7 +1135,11 @@ static PFace *p_face_add_fill(PChart *chart, PVert *v1, PVert *v2, PVert *v3)
static PBool p_quad_split_direction(PHandle *handle, float **co, PHashKey *vkeys)
{
float fac = len_v3v3(co[0], co[2]) - len_v3v3(co[1], co[3]);
/* slight bias to prefer one edge over the other in case they are equal, so
* that in symmetric models we choose the same split direction instead of
* depending on floating point errors to decide */
float bias = 1.0f + 1e-6f;
float fac = len_v3v3(co[0], co[2])*bias - len_v3v3(co[1], co[3]);
PBool dir = (fac <= 0.0f);
/* the face exists check is there because of a special case: when

View File

@@ -31,6 +31,7 @@ set(INC
../../../blenlib
../../../makesdna
../../../../../intern/guardedalloc
../../../../../intern/utfconv
)
set(INC_SYS

View File

@@ -10,7 +10,9 @@ incs = ['.',
'../../../blenlib',
'intern/include',
'#/intern/guardedalloc',
'../../../makesdna']
'../../../makesdna',
'#/intern/utfconv']
incs += Split(env['BF_OPENEXR_INC'])
defs = ['WITH_OPENEXR']

View File

@@ -32,12 +32,17 @@
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <fstream>
#include <string>
#include <set>
#include <errno.h>
#include <openexr_api.h>
#if defined (WIN32) && !defined(FREE_WINDOWS)
#include "utfconv.h"
#endif
extern "C"
{
@@ -66,6 +71,7 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void)
#if defined(_WIN32) && !defined(FREE_WINDOWS)
#include <half.h>
#include <Iex/Iex.h>
#include <IlmImf/ImfVersion.h>
#include <IlmImf/ImfArray.h>
#include <IlmImf/ImfIO.h>
@@ -79,6 +85,7 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void)
#include <Imath/ImathBox.h>
#else
#include <half.h>
#include <Iex.h>
#include <ImfVersion.h>
#include <ImathBox.h>
#include <ImfArray.h>
@@ -95,6 +102,8 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void)
using namespace Imf;
using namespace Imath;
/* Memory Input Stream */
class Mem_IStream : public Imf::IStream
{
public:
@@ -142,6 +151,122 @@ void Mem_IStream::clear()
{
}
/* File Input Stream */
class IFileStream : public IStream
{
public:
IFileStream(const char *filename)
: IStream(filename)
{
/* utf-8 file path support on windows */
#if defined (WIN32) && !defined(FREE_WINDOWS)
wchar_t *wfilename = alloc_utf16_from_8(filename, 0);
ifs.open(wfilename, std::ios_base::binary);
free(wfilename);
#else
ifs.open(filename, std::ios_base::binary);
#endif
if (!ifs)
Iex::throwErrnoExc();
}
virtual bool read(char c[], int n)
{
if (!ifs)
throw Iex::InputExc("Unexpected end of file.");
errno = 0;
ifs.read(c, n);
return check_error();
}
virtual Int64 tellg()
{
return std::streamoff(ifs.tellg());
}
virtual void seekg(Int64 pos)
{
ifs.seekg(pos);
check_error();
}
virtual void clear()
{
ifs.clear();
}
private:
bool check_error()
{
if (!ifs) {
if (errno)
Iex::throwErrnoExc();
return false;
}
return true;
}
std::ifstream ifs;
};
/* File Output Stream */
class OFileStream : public OStream
{
public:
OFileStream(const char *filename)
: OStream(filename)
{
/* utf-8 file path support on windows */
#if defined (WIN32) && !defined(FREE_WINDOWS)
wchar_t *wfilename = alloc_utf16_from_8(filename, 0);
ofs.open(wfilename, std::ios_base::binary);
free(wfilename);
#else
ofs.open(filename, std::ios_base::binary);
#endif
if (!ofs)
Iex::throwErrnoExc();
}
virtual void write(const char c[], int n)
{
errno = 0;
ofs.write(c, n);
check_error();
}
virtual Int64 tellp()
{
return std::streamoff(ofs.tellp());
}
virtual void seekp(Int64 pos)
{
ofs.seekp(pos);
check_error();
}
private:
void check_error()
{
if (!ofs) {
if (errno)
Iex::throwErrnoExc();
throw Iex::ErrnoExc("File output failed.");
}
}
std::ofstream ofs;
};
struct _RGBAZ {
half r;
half g;
@@ -216,7 +341,10 @@ static int imb_save_openexr_half(struct ImBuf *ibuf, const char *name, int flags
header.channels().insert("Z", Channel(Imf::FLOAT));
FrameBuffer frameBuffer;
OutputFile *file = new OutputFile(name, header);
/* manually create ofstream, so we can handle utf-8 filepaths on windows */
OFileStream file_stream(name);
OutputFile file(file_stream, header);
/* we store first everything in half array */
RGBAZ *pixels = new RGBAZ[height * width];
@@ -281,9 +409,9 @@ static int imb_save_openexr_half(struct ImBuf *ibuf, const char *name, int flags
// printf("OpenEXR-save: Writing OpenEXR file of height %d.\n", height);
file->setFrameBuffer(frameBuffer);
file->writePixels(height);
delete file;
file.setFrameBuffer(frameBuffer);
file.writePixels(height);
delete[] pixels;
}
catch (const std::exception &exc)
@@ -321,7 +449,11 @@ static int imb_save_openexr_float(struct ImBuf *ibuf, const char *name, int flag
header.channels().insert("Z", Channel(Imf::FLOAT));
FrameBuffer frameBuffer;
OutputFile *file = new OutputFile(name, header);
/* manually create ofstream, so we can handle utf-8 filepaths on windows */
OFileStream file_stream(name);
OutputFile file(file_stream, header);
int xstride = sizeof(float) * channels;
int ystride = -xstride * width;
float *rect[4] = {NULL, NULL, NULL, NULL};
@@ -340,9 +472,8 @@ static int imb_save_openexr_float(struct ImBuf *ibuf, const char *name, int flag
if (is_zbuf)
frameBuffer.insert("Z", Slice(Imf::FLOAT, (char *) (ibuf->zbuf_float + (height - 1) * width),
sizeof(float), sizeof(float) * -width));
file->setFrameBuffer(frameBuffer);
file->writePixels(height);
delete file;
file.setFrameBuffer(frameBuffer);
file.writePixels(height);
}
catch (const std::exception &exc)
{
@@ -391,9 +522,13 @@ static ListBase exrhandles = {NULL, NULL};
typedef struct ExrHandle {
struct ExrHandle *next, *prev;
IFileStream *ifile_stream;
InputFile *ifile;
OFileStream *ofile_stream;
TiledOutputFile *tofile;
OutputFile *ofile;
int tilex, tiley;
int width, height;
int mipmap;
@@ -486,12 +621,19 @@ int IMB_exr_begin_write(void *handle, const char *filename, int width, int heigh
header.insert("BlenderMultiChannel", StringAttribute("Blender V2.55.1 and newer"));
/* avoid crash/abort when we don't have permission to write here */
/* manually create ofstream, so we can handle utf-8 filepaths on windows */
try {
data->ofile = new OutputFile(filename, header);
data->ofile_stream = new OFileStream(filename);
data->ofile = new OutputFile(*(data->ofile_stream), header);
}
catch (const std::exception &exc) {
std::cerr << "IMB_exr_begin_write: ERROR: " << exc.what() << std::endl;
delete data->ofile;
delete data->ofile_stream;
data->ofile = NULL;
data->ofile_stream = NULL;
}
return (data->ofile != NULL);
@@ -518,7 +660,19 @@ void IMB_exrtile_begin_write(void *handle, const char *filename, int mipmap, int
header.insert("BlenderMultiChannel", StringAttribute("Blender V2.43"));
data->tofile = new TiledOutputFile(filename, header);
/* avoid crash/abort when we don't have permission to write here */
/* manually create ofstream, so we can handle utf-8 filepaths on windows */
try {
data->ofile_stream = new OFileStream(filename);
data->tofile = new TiledOutputFile(*(data->ofile_stream), header);
}
catch (const std::exception &exc) {
delete data->tofile;
delete data->ofile_stream;
data->tofile = NULL;
data->ofile_stream = NULL;
}
}
/* read from file */
@@ -527,7 +681,19 @@ int IMB_exr_begin_read(void *handle, const char *filename, int *width, int *heig
ExrHandle *data = (ExrHandle *)handle;
if (BLI_exists(filename) && BLI_file_size(filename) > 32) { /* 32 is arbitrary, but zero length files crashes exr */
data->ifile = new InputFile(filename);
/* avoid crash/abort when we don't have permission to write here */
try {
data->ifile_stream = new IFileStream(filename);
data->ifile = new InputFile(*(data->ifile_stream));
}
catch (const std::exception &exc) {
delete data->ifile;
delete data->ifile_stream;
data->ifile = NULL;
data->ifile_stream = NULL;
}
if (data->ifile) {
Box2i dw = data->ifile->header().dataWindow();
data->width = *width = dw.max.x - dw.min.x + 1;
@@ -696,16 +862,17 @@ void IMB_exr_close(void *handle)
ExrLayer *lay;
ExrPass *pass;
if (data->ifile)
delete data->ifile;
else if (data->ofile)
delete data->ofile;
else if (data->tofile)
delete data->tofile;
delete data->ifile;
delete data->ifile_stream;
delete data->ofile;
delete data->tofile;
delete data->ofile_stream;
data->ifile = NULL;
data->ifile_stream = NULL;
data->ofile = NULL;
data->tofile = NULL;
data->ofile_stream = NULL;
BLI_freelistN(&data->channels);

View File

@@ -4159,7 +4159,7 @@ static void rna_def_node_socket(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", SOCK_HIDDEN);
RNA_def_property_boolean_funcs(prop, NULL, "rna_NodeSocket_hide_set");
RNA_def_property_ui_text(prop, "Hide", "Hide the socket");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, NULL);
RNA_def_property_update(prop, NC_NODE | ND_DISPLAY, NULL);
prop = RNA_def_property(srna, "is_linked", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SOCK_IN_USE);

View File

@@ -699,12 +699,6 @@ void playanim_window_open(const char *title, int posx, int posy, int sizex, int
inital_state = start_maximized ? GHOST_kWindowStateFullScreen : GHOST_kWindowStateNormal;
else
inital_state = start_maximized ? GHOST_kWindowStateMaximized : GHOST_kWindowStateNormal;
#if defined(__APPLE__) && !defined(GHOST_COCOA)
{
extern int macPrefState; /* creator.c */
initial_state += macPrefState;
}
#endif
g_WS.ghost_window = GHOST_CreateWindow(g_WS.ghost_system,
title,

View File

@@ -341,12 +341,6 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win)
wm_get_screensize(&scr_w, &scr_h);
posy = (scr_h - win->posy - win->sizey);
#if defined(__APPLE__) && !defined(GHOST_COCOA)
{
extern int macPrefState; /* creator.c */
initial_state += macPrefState;
}
#endif
/* Disable AA for now, as GL_SELECT (used for border, lasso, ... select)
* doesn't work well when AA is initialized, even if not used. */
ghostwin = GHOST_CreateWindow(g_system, title,