Files
test2/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

299 lines
7.3 KiB
C
Raw Normal View History

/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
/** \file
* \ingroup freestyle
2019-08-17 00:54:22 +10:00
* \brief A Set of indexed faces to represent a surface object
*/
#include <memory.h>
#include <stdio.h>
//! inherits from class Rep
#include "Rep.h"
#include "../system/FreestyleConfig.h"
2008-04-30 15:41:54 +00:00
Attempt to fix a potential name conflict between Freestyle and the compositor. A crash in the Freestyle renderer was reported by Ton on IRC with a stack trace below. Note that #2 is in Freestyle, whereas #1 is in the compositor. The problem was observed in a debug build on OS X 10.7 (gcc 4.2, openmp disabled, no llvm). ---------------------------------------------------------------------- Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: 13 at address: 0x0000000000000000 [Switching to process 72386 thread 0xf303] 0x0000000100c129f3 in NodeBase::~NodeBase (this=0x10e501c80) at COM_NodeBase.cpp:43 43 delete (this->m_outputsockets.back()); Current language: auto; currently c++ (gdb) where #0 0x0000000100c129f3 in NodeBase::~NodeBase (this=0x10e501c80) at COM_NodeBase.cpp:43 #1 0x0000000100c29066 in Node::~Node (this=0x10e501c80) at COM_Node.h:49 #2 0x000000010089c273 in NodeShape::~NodeShape (this=0x10e501c80) at NodeShape.cpp:43 #3 0x000000010089910b in NodeGroup::destroy (this=0x10e501da0) at NodeGroup.cpp:61 #4 0x00000001008990cd in NodeGroup::destroy (this=0x10e5014b0) at NodeGroup.cpp:59 #5 0x00000001008990cd in NodeGroup::destroy (this=0x114e18da0) at NodeGroup.cpp:59 #6 0x00000001007e6602 in Controller::ClearRootNode (this=0x114e19640) at Controller.cpp:329 #7 0x00000001007ea52e in Controller::LoadMesh (this=0x114e19640, re=0x10aba4638, srl=0x1140f5258) at Controller.cpp:302 #8 0x00000001008030ad in prepare (re=0x10aba4638, srl=0x1140f5258) at FRS_freestyle.cpp:302 #9 0x000000010080457a in FRS_do_stroke_rendering (re=0x10aba4638, srl=0x1140f5258) at FRS_freestyle.cpp:600 #10 0x00000001006aeb9d in add_freestyle (re=0x10aba4638) at pipeline.c:1584 #11 0x00000001006aceb7 in do_render_3d (re=0x10aba4638) at pipeline.c:1094 #12 0x00000001006ae061 in do_render_fields_blur_3d (re=0x10aba4638) at pipeline.c:1367 #13 0x00000001006afa16 in do_render_composite_fields_blur_3d (re=0x10aba4638) at pipeline.c:1815 #14 0x00000001006b04e4 in do_render_all_options (re=0x10aba4638) at pipeline.c:2021 ---------------------------------------------------------------------- Apparently a name conflict between the two Blender modules is taking place. The present commit hence intends to address it by putting all the Freestyle C++ classes in the namespace 'Freestyle'. This revision will also prevent potential name conflicts with other Blender modules in the future. Special thanks to Lukas Toenne for the help with C++ namespace.
2013-04-09 00:46:49 +00:00
namespace Freestyle {
class IndexedFaceSet : public Rep {
2008-04-30 15:41:54 +00:00
public:
/** Triangles description style: */
enum TRIANGLES_STYLE {
TRIANGLE_STRIP,
TRIANGLE_FAN,
TRIANGLES,
};
/** User-specified face and edge marks for feature edge detection */
/* XXX Why in hell not use an enum here too? */
typedef uchar FaceEdgeMark;
static const FaceEdgeMark FACE_MARK = 1 << 0;
static const FaceEdgeMark EDGE_MARK_V1V2 = 1 << 1;
static const FaceEdgeMark EDGE_MARK_V2V3 = 1 << 2;
static const FaceEdgeMark EDGE_MARK_V3V1 = 1 << 3;
/** Builds an empty indexed face set. */
IndexedFaceSet();
/** Builds an indexed face set
* iVertices
* The array of object vertices 3D coordinates (for all faces).
* If iCopy != 0, the array is copied; you must deallocate iVertices. Else you must not.
* iVSize
* The size of iVertices (must be a multiple of 3)
* iNormals
* The array of object normals 3D coordinates.
* If iCopy != 0, the array is copied; you must deallocate iNormals. Else you must not.
* iNSize
* The size of iNormals
* iMaterials
* The array of materials
* iMSize
* The size of iMaterials
* iTexCoords
* The array of texture coordinates.
* iTSize
* The size of iTexCoords (must be multiple of 2)
* iNumFaces
* The number of faces
* iNumVertexPerFace
* Array containing the number of vertices per face.
* iFaceStyle
* Array containing the description style of each faces.
* The style belongs to:
* - TRIANGLE_STRIP: the face indices describe a triangle strip
* - TRIANGLE_FAN : the face indices describe a triangle fan
* - TRIANGLES : the face indices describe single triangles
* If iCopy != 0, the array is copied; you must deallocate iFaceStyle. Else you must not.
* iVIndices,
2018-06-17 17:05:14 +02:00
* Array of vertices indices.
* The integers contained in this array must be multiple of 3.
* If iCopy != 0, the array is copied; you must deallocate iVIndices. Else you must not.
* iVISize
* The size of iVIndices.
* iNIndices
* Array of normals indices.
* The integers contained in this array must be multiple of 3.
* If iCopy != 0, the array is copied; you must deallocate iNIndices. Else you must not.
* iNISize
* The size of iNIndices
* iMIndices
* The Material indices (per vertex)
* iMISize
* The size of iMIndices
* iTIndices
* The Texture coordinates indices (per vertex). The integers contained in this array must
* be multiple of 2. iTISize The size of iMIndices iCopy 0 : the arrays are not copied. The
2024-01-29 11:47:42 +11:00
* pointers passed as arguments are used. IndexedFaceSet takes these arrays deallocation in
* charge. 1 : the arrays are copied. The caller is in charge of the arrays, passed as arguments
2024-01-29 11:47:42 +11:00
* deallocation.
2018-09-02 18:28:27 +10:00
*/
IndexedFaceSet(float *iVertices,
uint iVSize,
float *iNormals,
uint iNSize,
FrsMaterial **iMaterials,
uint iMSize,
float *iTexCoords,
uint iTSize,
uint iNumFaces,
uint *iNumVertexPerFace,
TRIANGLES_STYLE *iFaceStyle,
FaceEdgeMark *iFaceEdgeMarks,
uint *iVIndices,
uint iVISize,
uint *iNIndices,
uint iNISize,
uint *iMIndices,
uint iMISize,
uint *iTIndices,
uint iTISize,
uint iCopy = 1);
/** Builds an indexed face set from an other indexed face set */
IndexedFaceSet(const IndexedFaceSet &iBrother);
void swap(IndexedFaceSet &ioOther)
{
2008-04-30 15:41:54 +00:00
std::swap(_Vertices, ioOther._Vertices);
std::swap(_Normals, ioOther._Normals);
std::swap(_FrsMaterials, ioOther._FrsMaterials);
std::swap(_TexCoords, ioOther._TexCoords);
std::swap(_FaceEdgeMarks, ioOther._FaceEdgeMarks);
2008-04-30 15:41:54 +00:00
std::swap(_VSize, ioOther._VSize);
std::swap(_NSize, ioOther._NSize);
std::swap(_MSize, ioOther._MSize);
std::swap(_TSize, ioOther._TSize);
2008-04-30 15:41:54 +00:00
std::swap(_NumFaces, ioOther._NumFaces);
std::swap(_NumVertexPerFace, ioOther._NumVertexPerFace);
std::swap(_FaceStyle, ioOther._FaceStyle);
2008-04-30 15:41:54 +00:00
std::swap(_VIndices, ioOther._VIndices);
std::swap(_NIndices, ioOther._NIndices);
std::swap(_MIndices, ioOther._MIndices); // Material Indices
std::swap(_TIndices, ioOther._TIndices);
2008-04-30 15:41:54 +00:00
std::swap(_VISize, ioOther._VISize);
std::swap(_NISize, ioOther._NISize);
std::swap(_MISize, ioOther._MISize);
std::swap(_TISize, ioOther._TISize);
2008-04-30 15:41:54 +00:00
Rep::swap(ioOther);
}
IndexedFaceSet &operator=(const IndexedFaceSet &iBrother)
{
2008-04-30 15:41:54 +00:00
IndexedFaceSet tmp(iBrother);
swap(tmp);
return *this;
}
/** Destructor
* deallocates all the resources
*/
virtual ~IndexedFaceSet();
/** Accept the corresponding visitor */
virtual void accept(SceneVisitor &v);
/** Compute the Bounding Box */
virtual void ComputeBBox();
/** Accessors */
virtual const float *vertices() const
{
return _Vertices;
}
virtual const float *normals() const
{
return _Normals;
}
2019-03-25 11:42:28 +11:00
virtual const FrsMaterial *const *frs_materials() const
{
return _FrsMaterials;
}
virtual const float *texCoords() const
{
return _TexCoords;
}
virtual uint vsize() const
{
return _VSize;
}
virtual uint nsize() const
{
return _NSize;
}
virtual uint msize() const
{
return _MSize;
}
virtual uint tsize() const
{
return _TSize;
}
virtual uint numFaces() const
{
return _NumFaces;
}
virtual const uint *numVertexPerFaces() const
{
return _NumVertexPerFace;
}
virtual const TRIANGLES_STYLE *trianglesStyle() const
{
return _FaceStyle;
}
virtual const uchar *faceEdgeMarks() const
{
return _FaceEdgeMarks;
}
virtual const uint *vindices() const
{
return _VIndices;
}
virtual const uint *nindices() const
{
return _NIndices;
}
virtual const uint *mindices() const
{
return _MIndices;
}
virtual const uint *tindices() const
{
return _TIndices;
}
virtual uint visize() const
{
return _VISize;
}
virtual uint nisize() const
{
return _NISize;
}
virtual uint misize() const
{
return _MISize;
}
virtual uint tisize() const
{
return _TISize;
}
2008-04-30 15:41:54 +00:00
protected:
float *_Vertices;
float *_Normals;
FrsMaterial **_FrsMaterials;
float *_TexCoords;
uint _VSize;
uint _NSize;
uint _MSize;
uint _TSize;
uint _NumFaces;
uint *_NumVertexPerFace;
TRIANGLES_STYLE *_FaceStyle;
FaceEdgeMark *_FaceEdgeMarks;
uint *_VIndices;
uint *_NIndices;
uint *_MIndices; // Material Indices
uint *_TIndices; // Texture coordinates Indices
uint _VISize;
uint _NISize;
uint _MISize;
uint _TISize;
2008-04-30 15:41:54 +00:00
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:IndexedFaceSet")
2008-04-30 15:41:54 +00:00
};
Attempt to fix a potential name conflict between Freestyle and the compositor. A crash in the Freestyle renderer was reported by Ton on IRC with a stack trace below. Note that #2 is in Freestyle, whereas #1 is in the compositor. The problem was observed in a debug build on OS X 10.7 (gcc 4.2, openmp disabled, no llvm). ---------------------------------------------------------------------- Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: 13 at address: 0x0000000000000000 [Switching to process 72386 thread 0xf303] 0x0000000100c129f3 in NodeBase::~NodeBase (this=0x10e501c80) at COM_NodeBase.cpp:43 43 delete (this->m_outputsockets.back()); Current language: auto; currently c++ (gdb) where #0 0x0000000100c129f3 in NodeBase::~NodeBase (this=0x10e501c80) at COM_NodeBase.cpp:43 #1 0x0000000100c29066 in Node::~Node (this=0x10e501c80) at COM_Node.h:49 #2 0x000000010089c273 in NodeShape::~NodeShape (this=0x10e501c80) at NodeShape.cpp:43 #3 0x000000010089910b in NodeGroup::destroy (this=0x10e501da0) at NodeGroup.cpp:61 #4 0x00000001008990cd in NodeGroup::destroy (this=0x10e5014b0) at NodeGroup.cpp:59 #5 0x00000001008990cd in NodeGroup::destroy (this=0x114e18da0) at NodeGroup.cpp:59 #6 0x00000001007e6602 in Controller::ClearRootNode (this=0x114e19640) at Controller.cpp:329 #7 0x00000001007ea52e in Controller::LoadMesh (this=0x114e19640, re=0x10aba4638, srl=0x1140f5258) at Controller.cpp:302 #8 0x00000001008030ad in prepare (re=0x10aba4638, srl=0x1140f5258) at FRS_freestyle.cpp:302 #9 0x000000010080457a in FRS_do_stroke_rendering (re=0x10aba4638, srl=0x1140f5258) at FRS_freestyle.cpp:600 #10 0x00000001006aeb9d in add_freestyle (re=0x10aba4638) at pipeline.c:1584 #11 0x00000001006aceb7 in do_render_3d (re=0x10aba4638) at pipeline.c:1094 #12 0x00000001006ae061 in do_render_fields_blur_3d (re=0x10aba4638) at pipeline.c:1367 #13 0x00000001006afa16 in do_render_composite_fields_blur_3d (re=0x10aba4638) at pipeline.c:1815 #14 0x00000001006b04e4 in do_render_all_options (re=0x10aba4638) at pipeline.c:2021 ---------------------------------------------------------------------- Apparently a name conflict between the two Blender modules is taking place. The present commit hence intends to address it by putting all the Freestyle C++ classes in the namespace 'Freestyle'. This revision will also prevent potential name conflicts with other Blender modules in the future. Special thanks to Lukas Toenne for the help with C++ namespace.
2013-04-09 00:46:49 +00:00
} /* namespace Freestyle */