forked from bartvdbraak/blender
Merge branch 'master' into blender2.8
This commit is contained in:
commit
ca67cdb73c
@ -38,7 +38,7 @@ PROJECT_NAME = Blender
|
||||
# could be handy for archiving the generated documentation or if some version
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER = "V2.8x"
|
||||
PROJECT_NUMBER = "V2.79"
|
||||
|
||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||
# for a project that appears at the top of each page and should give viewer a
|
||||
|
@ -14,6 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "kernel/kernel_compat_opencl.h" // PRECOMPILED
|
||||
#include "kernel/split/kernel_split_common.h" // PRECOMPILED
|
||||
|
||||
#include "kernel/kernels/opencl/kernel_state_buffer_size.cl"
|
||||
#include "kernel/kernels/opencl/kernel_data_init.cl"
|
||||
#include "kernel/kernels/opencl/kernel_path_init.cl"
|
||||
|
@ -45,6 +45,7 @@ OIIO_NAMESPACE_USING
|
||||
# include <shlwapi.h>
|
||||
#endif
|
||||
|
||||
#include "util/util_map.h"
|
||||
#include "util/util_windows.h"
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
@ -768,15 +769,35 @@ bool path_remove(const string& path)
|
||||
return remove(path.c_str()) == 0;
|
||||
}
|
||||
|
||||
static string line_directive(const string& base, const string& path, int line)
|
||||
struct SourceReplaceState {
|
||||
typedef map<string, string> ProcessedMapping;
|
||||
/* Base director for all relative include headers. */
|
||||
string base;
|
||||
/* Result of processed files. */
|
||||
ProcessedMapping processed_files;
|
||||
/* Set of files which are considered "precompiled" and which are replaced
|
||||
* with and empty string on a subsequent occurrence in include statement.
|
||||
*/
|
||||
set<string> precompiled_headers;
|
||||
};
|
||||
|
||||
static string path_source_replace_includes_recursive(
|
||||
const string& source,
|
||||
const string& source_filepath,
|
||||
SourceReplaceState *state);
|
||||
|
||||
static string line_directive(const SourceReplaceState& state,
|
||||
const string& path,
|
||||
const int line)
|
||||
{
|
||||
string escaped_path = path;
|
||||
/* First we make path relative. */
|
||||
if(string_startswith(escaped_path, base.c_str())) {
|
||||
const string base_file = path_filename(base);
|
||||
const size_t base_len = base.length();
|
||||
escaped_path = base_file + escaped_path.substr(base_len,
|
||||
escaped_path.length() - base_len);
|
||||
if(string_startswith(escaped_path, state.base.c_str())) {
|
||||
const string base_file = path_filename(state.base);
|
||||
const size_t base_len = state.base.length();
|
||||
escaped_path = base_file +
|
||||
escaped_path.substr(base_len,
|
||||
escaped_path.length() - base_len);
|
||||
}
|
||||
/* Second, we replace all unsafe characters. */
|
||||
string_replace(escaped_path, "\"", "\\\"");
|
||||
@ -786,50 +807,106 @@ static string line_directive(const string& base, const string& path, int line)
|
||||
return string_printf("#line %d \"%s\"", line, escaped_path.c_str());
|
||||
}
|
||||
|
||||
static string path_source_replace_includes_recursive(
|
||||
const string& base,
|
||||
const string& source,
|
||||
const string& source_filepath)
|
||||
static string path_source_handle_preprocessor(
|
||||
const string& preprocessor_line,
|
||||
const string& source_filepath,
|
||||
const size_t line_number,
|
||||
SourceReplaceState *state)
|
||||
{
|
||||
/* Our own little c preprocessor that replaces #includes with the file
|
||||
* contents, to work around issue of OpenCL drivers not supporting
|
||||
* include paths with spaces in them.
|
||||
*/
|
||||
|
||||
string result = "";
|
||||
vector<string> lines;
|
||||
string_split(lines, source, "\n", false);
|
||||
|
||||
for(size_t i = 0; i < lines.size(); ++i) {
|
||||
string line = lines[i];
|
||||
if(line[0] == '#') {
|
||||
string token = string_strip(line.substr(1, line.size() - 1));
|
||||
if(string_startswith(token, "include")) {
|
||||
token = string_strip(token.substr(7, token.size() - 7));
|
||||
if(token[0] == '"') {
|
||||
const size_t n_start = 1;
|
||||
const size_t n_end = token.find("\"", n_start);
|
||||
const string filename = token.substr(n_start, n_end - n_start);
|
||||
string filepath = path_join(base, filename);
|
||||
if(!path_exists(filepath)) {
|
||||
filepath = path_join(path_dirname(source_filepath),
|
||||
filename);
|
||||
}
|
||||
string text;
|
||||
if(path_read_text(filepath, text)) {
|
||||
text = path_source_replace_includes_recursive(
|
||||
base, text, filepath);
|
||||
/* Use line directives for better error messages. */
|
||||
line = line_directive(base, filepath, 1)
|
||||
+ token.replace(0, n_end + 1, "\n" + text + "\n")
|
||||
+ line_directive(base, source_filepath, i + 1);
|
||||
}
|
||||
}
|
||||
string result = preprocessor_line;
|
||||
string token = string_strip(
|
||||
preprocessor_line.substr(1, preprocessor_line.size() - 1));
|
||||
if(string_startswith(token, "include")) {
|
||||
token = string_strip(token.substr(7, token.size() - 7));
|
||||
if(token[0] == '"') {
|
||||
const size_t n_start = 1;
|
||||
const size_t n_end = token.find("\"", n_start);
|
||||
const string filename = token.substr(n_start, n_end - n_start);
|
||||
const bool is_precompiled = string_endswith(token, "// PRECOMPILED");
|
||||
string filepath = path_join(state->base, filename);
|
||||
if(!path_exists(filepath)) {
|
||||
filepath = path_join(path_dirname(source_filepath),
|
||||
filename);
|
||||
}
|
||||
if(is_precompiled) {
|
||||
state->precompiled_headers.insert(filepath);
|
||||
}
|
||||
string text;
|
||||
if(path_read_text(filepath, text)) {
|
||||
text = path_source_replace_includes_recursive(
|
||||
text, filepath, state);
|
||||
/* Use line directives for better error messages. */
|
||||
result = line_directive(*state, filepath, 1) + "\n"
|
||||
+ text + "\n"
|
||||
+ line_directive(*state, source_filepath, line_number + 1);
|
||||
}
|
||||
}
|
||||
result += line + "\n";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Our own little c preprocessor that replaces #includes with the file
|
||||
* contents, to work around issue of OpenCL drivers not supporting
|
||||
* include paths with spaces in them.
|
||||
*/
|
||||
static string path_source_replace_includes_recursive(
|
||||
const string& source,
|
||||
const string& source_filepath,
|
||||
SourceReplaceState *state)
|
||||
{
|
||||
/* Try to re-use processed file without spending time on replacing all
|
||||
* include directives again.
|
||||
*/
|
||||
SourceReplaceState::ProcessedMapping::iterator replaced_file =
|
||||
state->processed_files.find(source_filepath);
|
||||
if(replaced_file != state->processed_files.end()) {
|
||||
if(state->precompiled_headers.find(source_filepath) !=
|
||||
state->precompiled_headers.end()) {
|
||||
return "";
|
||||
}
|
||||
return replaced_file->second;
|
||||
}
|
||||
/* Perform full file processing. */
|
||||
string result = "";
|
||||
const size_t source_length = source.length();
|
||||
size_t index = 0;
|
||||
size_t line_number = 0, column_number = 1;
|
||||
bool inside_preprocessor = false;
|
||||
string preprocessor_line = "";
|
||||
while(index < source_length) {
|
||||
const char ch = source[index];
|
||||
if(ch == '\n') {
|
||||
if(inside_preprocessor) {
|
||||
result += path_source_handle_preprocessor(preprocessor_line,
|
||||
source_filepath,
|
||||
line_number,
|
||||
state);
|
||||
}
|
||||
inside_preprocessor = false;
|
||||
preprocessor_line = "";
|
||||
column_number = 0;
|
||||
++line_number;
|
||||
}
|
||||
else if(ch == '#' && column_number == 1) {
|
||||
inside_preprocessor = true;
|
||||
}
|
||||
if(inside_preprocessor) {
|
||||
preprocessor_line += ch;
|
||||
}
|
||||
else {
|
||||
result += ch;
|
||||
}
|
||||
++index;
|
||||
++column_number;
|
||||
}
|
||||
if(inside_preprocessor) {
|
||||
result += path_source_handle_preprocessor(preprocessor_line,
|
||||
source_filepath,
|
||||
line_number,
|
||||
state);
|
||||
}
|
||||
/* Store result for further reuse. */
|
||||
state->processed_files[source_filepath] = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -837,10 +914,12 @@ string path_source_replace_includes(const string& source,
|
||||
const string& path,
|
||||
const string& source_filename)
|
||||
{
|
||||
SourceReplaceState state;
|
||||
state.base = path;
|
||||
return path_source_replace_includes_recursive(
|
||||
path,
|
||||
source,
|
||||
path_join(path, source_filename));
|
||||
path_join(path, source_filename),
|
||||
&state);
|
||||
}
|
||||
|
||||
FILE *path_fopen(const string& path, const string& mode)
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 277 KiB After Width: | Height: | Size: 248 KiB |
Binary file not shown.
Before Width: | Height: | Size: 965 KiB After Width: | Height: | Size: 682 KiB |
@ -110,7 +110,7 @@
|
||||
inner="#39424bcc"
|
||||
inner_sel="#667686bf"
|
||||
item="#191919ff"
|
||||
text="#000000"
|
||||
text="#b8b8b8"
|
||||
text_sel="#ffffff"
|
||||
show_shaded="TRUE"
|
||||
shadetop="25"
|
||||
|
@ -110,7 +110,7 @@
|
||||
inner="#4b4b4bff"
|
||||
inner_sel="#646464ff"
|
||||
item="#191919ff"
|
||||
text="#000000"
|
||||
text="#b8b8b8"
|
||||
text_sel="#ffffff"
|
||||
show_shaded="TRUE"
|
||||
shadetop="0"
|
||||
|
@ -110,7 +110,7 @@
|
||||
inner="#303030ff"
|
||||
inner_sel="#678db2ff"
|
||||
item="#191919ff"
|
||||
text="#272727"
|
||||
text="#e6f1ff"
|
||||
text_sel="#ffffff"
|
||||
show_shaded="FALSE"
|
||||
shadetop="0"
|
||||
|
@ -375,8 +375,7 @@ static size_t unit_as_string(char *str, int len_max, double value, int prec, con
|
||||
/* Adjust precision to expected number of significant digits.
|
||||
* Note that here, we shall not have to worry about very big/small numbers, units are expected to replace
|
||||
* 'scientific notation' in those cases. */
|
||||
const int l10 = (value_conv == 0.0) ? 0 : (int)log10(fabs(value_conv));
|
||||
prec -= l10 + (int)(l10 < 0);
|
||||
prec -= integer_digits_d(value_conv);
|
||||
CLAMP(prec, 0, 6);
|
||||
|
||||
/* Convert to a string */
|
||||
@ -449,12 +448,15 @@ size_t bUnit_AsString(char *str, int len_max, double value, int prec, int system
|
||||
size_t i;
|
||||
i = unit_as_string(str, len_max, value_a, prec, usys, unit_a, '\0');
|
||||
|
||||
prec -= integer_digits_d(value_a / unit_b->scalar) - integer_digits_d(value_b / unit_b->scalar);
|
||||
prec = max_ii(prec, 0);
|
||||
|
||||
/* is there enough space for at least 1 char of the next unit? */
|
||||
if (i + 2 < len_max) {
|
||||
str[i++] = ' ';
|
||||
|
||||
/* use low precision since this is a smaller unit */
|
||||
i += unit_as_string(str + i, len_max - i, value_b, prec ? 1 : 0, usys, unit_b, '\0');
|
||||
i += unit_as_string(str + i, len_max - i, value_b, prec, usys, unit_b, '\0');
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
@ -138,6 +138,9 @@ MINLINE int signum_i(float a);
|
||||
|
||||
MINLINE float power_of_2(float f);
|
||||
|
||||
MINLINE int integer_digits_f(const float f);
|
||||
MINLINE int integer_digits_d(const double d);
|
||||
|
||||
/* these don't really fit anywhere but were being copied about a lot */
|
||||
MINLINE int is_power_of_2_i(int n);
|
||||
MINLINE int power_of_2_max_i(int n);
|
||||
|
@ -314,6 +314,21 @@ MINLINE int signum_i(float a)
|
||||
else return 0;
|
||||
}
|
||||
|
||||
/** Returns number of (base ten) *significant* digits of integer part of given float
|
||||
* (negative in case of decimal-only floats, 0.01 returns -1 e.g.). */
|
||||
MINLINE int integer_digits_f(const float f)
|
||||
{
|
||||
return (f == 0.0f) ? 0 : (int)floor(log10(fabs(f))) + 1;
|
||||
}
|
||||
|
||||
/** Returns number of (base ten) *significant* digits of integer part of given double
|
||||
* (negative in case of decimal-only floats, 0.01 returns -1 e.g.). */
|
||||
MINLINE int integer_digits_d(const double d)
|
||||
{
|
||||
return (d == 0.0) ? 0 : (int)floor(log10(fabs(d))) + 1;
|
||||
}
|
||||
|
||||
|
||||
/* Internal helpers for SSE2 implementation.
|
||||
*
|
||||
* NOTE: Are to be called ONLY from inside `#ifdef __SSE2__` !!!
|
||||
|
@ -1659,7 +1659,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
|
||||
} FOREACH_NODETREE_END
|
||||
}
|
||||
|
||||
{
|
||||
if (!MAIN_VERSION_ATLEAST(main, 279, 0)) {
|
||||
for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
|
||||
if (scene->r.im_format.exr_codec == R_IMF_EXR_CODEC_DWAB) {
|
||||
scene->r.im_format.exr_codec = R_IMF_EXR_CODEC_DWAA;
|
||||
@ -1697,7 +1697,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
|
||||
void do_versions_after_linking_270(Main *main)
|
||||
{
|
||||
/* To be added to next subversion bump! */
|
||||
{
|
||||
if (!MAIN_VERSION_ATLEAST(main, 279, 0)) {
|
||||
FOREACH_NODETREE(main, ntree, id) {
|
||||
if (ntree->type == NTREE_COMPOSIT) {
|
||||
ntreeSetTypes(NULL, ntree);
|
||||
|
@ -2226,20 +2226,24 @@ void ui_but_string_get_ex(uiBut *but, char *str, const size_t maxlen, const int
|
||||
else {
|
||||
int prec = (float_precision == -1) ? ui_but_calc_float_precision(but, value) : float_precision;
|
||||
if (use_exp_float) {
|
||||
const int l10 = (value == 0.0f) ? 0 : (int)log10(fabs(value));
|
||||
if (l10 < -6 || l10 > 12) {
|
||||
const int int_digits_num = integer_digits_f(value);
|
||||
if (int_digits_num < -6 || int_digits_num > 12) {
|
||||
BLI_snprintf(str, maxlen, "%.*g", prec, value);
|
||||
if (r_use_exp_float) {
|
||||
*r_use_exp_float = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
prec -= l10 + (int)(l10 < 0);
|
||||
prec -= int_digits_num;
|
||||
CLAMP(prec, 0, UI_PRECISION_FLOAT_MAX);
|
||||
BLI_snprintf(str, maxlen, "%.*f", prec, value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
#if 0 /* TODO, but will likely break some stuff, so better after 2.79 release. */
|
||||
prec -= int_digits_num;
|
||||
CLAMP(prec, 0, UI_PRECISION_FLOAT_MAX);
|
||||
#endif
|
||||
BLI_snprintf(str, maxlen, "%.*f", prec, value);
|
||||
}
|
||||
}
|
||||
|
@ -32,18 +32,17 @@ class UnitsTesting(unittest.TestCase):
|
||||
OUTPUT_TESTS = (
|
||||
# system, type, prec, sep, compat, value, output
|
||||
##### LENGTH
|
||||
# Note: precision handling is a bit complicated when using multi-units...
|
||||
('IMPERIAL', 'LENGTH', 3, False, False, 0.3048, "1'"),
|
||||
('IMPERIAL', 'LENGTH', 3, False, True, 0.3048, "1ft"),
|
||||
('IMPERIAL', 'LENGTH', 3, True, False, 0.3048 * 2 + 0.0254 * 5.5, "2' 5.5\""),
|
||||
# Those next two fail, here again because precision ignores order magnitude :/
|
||||
#('IMPERIAL', 'LENGTH', 3, False, False, 1609.344 * 1e6, "1000000mi"), # == 1000000.004mi!!!
|
||||
#('IMPERIAL', 'LENGTH', 6, False, False, 1609.344 * 1e6, "1000000mi"), # == 1000000.003641mi!!!
|
||||
('METRIC', 'LENGTH', 3, True, False, 1000 * 2 + 0.001 * 15, "2km 1.5cm"),
|
||||
('METRIC', 'LENGTH', 3, True, False, 1234.56789, "1km 234.6m"),
|
||||
# Note: precision seems basically unused when using multi units!
|
||||
('METRIC', 'LENGTH', 9, True, False, 1234.56789, "1km 234.6m"),
|
||||
('METRIC', 'LENGTH', 9, False, False, 1234.56789, "1.23456789km"),
|
||||
('METRIC', 'LENGTH', 9, True, False, 1000.000123456789, "1km 0.1mm"),
|
||||
('IMPERIAL', 'LENGTH', 4, True, False, 0.3048 * 2 + 0.0254 * 5.5, "2' 5.5\""),
|
||||
('IMPERIAL', 'LENGTH', 3, False, False, 1609.344 * 1e6, "1000000mi"),
|
||||
('IMPERIAL', 'LENGTH', 6, False, False, 1609.344 * 1e6, "1000000mi"),
|
||||
('METRIC', 'LENGTH', 3, True, False, 1000 * 2 + 0.001 * 15, "2km 2cm"),
|
||||
('METRIC', 'LENGTH', 5, True, False, 1234.56789, "1km 234.6m"),
|
||||
('METRIC', 'LENGTH', 6, True, False, 1234.56789, "1km 234.57m"),
|
||||
('METRIC', 'LENGTH', 9, False, False, 1234.56789, "1.234568km"),
|
||||
('METRIC', 'LENGTH', 9, True, False, 1000.000123456789, "1km 0.123mm"),
|
||||
)
|
||||
|
||||
def test_units_inputs(self):
|
||||
|
Loading…
Reference in New Issue
Block a user