Listing the "Blender Foundation" as copyright holder implied the Blender Foundation holds copyright to files which may include work from many developers. While keeping copyright on headers makes sense for isolated libraries, Blender's own code may be refactored or moved between files in a way that makes the per file copyright holders less meaningful. Copyright references to the "Blender Foundation" have been replaced with "Blender Authors", with the exception of `./extern/` since these this contains libraries which are more isolated, any changed to license headers there can be handled on a case-by-case basis. Some directories in `./intern/` have also been excluded: - `./intern/cycles/` it's own `AUTHORS` file is planned. - `./intern/opensubdiv/`. An "AUTHORS" file has been added, using the chromium projects authors file as a template. Design task: #110784 Ref !110783.
71 lines
1.7 KiB
C++
71 lines
1.7 KiB
C++
/* SPDX-FileCopyrightText: 2012-2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup freestyle
|
|
*/
|
|
|
|
#include "SceneHash.h"
|
|
|
|
#include "BLI_sys_types.h"
|
|
|
|
#include <sstream>
|
|
|
|
namespace Freestyle {
|
|
|
|
string SceneHash::toString()
|
|
{
|
|
stringstream ss;
|
|
ss << hex << _sum;
|
|
return ss.str();
|
|
}
|
|
|
|
void SceneHash::visitNodeViewLayer(NodeViewLayer &node)
|
|
{
|
|
RenderData *r = &node.scene().r;
|
|
adler32((uchar *)&r->xsch, sizeof(r->xsch)); // resolution_x
|
|
adler32((uchar *)&r->ysch, sizeof(r->ysch)); // resolution_y
|
|
adler32((uchar *)&r->size, sizeof(r->size)); // resolution_percentage
|
|
|
|
FreestyleConfig *config = &node.sceneLayer().freestyle_config;
|
|
adler32((uchar *)&config->flags, sizeof(config->flags));
|
|
adler32((uchar *)&config->crease_angle, sizeof(config->crease_angle));
|
|
adler32((uchar *)&config->sphere_radius, sizeof(config->sphere_radius));
|
|
adler32((uchar *)&config->dkr_epsilon, sizeof(config->dkr_epsilon));
|
|
}
|
|
|
|
void SceneHash::visitNodeCamera(NodeCamera &cam)
|
|
{
|
|
double *proj = cam.projectionMatrix();
|
|
for (int i = 0; i < 16; i++) {
|
|
adler32((uchar *)&proj[i], sizeof(double));
|
|
}
|
|
}
|
|
|
|
void SceneHash::visitIndexedFaceSet(IndexedFaceSet &ifs)
|
|
{
|
|
const float *v = ifs.vertices();
|
|
const uint n = ifs.vsize();
|
|
|
|
for (uint i = 0; i < n; i++) {
|
|
adler32((uchar *)&v[i], sizeof(v[i]));
|
|
}
|
|
}
|
|
|
|
static const int MOD_ADLER = 65521;
|
|
|
|
void SceneHash::adler32(const uchar *data, int size)
|
|
{
|
|
uint32_t sum1 = _sum & 0xffff;
|
|
uint32_t sum2 = (_sum >> 16) & 0xffff;
|
|
|
|
for (int i = 0; i < size; i++) {
|
|
sum1 = (sum1 + data[i]) % MOD_ADLER;
|
|
sum2 = (sum1 + sum2) % MOD_ADLER;
|
|
}
|
|
_sum = sum1 | (sum2 << 16);
|
|
}
|
|
|
|
} /* namespace Freestyle */
|