Changeset View
Changeset View
Standalone View
Standalone View
source/blender/render/intern/texture_margin.cc
| /* SPDX-License-Identifier: GPL-2.0-or-later | /* SPDX-License-Identifier: GPL-2.0-or-later | ||||
| * Copyright 2001-2002 NaN Holding BV. All rights reserved. */ | * Copyright 2001-2002 NaN Holding BV. All rights reserved. */ | ||||
| /** \file | /** \file | ||||
| * \ingroup render | * \ingroup render | ||||
| */ | */ | ||||
| #include "BLI_assert.h" | #include "BLI_assert.h" | ||||
| #include "BLI_math_geom.h" | #include "BLI_math_geom.h" | ||||
| #include "BLI_math_vec_types.hh" | #include "BLI_math_vec_types.hh" | ||||
| #include "BLI_math_vector.hh" | #include "BLI_math_vector.hh" | ||||
| #include "BLI_vector.hh" | #include "BLI_vector.hh" | ||||
| #include "BKE_DerivedMesh.h" | #include "BKE_DerivedMesh.h" | ||||
| #include "BKE_customdata.h" | #include "BKE_customdata.h" | ||||
| #include "BKE_mesh.h" | #include "BKE_mesh.h" | ||||
| #include "BKE_mesh_mapping.h" | |||||
| #include "DNA_mesh_types.h" | #include "DNA_mesh_types.h" | ||||
| #include "DNA_meshdata_types.h" | #include "DNA_meshdata_types.h" | ||||
| #include "IMB_imbuf.h" | #include "IMB_imbuf.h" | ||||
| #include "IMB_imbuf_types.h" | #include "IMB_imbuf_types.h" | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| Show All 14 Lines | |||||
| */ | */ | ||||
| class TextureMarginMap { | class TextureMarginMap { | ||||
| static const int directions[8][2]; | static const int directions[8][2]; | ||||
| static const int distances[8]; | static const int distances[8]; | ||||
| /** Maps UV-edges to their corresponding UV-edge. */ | /** Maps UV-edges to their corresponding UV-edge. */ | ||||
| Vector<int> loop_adjacency_map_; | Vector<int> loop_adjacency_map_; | ||||
| /** Maps UV-edges to their corresponding polygon. */ | /** Maps UV-edges to their corresponding polygon. */ | ||||
| Vector<int> loop_to_poly_map_; | Array<int> loop_to_poly_map_; | ||||
| int w_, h_; | int w_, h_; | ||||
| float uv_offset_[2]; | float uv_offset_[2]; | ||||
| Vector<uint32_t> pixel_data_; | Vector<uint32_t> pixel_data_; | ||||
| ZSpan zspan_; | ZSpan zspan_; | ||||
| uint32_t value_to_store_; | uint32_t value_to_store_; | ||||
| char *mask_; | char *mask_; | ||||
| ▲ Show 20 Lines • Show All 228 Lines • ▼ Show 20 Lines | float2 uv_to_xy(MLoopUV const &mloopuv) const | ||||
| float2 ret; | float2 ret; | ||||
| ret.x = (((mloopuv.uv[0] - uv_offset_[0]) * w_) - (0.5f + 0.001f)); | ret.x = (((mloopuv.uv[0] - uv_offset_[0]) * w_) - (0.5f + 0.001f)); | ||||
| ret.y = (((mloopuv.uv[1] - uv_offset_[1]) * h_) - (0.5f + 0.001f)); | ret.y = (((mloopuv.uv[1] - uv_offset_[1]) * h_) - (0.5f + 0.001f)); | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| void build_tables() | void build_tables() | ||||
| { | { | ||||
| loop_to_poly_map_.resize(totloop_); | loop_to_poly_map_ = blender::mesh_topology::build_corner_to_poly_map({mpoly_, totpoly_}, | ||||
| for (int i = 0; i < totpoly_; i++) { | totloop_); | ||||
| for (int j = 0; j < mpoly_[i].totloop; j++) { | |||||
| int l = j + mpoly_[i].loopstart; | |||||
| loop_to_poly_map_[l] = i; | |||||
| } | |||||
| } | |||||
| loop_adjacency_map_.resize(totloop_, -1); | loop_adjacency_map_.resize(totloop_, -1); | ||||
| Vector<int> tmpmap; | Vector<int> tmpmap; | ||||
| tmpmap.resize(totedge_, -1); | tmpmap.resize(totedge_, -1); | ||||
| for (size_t i = 0; i < totloop_; i++) { | for (size_t i = 0; i < totloop_; i++) { | ||||
| int edge = mloop_[i].e; | int edge = mloop_[i].e; | ||||
| ▲ Show 20 Lines • Show All 312 Lines • Show Last 20 Lines | |||||