Fix T57884: Triangle count is incorrect when above around 2 billion
Maniphest Tasks: T57884 Differential Revision: https://developer.blender.org/D3962
This commit is contained in:
@@ -33,6 +33,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -71,6 +72,7 @@ char *BLI_sprintfN(const char *__restrict format, ...) ATTR_WARN_UNUSED_RESULT A
|
|||||||
size_t BLI_strescape(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL();
|
size_t BLI_strescape(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL();
|
||||||
|
|
||||||
size_t BLI_str_format_int_grouped(char dst[16], int num) ATTR_NONNULL();
|
size_t BLI_str_format_int_grouped(char dst[16], int num) ATTR_NONNULL();
|
||||||
|
size_t BLI_str_format_uint64_grouped(char dst[16], uint64_t num) ATTR_NONNULL();
|
||||||
void BLI_str_format_byte_unit(char dst[15], long long int size, const bool base_10) ATTR_NONNULL();
|
void BLI_str_format_byte_unit(char dst[15], long long int size, const bool base_10) ATTR_NONNULL();
|
||||||
|
|
||||||
int BLI_strcaseeq(const char *a, const char *b) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
int BLI_strcaseeq(const char *a, const char *b) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
|
|
||||||
@@ -975,24 +976,13 @@ size_t BLI_str_partition_ex(
|
|||||||
return end ? (size_t)(end - str) : strlen(str);
|
return end ? (size_t)(end - str) : strlen(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
size_t BLI_str_format_int_grouped_ex(char src[16], char dst[16], int num_len)
|
||||||
* Format ints with decimal grouping.
|
|
||||||
* 1000 -> 1,000
|
|
||||||
*
|
|
||||||
* \param dst The resulting string
|
|
||||||
* \param num Number to format
|
|
||||||
* \return The length of \a dst
|
|
||||||
*/
|
|
||||||
size_t BLI_str_format_int_grouped(char dst[16], int num)
|
|
||||||
{
|
{
|
||||||
char src[16];
|
|
||||||
char *p_src = src;
|
char *p_src = src;
|
||||||
char *p_dst = dst;
|
char *p_dst = dst;
|
||||||
|
|
||||||
const char separator = ',';
|
const char separator = ',';
|
||||||
int num_len, commas;
|
int commas;
|
||||||
|
|
||||||
num_len = sprintf(src, "%d", num);
|
|
||||||
|
|
||||||
if (*p_src == '-') {
|
if (*p_src == '-') {
|
||||||
*p_dst++ = *p_src++;
|
*p_dst++ = *p_src++;
|
||||||
@@ -1010,6 +1000,38 @@ size_t BLI_str_format_int_grouped(char dst[16], int num)
|
|||||||
return (size_t)(p_dst - dst);
|
return (size_t)(p_dst - dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format ints with decimal grouping.
|
||||||
|
* 1000 -> 1,000
|
||||||
|
*
|
||||||
|
* \param dst The resulting string
|
||||||
|
* \param num Number to format
|
||||||
|
* \return The length of \a dst
|
||||||
|
*/
|
||||||
|
size_t BLI_str_format_int_grouped(char dst[16], int num)
|
||||||
|
{
|
||||||
|
char src[16];
|
||||||
|
int num_len = sprintf(src, "%d", num);
|
||||||
|
|
||||||
|
return BLI_str_format_int_grouped_ex(src, dst, num_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format uint64_t with decimal grouping.
|
||||||
|
* 1000 -> 1,000
|
||||||
|
*
|
||||||
|
* \param dst The resulting string
|
||||||
|
* \param num Number to format
|
||||||
|
* \return The length of \a dst
|
||||||
|
*/
|
||||||
|
size_t BLI_str_format_uint64_grouped(char dst[16], uint64_t num)
|
||||||
|
{
|
||||||
|
char src[16];
|
||||||
|
int num_len = sprintf(src, "%"PRIu64"",num);
|
||||||
|
|
||||||
|
return BLI_str_format_int_grouped_ex(src, dst, num_len);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a size in bytes using binary units.
|
* Format a size in bytes using binary units.
|
||||||
* 1000 -> 1 KB
|
* 1000 -> 1 KB
|
||||||
|
|||||||
@@ -70,14 +70,14 @@
|
|||||||
#define MAX_INFO_NUM_LEN 16
|
#define MAX_INFO_NUM_LEN 16
|
||||||
|
|
||||||
typedef struct SceneStats {
|
typedef struct SceneStats {
|
||||||
int totvert, totvertsel;
|
uint64_t totvert, totvertsel;
|
||||||
int totedge, totedgesel;
|
uint64_t totedge, totedgesel;
|
||||||
int totface, totfacesel;
|
uint64_t totface, totfacesel;
|
||||||
int totbone, totbonesel;
|
uint64_t totbone, totbonesel;
|
||||||
int totobj, totobjsel;
|
uint64_t totobj, totobjsel;
|
||||||
int totlamp, totlampsel;
|
uint64_t totlamp, totlampsel;
|
||||||
int tottri;
|
uint64_t tottri;
|
||||||
int totgplayer, totgpframe, totgpstroke, totgppoint;
|
uint64_t totgplayer, totgpframe, totgpstroke, totgppoint;
|
||||||
|
|
||||||
char infostr[MAX_INFO_LEN];
|
char infostr[MAX_INFO_LEN];
|
||||||
} SceneStats;
|
} SceneStats;
|
||||||
@@ -450,7 +450,7 @@ static void stats_string(ViewLayer *view_layer)
|
|||||||
|
|
||||||
/* Generate formatted numbers */
|
/* Generate formatted numbers */
|
||||||
#define SCENE_STATS_FMT_INT(_id) \
|
#define SCENE_STATS_FMT_INT(_id) \
|
||||||
BLI_str_format_int_grouped(stats_fmt._id, stats->_id)
|
BLI_str_format_uint64_grouped(stats_fmt._id, stats->_id)
|
||||||
|
|
||||||
SCENE_STATS_FMT_INT(totvert);
|
SCENE_STATS_FMT_INT(totvert);
|
||||||
SCENE_STATS_FMT_INT(totvertsel);
|
SCENE_STATS_FMT_INT(totvertsel);
|
||||||
|
|||||||
Reference in New Issue
Block a user