Merging r41140 through r41157 from trunk into soc-2011-tomato

This commit is contained in:
Sergey Sharybin
2011-10-20 20:24:04 +00:00
48 changed files with 357 additions and 253 deletions

View File

@@ -1654,8 +1654,17 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
//printf("\nW failure for event 0x%x",[event type]);
return GHOST_kFailure;
}
/* unicode input - not entirely supported yet
* but we are getting the right byte, Blender is not drawing it though
* also some languages may need special treatment:
- Japanese: romanji is used as input, and every 2 letters OSX converts the text
to Hiragana/Katakana.
- Korean: one add one letter at a time, and then the OSX join them in the equivalent
combined letter.
*/
char utf8_buf[6]= {'\0'};
char utf8_buf[6]= {'\0'}; /* TODO, unicode input */
switch ([event type]) {
case NSKeyDown:
@@ -1669,7 +1678,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
keyCode = convertKey([event keyCode],0,
[event type] == NSKeyDown?kUCKeyActionDown:kUCKeyActionUp);
/* ascii */
characters = [event characters];
if ([characters length]>0) { //Check for dead keys
//Convert characters to iso latin 1 encoding
@@ -1681,16 +1690,32 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
}
else
ascii= 0;
/* unicode */
if ([characters length]>0) {
convertedCharacters = [characters dataUsingEncoding:NSUTF8StringEncoding];
if ([convertedCharacters length]>0) {
utf8_buf[0] = ((char*)[convertedCharacters bytes])[0];
utf8_buf[1] = ((char*)[convertedCharacters bytes])[1];
utf8_buf[2] = ((char*)[convertedCharacters bytes])[2];
utf8_buf[3] = ((char*)[convertedCharacters bytes])[3];
utf8_buf[4] = ((char*)[convertedCharacters bytes])[4];
utf8_buf[5] = ((char*)[convertedCharacters bytes])[5];
}
else {
utf8_buf[0] = '\0';
}
}
if ((keyCode == GHOST_kKeyQ) && (m_modifierMask & NSCommandKeyMask))
break; //Cmd-Q is directly handled by Cocoa
if ([event type] == NSKeyDown) {
pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyDown, window, keyCode, ascii, utf8_buf) );
//printf("\nKey down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii);
//printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf);
} else {
pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyUp, window, keyCode, ascii, utf8_buf) );
//printf("\nKey up rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii);
//printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf);
}
break;

View File

@@ -665,7 +665,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
split = layout.split()
col = split.column()
col.label(text="Texture:")
col.prop(md, "texture", text="")
col.template_ID(md, "texture", new="texture.new")
col = split.column()
col.label(text="Texture Coordinates:")

View File

@@ -61,6 +61,10 @@ class PHYSICS_PT_field(PhysicButtonsPanel, Panel):
split = layout.split(percentage=0.2)
split.label(text="Shape:")
split.prop(field, "shape", text="")
elif field.type == 'TEXTURE':
split = layout.split(percentage=0.2)
split.label(text="Texture:")
split.row().template_ID(field, "texture", new="texture.new")
split = layout.split()
@@ -103,7 +107,6 @@ class PHYSICS_PT_field(PhysicButtonsPanel, Panel):
elif field.type == 'TEXTURE':
col = split.column()
col.prop(field, "strength")
col.prop(field, "texture", text="")
col.prop(field, "texture_mode", text="")
col.prop(field, "texture_nabla")

View File

@@ -53,7 +53,7 @@ extern "C" {
/* can be left blank, otherwise a,b,c... etc with no quotes */
#define BLENDER_VERSION_CHAR
/* alpha/beta/rc/release, docs use this */
#define BLENDER_VERSION_CYCLE release
#define BLENDER_VERSION_CYCLE alpha
struct ListBase;
struct MemFile;

View File

@@ -85,11 +85,6 @@ struct chartrans *BKE_text_to_curve(struct Main *bmain, struct Scene *scene, str
int BKE_font_getselection(struct Object *ob, int *start, int *end);
size_t chtoutf8(const unsigned long c, char o[4]);
void wcs2utf8s(char *dst, const wchar_t *src);
size_t wcsleninu8(wchar_t *src);
size_t utf8towchar(wchar_t *w, const char *c);
#ifdef __cplusplus
}
#endif

View File

@@ -44,6 +44,7 @@
#include "DNA_scene_types.h"
#include "BLI_edgehash.h"
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BKE_mesh.h"

View File

@@ -38,6 +38,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "bmesh_private.h"

View File

@@ -37,7 +37,7 @@
*/
#include "BLI_listbase.h"
#include "MEM_guardedalloc.h"
#include "BKE_bmesh.h"
#include "bmesh_private.h"

View File

@@ -40,6 +40,7 @@
#include <limits.h>
#include "MEM_guardedalloc.h"
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BKE_bmesh.h"
/**

View File

@@ -38,6 +38,7 @@
#include "BLI_winstuff.h"
#include "BLI_utildefines.h"
#include "BLI_listbase.h"
#include "BLI_ghash.h"
#include "DNA_anim_types.h"

View File

@@ -64,142 +64,6 @@
static ListBase ttfdata= {NULL, NULL};
/* UTF-8 <-> wchar transformations */
size_t chtoutf8(const unsigned long c, char o[4])
{
// Variables and initialization
/* memset(o, 0, 4); */
// Create the utf-8 string
if (c < 0x80) {
o[0] = (char) c;
return 1;
}
else if (c < 0x800) {
o[0] = (0xC0 | (c>>6));
o[1] = (0x80 | (c & 0x3f));
return 2;
}
else if (c < 0x10000) {
o[0] = (0xe0 | (c >> 12));
o[1] = (0x80 | (c >>6 & 0x3f));
o[2] = (0x80 | (c & 0x3f));
return 3;
}
else if (c < 0x200000) {
o[0] = (0xf0 | (c>>18));
o[1] = (0x80 | (c >>12 & 0x3f));
o[2] = (0x80 | (c >> 6 & 0x3f));
o[3] = (0x80 | (c & 0x3f));
return 4;
}
/* should we assert here? */
return 0;
}
void wcs2utf8s(char *dst, const wchar_t *src)
{
while(*src) {
dst += chtoutf8(*src++, dst);
}
*dst= '\0';
}
size_t wcsleninu8(wchar_t *src)
{
char ch_dummy[4];
size_t len = 0;
while(*src) {
len += chtoutf8(*src++, ch_dummy);
}
return len;
}
static size_t utf8slen(const char *strc)
{
int len=0;
while(*strc) {
if ((*strc & 0xe0) == 0xc0) {
if((strc[1] & 0x80) && (strc[1] & 0x40) == 0x00)
strc++;
} else if ((*strc & 0xf0) == 0xe0) {
if((strc[1] & strc[2] & 0x80) && ((strc[1] | strc[2]) & 0x40) == 0x00)
strc += 2;
} else if ((*strc & 0xf8) == 0xf0) {
if((strc[1] & strc[2] & strc[3] & 0x80) && ((strc[1] | strc[2] | strc[3]) & 0x40) == 0x00)
strc += 3;
}
strc++;
len++;
}
return len;
}
/* Converts Unicode to wchar
According to RFC 3629 "UTF-8, a transformation format of ISO 10646"
(http://tools.ietf.org/html/rfc3629), the valid UTF-8 encoding are:
Char. number range | UTF-8 octet sequence
(hexadecimal) | (binary)
--------------------+---------------------------------------------
0000 0000-0000 007F | 0xxxxxxx
0000 0080-0000 07FF | 110xxxxx 10xxxxxx
0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
If the encoding incidated by the first character is incorrect (because the
1 to 3 following characters do not match 10xxxxxx), the output is a '?' and
only a single input character is consumed.
*/
size_t utf8towchar(wchar_t *w, const char *c)
{
int len=0;
if(w==NULL || c==NULL) return(0);
while(*c) {
if ((*c & 0xe0) == 0xc0) {
if((c[1] & 0x80) && (c[1] & 0x40) == 0x00) {
*w=((c[0] &0x1f)<<6) | (c[1]&0x3f);
c++;
} else {
*w = '?';
}
} else if ((*c & 0xf0) == 0xe0) {
if((c[1] & c[2] & 0x80) && ((c[1] | c[2]) & 0x40) == 0x00) {
*w=((c[0] & 0x0f)<<12) | ((c[1]&0x3f)<<6) | (c[2]&0x3f);
c += 2;
} else {
*w = '?';
}
} else if ((*c & 0xf8) == 0xf0) {
if((c[1] & c[2] & c[3] & 0x80) && ((c[1] | c[2] | c[3]) & 0x40) == 0x00) {
*w=((c[0] & 0x07)<<18) | ((c[1]&0x1f)<<12) | ((c[2]&0x3f)<<6) | (c[3]&0x3f);
c += 3;
} else {
*w = '?';
}
} else
*w=(c[0] & 0x7f);
c++;
w++;
len++;
}
return len;
}
/* The vfont code */
void free_vfont(struct VFont *vf)
{
@@ -691,10 +555,10 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
if(vfont == NULL) return NULL;
// Create unicode string
utf8len = utf8slen(cu->str);
utf8len = BLI_strlen_utf8(cu->str);
mem = MEM_callocN(((utf8len + 1) * sizeof(wchar_t)), "convertedmem");
utf8towchar(mem, cu->str);
BLI_strncpy_wchar_from_utf8(mem, cu->str, utf8len + 1);
// Count the wchar_t string length
slen = wcslen(mem);

View File

@@ -52,6 +52,9 @@
#include "DNA_meshdata_types.h"
#include "BLI_utildefines.h"
#include "BLI_path_util.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BKE_bmesh.h"
#include "BKE_cloth.h"

View File

@@ -42,6 +42,9 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
#include "BLI_path_util.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_ghash.h"
#include "DNA_anim_types.h"

View File

@@ -70,7 +70,6 @@
#include "BLI_listbase.h"
#include "BLI_threads.h"
#include "BLI_storage.h" /* For _LARGEFILE64_SOURCE; zlib needs this on some systems */
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BKE_main.h"

View File

@@ -812,13 +812,12 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData
}
}
#ifdef WITH_SMOKE
// forward decleration
static void smoke_calc_transparency(float *result, float *input, float *p0, float *p1, int res[3], float dx, float *light, bresenham_callback cb, float correct);
static float calc_voxel_transp(float *result, float *input, int res[3], int *pixel, float *tRay, float correct);
#ifdef WITH_SMOKE
static int get_lamp(Scene *scene, float *light)
{
Base *base_tmp = NULL;

View File

@@ -68,6 +68,7 @@ variables on the UI for now
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLI_listbase.h"
#include "BLI_ghash.h"
#include "BLI_threads.h"

View File

@@ -74,6 +74,8 @@ extern "C" {
#include "BLI_string.h"
#include "BLI_string_utf8.h"
#include "BLI_path_util.h"
#include "BLI_storage.h"

View File

@@ -39,13 +39,6 @@
extern "C" {
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "BLI_mempool.h"
#include "BLI_blenlib.h"
typedef unsigned int (*GHashHashFP) (const void *key);
typedef int (*GHashCmpFP) (const void *a, const void *b);
typedef void (*GHashKeyFreeFP) (void *key);

View File

@@ -25,9 +25,7 @@
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
*
* $Id$
*/
*/
#ifndef BLI_STRING_H
#define BLI_STRING_H
@@ -142,16 +140,6 @@ void BLI_timestr(double _time, char *str); /* time var is global */
void BLI_ascii_strtolower(char *str, int len);
void BLI_ascii_strtoupper(char *str, int len);
/* string_utf8.c - may move these into their own header some day - campbell */
char *BLI_strncpy_utf8(char *dst, const char *src, size_t maxncpy);
int BLI_utf8_invalid_byte(const char *str, int length);
int BLI_utf8_invalid_strip(char *str, int length);
/* copied from glib */
char *BLI_str_find_prev_char_utf8(const char *str, const char *p);
char *BLI_str_find_next_char_utf8(const char *p, const char *end);
char *BLI_str_prev_char_utf8(const char *p);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,55 @@
/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* 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
* of the License, or (at your option) any later version.
*
* 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,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef BLI_STRING_UTF8_H
#define BLI_STRING_UTF8_H
/** \file BLI_string_utf8.h
* \ingroup bli
*/
#ifdef __cplusplus
extern "C" {
#endif
char *BLI_strncpy_utf8(char *dst, const char *src, size_t maxncpy);
int BLI_utf8_invalid_byte(const char *str, int length);
int BLI_utf8_invalid_strip(char *str, int length);
/* copied from glib */
char *BLI_str_find_prev_char_utf8(const char *str, const char *p);
char *BLI_str_find_next_char_utf8(const char *p, const char *end);
char *BLI_str_prev_char_utf8(const char *p);
/* wchar_t functions, copied from blenders own font.c originally */
size_t BLI_wstrlen_utf8(const wchar_t *src);
size_t BLI_strlen_utf8(const char *strc);
size_t BLI_strncpy_wchar_as_utf8(char *dst, const wchar_t *src, const size_t maxcpy);
size_t BLI_strncpy_wchar_from_utf8(wchar_t *dst, const char *src, const size_t maxcpy);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -128,6 +128,7 @@ set(SRC
BLI_storage.h
BLI_storage_types.h
BLI_string.h
BLI_string_utf8.h
BLI_threads.h
BLI_utildefines.h
BLI_uvproject.h

View File

@@ -35,12 +35,13 @@
#include <ctype.h> /* for tolower */
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BLI_args.h"
#include "BLI_ghash.h"

View File

@@ -32,11 +32,20 @@
* \ingroup bli
*/
#include <string.h>
#include <stdlib.h>
#include "MEM_guardedalloc.h"
// #include "BLI_blenlib.h"
#include "BLI_mempool.h"
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
#include "BLO_sys_types.h" // for intptr_t support
/***/

View File

@@ -31,6 +31,8 @@
*/
#include <string.h>
#include <wchar.h>
#include <wctype.h>
#include "BLI_string.h"
@@ -183,6 +185,159 @@ char *BLI_strncpy_utf8(char *dst, const char *src, size_t maxncpy)
return dst_r;
}
/* --------------------------------------------------------------------------*/
/* wchar_t / utf8 functions */
/* UTF-8 <-> wchar transformations */
static size_t chtoutf8(const unsigned long c, char o[4])
{
// Variables and initialization
/* memset(o, 0, 4); */
// Create the utf-8 string
if (c < 0x80) {
o[0] = (char) c;
return 1;
}
else if (c < 0x800) {
o[0] = (0xC0 | (c>>6));
o[1] = (0x80 | (c & 0x3f));
return 2;
}
else if (c < 0x10000) {
o[0] = (0xe0 | (c >> 12));
o[1] = (0x80 | (c >>6 & 0x3f));
o[2] = (0x80 | (c & 0x3f));
return 3;
}
else if (c < 0x200000) {
o[0] = (0xf0 | (c>>18));
o[1] = (0x80 | (c >>12 & 0x3f));
o[2] = (0x80 | (c >> 6 & 0x3f));
o[3] = (0x80 | (c & 0x3f));
return 4;
}
/* should we assert here? */
return 0;
}
size_t BLI_strncpy_wchar_as_utf8(char *dst, const wchar_t *src, const size_t maxcpy)
{
size_t len = 0;
while(*src && len < maxcpy) { /* XXX can still run over the buffer because utf8 size isnt known :| */
len += chtoutf8(*src++, dst+len);
}
dst[len]= '\0';
return len;
}
/* wchar len in utf8 */
size_t BLI_wstrlen_utf8(const wchar_t *src)
{
char ch_dummy[4];
size_t len = 0;
while(*src) {
len += chtoutf8(*src++, ch_dummy);
}
return len;
}
// utf8slen
size_t BLI_strlen_utf8(const char *strc)
{
int len=0;
while(*strc) {
if ((*strc & 0xe0) == 0xc0) {
if((strc[1] & 0x80) && (strc[1] & 0x40) == 0x00)
strc++;
} else if ((*strc & 0xf0) == 0xe0) {
if((strc[1] & strc[2] & 0x80) && ((strc[1] | strc[2]) & 0x40) == 0x00)
strc += 2;
} else if ((*strc & 0xf8) == 0xf0) {
if((strc[1] & strc[2] & strc[3] & 0x80) && ((strc[1] | strc[2] | strc[3]) & 0x40) == 0x00)
strc += 3;
}
strc++;
len++;
}
return len;
}
/* Converts Unicode to wchar
According to RFC 3629 "UTF-8, a transformation format of ISO 10646"
(http://tools.ietf.org/html/rfc3629), the valid UTF-8 encoding are:
Char. number range | UTF-8 octet sequence
(hexadecimal) | (binary)
--------------------+---------------------------------------------
0000 0000-0000 007F | 0xxxxxxx
0000 0080-0000 07FF | 110xxxxx 10xxxxxx
0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
If the encoding incidated by the first character is incorrect (because the
1 to 3 following characters do not match 10xxxxxx), the output is a '?' and
only a single input character is consumed.
*/
size_t BLI_strncpy_wchar_from_utf8(wchar_t *dst_w, const char *src_c, const size_t maxcpy)
{
int len=0;
if(dst_w==NULL || src_c==NULL) return(0);
while(*src_c && len < maxcpy) {
if ((*src_c & 0xe0) == 0xc0) {
if((src_c[1] & 0x80) && (src_c[1] & 0x40) == 0x00) {
*dst_w=((src_c[0] &0x1f)<<6) | (src_c[1]&0x3f);
src_c++;
} else {
*dst_w = '?';
}
} else if ((*src_c & 0xf0) == 0xe0) {
if((src_c[1] & src_c[2] & 0x80) && ((src_c[1] | src_c[2]) & 0x40) == 0x00) {
*dst_w=((src_c[0] & 0x0f)<<12) | ((src_c[1]&0x3f)<<6) | (src_c[2]&0x3f);
src_c += 2;
} else {
*dst_w = '?';
}
} else if ((*src_c & 0xf8) == 0xf0) {
if((src_c[1] & src_c[2] & src_c[3] & 0x80) && ((src_c[1] | src_c[2] | src_c[3]) & 0x40) == 0x00) {
*dst_w=((src_c[0] & 0x07)<<18) | ((src_c[1]&0x1f)<<12) | ((src_c[2]&0x3f)<<6) | (src_c[3]&0x3f);
src_c += 3;
} else {
*dst_w = '?';
}
} else {
*dst_w=(src_c[0] & 0x7f);
}
src_c++;
dst_w++;
len++;
}
return len;
}
/* end wchar_t / utf8 functions */
/* --------------------------------------------------------------------------*/
/* copied from glib */
/**
* g_utf8_find_prev_char:

View File

@@ -44,6 +44,8 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_ghash.h"
#include "BLI_linklist.h"

View File

@@ -221,13 +221,13 @@ static void update_string(Curve *cu)
MEM_freeN(cu->str);
// Calculate the actual string length in UTF-8 variable characters
len = wcsleninu8(ef->textbuf);
len = BLI_wstrlen_utf8(ef->textbuf);
// Alloc memory for UTF-8 variable char length string
cu->str = MEM_callocN(len + sizeof(wchar_t), "str");
// Copy the wchar to UTF-8
wcs2utf8s(cu->str, ef->textbuf);
BLI_strncpy_wchar_as_utf8(cu->str, ef->textbuf, len + 1);
}
static int insert_into_textbuf(Object *obedit, uintptr_t c)
@@ -373,7 +373,7 @@ static int paste_file(bContext *C, ReportList *reports, const char *filename)
if(cu->len+filelen<MAXTEXT) {
int tmplen;
wchar_t *mem = MEM_callocN((sizeof(wchar_t)*filelen)+(4*sizeof(wchar_t)), "temporary");
tmplen = utf8towchar(mem, strp);
tmplen = BLI_strncpy_wchar_from_utf8(mem, strp, filelen + 1);
wcscat(ef->textbuf, mem);
MEM_freeN(mem);
cu->len += tmplen;
@@ -1241,10 +1241,10 @@ static int insert_text_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
inserted_utf8= RNA_string_get_alloc(op->ptr, "text", NULL, 0);
len= strlen(inserted_utf8);
len= BLI_strlen_utf8(inserted_utf8);
inserted_text= MEM_callocN(sizeof(wchar_t)*(len+1), "FONT_insert_text");
utf8towchar(inserted_text, inserted_utf8);
BLI_strncpy_wchar_from_utf8(inserted_text, inserted_utf8, len+1);
for(a=0; a<len; a++)
insert_into_textbuf(obedit, inserted_text[a]);
@@ -1289,10 +1289,22 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt)
else if(event==BACKSPACEKEY)
ascii= 0;
if(val && ascii) {
if(val && (ascii || evt->utf8_buf[0])) {
/* handle case like TAB (== 9) */
if((ascii > 31 && ascii < 254 && ascii != 127) || (ascii==13) || (ascii==10) || (ascii==8)) {
if(accentcode) {
if( (ascii > 31 && ascii < 254 && ascii != 127) ||
(ascii==13) ||
(ascii==10) ||
(ascii==8) ||
(evt->utf8_buf[0]))
{
if (evt->utf8_buf[0]) {
BLI_strncpy_wchar_from_utf8(inserted_text, evt->utf8_buf, 1);
ascii= inserted_text[0];
insert_into_textbuf(obedit, ascii);
accentcode= 0;
}
else if(accentcode) {
if(cu->pos>0) {
inserted_text[0]= findaccent(ef->textbuf[cu->pos-1], ascii);
ef->textbuf[cu->pos-1]= inserted_text[0];
@@ -1348,7 +1360,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt)
/* store as utf8 in RNA string */
char inserted_utf8[8] = {0};
wcs2utf8s(inserted_utf8, inserted_text);
BLI_strncpy_wchar_as_utf8(inserted_utf8, inserted_text, sizeof(inserted_utf8));
RNA_string_set(op->ptr, "text", inserted_utf8);
}
@@ -1478,7 +1490,7 @@ void make_editText(Object *obedit)
}
// Convert the original text to wchar_t
utf8towchar(ef->textbuf, cu->str);
BLI_strncpy_wchar_from_utf8(ef->textbuf, cu->str, MAXTEXT+4); /* length is bogus */
wcscpy(ef->oldstr, ef->textbuf);
cu->len= wcslen(ef->textbuf);

View File

@@ -38,6 +38,7 @@
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"

View File

@@ -601,13 +601,13 @@ static void ui_draw_but_CHARTAB(uiBut *but)
wstr[0] = cs;
if(strcmp(G.selfont->name, FO_BUILTIN_NAME))
{
wcs2utf8s((char *)ustr, (wchar_t *)wstr);
BLI_strncpy_wchar_as_utf8((char *)ustr, (wchar_t *)wstr, sizeof(ustr));
}
else
{
if(G.ui_international == TRUE)
{
wcs2utf8s((char *)ustr, (wchar_t *)wstr);
BLI_strncpy_wchar_as_utf8((char *)ustr, (wchar_t *)wstr, sizeof(ustr));
}
else
{

View File

@@ -1941,7 +1941,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
break;
}
if(event->ascii && (retval == WM_UI_HANDLER_CONTINUE)) {
if((event->ascii || event->utf8_buf[0]) && (retval == WM_UI_HANDLER_CONTINUE)) {
char ascii = event->ascii;
/* exception that's useful for number buttons, some keyboard
@@ -1950,7 +1950,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
if(event->type == PADPERIOD && ascii == ',')
ascii = '.';
if(event->utf8_buf[0] || 1) {
if(event->utf8_buf[0]) {
/* keep this printf until utf8 is well tested */
printf("%s: utf8 char '%s'\n", __func__, event->utf8_buf);
// strcpy(event->utf8_buf, "12345");

View File

@@ -38,8 +38,8 @@
#include "DNA_scene_types.h"
#include "DNA_userdef_types.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BLI_string.h"
#include "BLI_ghash.h"
#include "BKE_animsys.h"

View File

@@ -39,6 +39,8 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLI_string.h"
#include "BLI_listbase.h"
#include "BLI_ghash.h"
#include "BLI_threads.h"

View File

@@ -44,7 +44,6 @@
#include "BLI_blenlib.h"
#include "BLI_linklist.h"
#include "BLI_dynstr.h"
#include "BLI_string.h"
#ifdef WIN32
#include <windows.h> /* need to include windows.h so _WIN32_IE is defined */

View File

@@ -214,6 +214,12 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn)
ED_area_tag_refresh(sa);
}
break;
case NC_OBJECT:
if(type==NTREE_SHADER) {
if(wmn->data==ND_OB_SHADING)
ED_area_tag_refresh(sa);
}
break;
case NC_TEXT:
/* pynodes */
if(wmn->data==ND_SHADING)

View File

@@ -29,10 +29,11 @@
#include "AVI_avi.h"
#include "imbuf.h"
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
#include "BLI_blenlib.h"
#include "BLI_math_base.h"
#include "BLI_string.h"
#include "MEM_guardedalloc.h"
#include "DNA_userdef_types.h"
#include "BKE_global.h"

View File

@@ -342,55 +342,27 @@ static int imb_save_openexr_float(struct ImBuf *ibuf, const char *name, int flag
FrameBuffer frameBuffer;
OutputFile *file = new OutputFile(name, header);
int xstride = sizeof(float) * 4;
int ystride = xstride*width;
float *init_to = new float [4 * width*height * sizeof(float)];
float *from, *to = init_to;
int xstride = sizeof(float) * channels;
int ystride = - xstride*width;
float *rect[4] = {NULL, NULL, NULL, NULL};
frameBuffer.insert ("R", Slice (FLOAT, (char *)init_to, xstride, ystride));
frameBuffer.insert ("G", Slice (FLOAT, (char *)(init_to + 1), xstride, ystride));
frameBuffer.insert ("B", Slice (FLOAT, (char *)(init_to + 2), xstride, ystride));
/* last scanline, stride negative */
rect[0]= ibuf->rect_float + channels*(height-1)*width;
rect[1]= rect[0]+1;
rect[2]= rect[0]+2;
rect[3]= (channels >= 4)? rect[0]+3:rect[0]; /* red as alpha, is this needed since alpha isnt written? */
frameBuffer.insert ("R", Slice (FLOAT, (char *)rect[0], xstride, ystride));
frameBuffer.insert ("G", Slice (FLOAT, (char *)rect[1], xstride, ystride));
frameBuffer.insert ("B", Slice (FLOAT, (char *)rect[2], xstride, ystride));
if (ibuf->depth==32 && channels >= 4)
frameBuffer.insert ("A", Slice (FLOAT, (char *)(init_to + 3), xstride, ystride));
frameBuffer.insert ("A", Slice (FLOAT, (char *)rect[3], xstride, ystride));
if (write_zbuf)
frameBuffer.insert ("Z", Slice (FLOAT, (char *) (ibuf->zbuf_float + (height-1)*width),
sizeof(float), sizeof(float) * -width));
if(ibuf->profile == IB_PROFILE_LINEAR_RGB) {
for (int i = ibuf->y-1; i >= 0; i--)
{
from= ibuf->rect_float + channels*i*width;
for (int j = ibuf->x; j > 0; j--)
{
to[0] = from[0];
to[1] = from[1];
to[2] = from[2];
to[3] = (channels >= 4)? from[3]: 1.0f;
to+= 4; from += 4;
}
}
}
else {
for (int i = ibuf->y-1; i >= 0; i--)
{
from= ibuf->rect_float + channels*i*width;
for (int j = ibuf->x; j > 0; j--)
{
to[0] = srgb_to_linearrgb(from[0]);
to[1] = srgb_to_linearrgb(from[1]);
to[2] = srgb_to_linearrgb(from[2]);
to[3] = (channels >= 4)? from[3]: 1.0f;
to+= 4; from += 4;
}
}
}
file->setFrameBuffer (frameBuffer);
file->writePixels (height);
delete file;
delete [] init_to;
}
catch (const std::exception &exc)
{

View File

@@ -483,7 +483,7 @@ void rna_Curve_body_set(PointerRNA *ptr, const char *value)
cu->str = MEM_callocN(len + sizeof(wchar_t), "str");
cu->strinfo = MEM_callocN( (len+4) *sizeof(CharInfo), "strinfo"); /* don't know why this is +4, just duplicating load_editText() */
//wcs2utf8s(cu->str, value); // value is not wchar_t
//BLI_strncpy_wchar_as_utf8(cu->str, value, len+1); // value is not wchar_t
BLI_strncpy(cu->str, value, len+1);
}

View File

@@ -39,7 +39,6 @@
#include "DNA_genfile.h"
#include "DNA_sdna_types.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BLI_ghash.h"

View File

@@ -55,6 +55,11 @@
#include "WM_types.h"
EnumPropertyItem modifier_type_items[] ={
{0, "", 0, "Modify", ""},
{eModifierType_UVProject, "UV_PROJECT", ICON_MOD_UVPROJECT, "UV Project", ""},
{eModifierType_WeightVGEdit, "VERTEX_WEIGHT_EDIT", ICON_MOD_VERTEX_WEIGHT, "Vertex Weight Edit", ""},
{eModifierType_WeightVGMix, "VERTEX_WEIGHT_MIX", ICON_MOD_VERTEX_WEIGHT, "Vertex Weight Mix", ""},
{eModifierType_WeightVGProximity, "VERTEX_WEIGHT_PROXIMITY", ICON_MOD_VERTEX_WEIGHT, "Vertex Weight Proximity", ""},
{0, "", 0, "Generate", ""},
{eModifierType_Array, "ARRAY", ICON_MOD_ARRAY, "Array", ""},
{eModifierType_Bevel, "BEVEL", ICON_MOD_BEVEL, "Bevel", ""},
@@ -68,11 +73,6 @@ EnumPropertyItem modifier_type_items[] ={
{eModifierType_Screw, "SCREW", ICON_MOD_SCREW, "Screw", ""},
{eModifierType_Solidify, "SOLIDIFY", ICON_MOD_SOLIDIFY, "Solidify", ""},
{eModifierType_Subsurf, "SUBSURF", ICON_MOD_SUBSURF, "Subdivision Surface", ""},
{0, "", 0, "Modify", ""},
{eModifierType_UVProject, "UV_PROJECT", ICON_MOD_UVPROJECT, "UV Project", ""},
{eModifierType_WeightVGEdit, "VERTEX_WEIGHT_EDIT", ICON_MOD_VERTEX_WEIGHT, "Vertex Weight Edit", ""},
{eModifierType_WeightVGMix, "VERTEX_WEIGHT_MIX", ICON_MOD_VERTEX_WEIGHT, "Vertex Weight Mix", ""},
{eModifierType_WeightVGProximity, "VERTEX_WEIGHT_PROXIMITY", ICON_MOD_VERTEX_WEIGHT, "Vertex Weight Proximity", ""},
{0, "", 0, "Deform", ""},
{eModifierType_Armature, "ARMATURE", ICON_MOD_ARMATURE, "Armature", ""},
{eModifierType_Cast, "CAST", ICON_MOD_CAST, "Cast", ""},

View File

@@ -289,12 +289,14 @@ static void rna_def_smoke_flow_settings(BlenderRNA *brna)
RNA_def_property_range(prop, 0.001, 1);
RNA_def_property_ui_range(prop, 0.001, 1.0, 1.0, 4);
RNA_def_property_ui_text(prop, "Density", "");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset");
prop= RNA_def_property(srna, "temperature", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "temp");
RNA_def_property_range(prop, -10, 10);
RNA_def_property_ui_range(prop, -10, 10, 1, 1);
RNA_def_property_ui_text(prop, "Temp. Diff.", "Temperature difference to ambient temperature");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset");
prop= RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "psys");
@@ -306,20 +308,24 @@ static void rna_def_smoke_flow_settings(BlenderRNA *brna)
prop= RNA_def_property(srna, "use_outflow", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "type", MOD_SMOKE_FLOW_TYPE_OUTFLOW);
RNA_def_property_ui_text(prop, "Outflow", "Delete smoke from simulation");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset");
prop= RNA_def_property(srna, "use_absolute", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_FLOW_ABSOLUTE);
RNA_def_property_ui_text(prop, "Absolute Density", "Only allow given density value in emitter area");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset");
prop= RNA_def_property(srna, "initial_velocity", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_FLOW_INITVELOCITY);
RNA_def_property_ui_text(prop, "Initial Velocity", "Smoke inherits its velocity from the emitter particle");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset");
prop= RNA_def_property(srna, "velocity_factor", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "vel_multi");
RNA_def_property_range(prop, -2.0, 2.0);
RNA_def_property_ui_range(prop, -2.0, 2.0, 0.05, 5);
RNA_def_property_ui_text(prop, "Multiplier", "Multiplier to adjust velocity passed to smoke");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset");
}
static void rna_def_smoke_coll_settings(BlenderRNA *brna)

View File

@@ -37,6 +37,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
#include "BLI_string.h"
#include "BKE_bmesh.h"
#include "BKE_cdderivedmesh.h"

View File

@@ -43,6 +43,7 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLI_listbase.h"
#include "BLI_ghash.h"
#include "BKE_cdderivedmesh.h"

View File

@@ -38,6 +38,8 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_ghash.h"
#include "DNA_armature_types.h"

View File

@@ -405,15 +405,15 @@ static bNodeSocket *verify_socket_template(bNodeTree *ntree, bNode *node, int in
static void verify_socket_template_list(bNodeTree *ntree, bNode *node, int in_out, ListBase *socklist, bNodeSocketTemplate *stemp_first)
{
bNodeSocket *sock;
bNodeSocket *sock, *nextsock;
bNodeSocketTemplate *stemp;
/* no inputs anymore? */
if(stemp_first==NULL) {
while(socklist->first) {
sock = (bNodeSocket*)socklist->first;
for (sock = (bNodeSocket*)socklist->first; sock; sock=nextsock) {
nextsock = sock->next;
if (!(sock->flag & SOCK_DYNAMIC))
nodeRemoveSocket(ntree, node, socklist->first);
nodeRemoveSocket(ntree, node, sock);
}
}
else {
@@ -424,10 +424,10 @@ static void verify_socket_template_list(bNodeTree *ntree, bNode *node, int in_ou
stemp++;
}
/* leftovers are removed */
while(socklist->first) {
sock = (bNodeSocket*)socklist->first;
for (sock = (bNodeSocket*)socklist->first; sock; sock=nextsock) {
nextsock = sock->next;
if (!(sock->flag & SOCK_DYNAMIC))
nodeRemoveSocket(ntree, node, socklist->first);
nodeRemoveSocket(ntree, node, sock);
}
/* and we put back the verified sockets */

View File

@@ -30,7 +30,7 @@
#include "py_capi_utils.h"
#include "BKE_font.h" /* only for utf8towchar, should replace with py funcs but too late in release now */
#include "BLI_string_utf8.h" /* only for BLI_strncpy_wchar_from_utf8, should replace with py funcs but too late in release now */
#ifdef _WIN32 /* BLI_setenv */
#include "BLI_path_util.h"
@@ -478,7 +478,7 @@ void PyC_SetHomePath(const char *py_path_bundle)
/* cant use this, on linux gives bug: #23018, TODO: try LANG="en_US.UTF-8" /usr/bin/blender, suggested 22008 */
/* mbstowcs(py_path_bundle_wchar, py_path_bundle, FILE_MAXDIR); */
utf8towchar(py_path_bundle_wchar, py_path_bundle);
BLI_strncpy_wchar_from_utf8(py_path_bundle_wchar, py_path_bundle, sizeof(py_path_bundle_wchar) / sizeof(wchar_t));
Py_SetPythonHome(py_path_bundle_wchar);
// printf("found python (wchar_t) '%ls'\n", py_path_bundle_wchar);

View File

@@ -52,12 +52,12 @@
#include "BLI_path_util.h"
#include "BLI_math_base.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"
#include "BKE_text.h"
#include "BKE_font.h" /* only for utf8towchar */
#include "BKE_main.h"
#include "BKE_global.h" /* only for script checking */
@@ -194,7 +194,7 @@ void BPY_python_start(int argc, const char **argv)
/* not essential but nice to set our name */
static wchar_t bprogname_wchar[FILE_MAXDIR+FILE_MAXFILE]; /* python holds a reference */
utf8towchar(bprogname_wchar, bprogname);
BLI_strncpy_wchar_from_utf8(bprogname_wchar, bprogname, sizeof(bprogname_wchar) / sizeof(wchar_t));
Py_SetProgramName(bprogname_wchar);
/* must run before python initializes */

View File

@@ -44,6 +44,7 @@
#include "../generic/bpy_internal_import.h"
#include "BLI_utildefines.h"
#include "BLI_string.h"
#include "RNA_access.h"
#include "RNA_enum_types.h"

View File

@@ -1146,7 +1146,7 @@ static int wm_eventmatch(wmEvent *winevent, wmKeyMapItem *kmi)
/* the matching rules */
if(kmitype==KM_TEXTINPUT)
if(ISTEXTINPUT(winevent->type) && winevent->ascii) return 1;
if(ISTEXTINPUT(winevent->type) && (winevent->ascii || winevent->utf8_buf[0])) return 1;
if(kmitype!=KM_ANY)
if(winevent->type!=kmitype) return 0;

View File

@@ -56,7 +56,6 @@
#include "BLI_blenlib.h"
#include "BLI_dynstr.h" /*for WM_operator_pystring */
#include "BLI_math.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BLI_ghash.h"