mirror of
https://github.com/minetest/irrlicht.git
synced 2025-07-01 15:50:27 +02:00
Reformat the code, using:
find -type f | # list all regular files grep -E '\.(h|cpp|mm)$' | # filter for source files grep -v '/mt_' | # filter out generated files grep -v '/vendor/' | # and vendored GL grep -v '/test/image_loader_test.cpp' | # and this file (has giant literals arrays) xargs -n 1 -P $(nproc) clang-format -i # reformat everything Co-authored-by: numzero <numzer0@yandex.ru>
This commit is contained in:
@ -17,23 +17,21 @@ namespace irr
|
||||
namespace scene
|
||||
{
|
||||
|
||||
|
||||
|
||||
//! constructor
|
||||
CMeshSceneNode::CMeshSceneNode(IMesh* mesh, ISceneNode* parent, ISceneManager* mgr, s32 id,
|
||||
const core::vector3df& position, const core::vector3df& rotation,
|
||||
const core::vector3df& scale)
|
||||
: IMeshSceneNode(parent, mgr, id, position, rotation, scale), Mesh(0),
|
||||
PassCount(0), ReadOnlyMaterials(false)
|
||||
CMeshSceneNode::CMeshSceneNode(IMesh *mesh, ISceneNode *parent, ISceneManager *mgr, s32 id,
|
||||
const core::vector3df &position, const core::vector3df &rotation,
|
||||
const core::vector3df &scale) :
|
||||
IMeshSceneNode(parent, mgr, id, position, rotation, scale),
|
||||
Mesh(0),
|
||||
PassCount(0), ReadOnlyMaterials(false)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CMeshSceneNode");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
setMesh(mesh);
|
||||
}
|
||||
|
||||
|
||||
//! destructor
|
||||
CMeshSceneNode::~CMeshSceneNode()
|
||||
{
|
||||
@ -41,18 +39,16 @@ CMeshSceneNode::~CMeshSceneNode()
|
||||
Mesh->drop();
|
||||
}
|
||||
|
||||
|
||||
//! frame
|
||||
void CMeshSceneNode::OnRegisterSceneNode()
|
||||
{
|
||||
if (IsVisible && Mesh)
|
||||
{
|
||||
if (IsVisible && Mesh) {
|
||||
// because this node supports rendering of mixed mode meshes consisting of
|
||||
// transparent and solid material at the same time, we need to go through all
|
||||
// materials, check of what type they are and register this node for the right
|
||||
// render pass according to that.
|
||||
|
||||
video::IVideoDriver* driver = SceneManager->getVideoDriver();
|
||||
video::IVideoDriver *driver = SceneManager->getVideoDriver();
|
||||
|
||||
PassCount = 0;
|
||||
int transparentCount = 0;
|
||||
@ -60,11 +56,10 @@ void CMeshSceneNode::OnRegisterSceneNode()
|
||||
|
||||
// count transparent and solid materials in this scene node
|
||||
const u32 numMaterials = ReadOnlyMaterials ? Mesh->getMeshBufferCount() : Materials.size();
|
||||
for (u32 i=0; i<numMaterials; ++i)
|
||||
{
|
||||
const video::SMaterial& material = ReadOnlyMaterials ? Mesh->getMeshBuffer(i)->getMaterial() : Materials[i];
|
||||
for (u32 i = 0; i < numMaterials; ++i) {
|
||||
const video::SMaterial &material = ReadOnlyMaterials ? Mesh->getMeshBuffer(i)->getMaterial() : Materials[i];
|
||||
|
||||
if ( driver->needsTransparentRenderPass(material) )
|
||||
if (driver->needsTransparentRenderPass(material))
|
||||
++transparentCount;
|
||||
else
|
||||
++solidCount;
|
||||
@ -85,36 +80,32 @@ void CMeshSceneNode::OnRegisterSceneNode()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! renders the node.
|
||||
void CMeshSceneNode::render()
|
||||
{
|
||||
video::IVideoDriver* driver = SceneManager->getVideoDriver();
|
||||
video::IVideoDriver *driver = SceneManager->getVideoDriver();
|
||||
|
||||
if (!Mesh || !driver)
|
||||
return;
|
||||
|
||||
const bool isTransparentPass =
|
||||
SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT;
|
||||
SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT;
|
||||
|
||||
++PassCount;
|
||||
|
||||
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
|
||||
Box = Mesh->getBoundingBox();
|
||||
|
||||
for (u32 i=0; i<Mesh->getMeshBufferCount(); ++i)
|
||||
{
|
||||
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
|
||||
if (mb)
|
||||
{
|
||||
const video::SMaterial& material = ReadOnlyMaterials ? mb->getMaterial() : Materials[i];
|
||||
for (u32 i = 0; i < Mesh->getMeshBufferCount(); ++i) {
|
||||
scene::IMeshBuffer *mb = Mesh->getMeshBuffer(i);
|
||||
if (mb) {
|
||||
const video::SMaterial &material = ReadOnlyMaterials ? mb->getMaterial() : Materials[i];
|
||||
|
||||
const bool transparent = driver->needsTransparentRenderPass(material);
|
||||
|
||||
// only render transparent buffer if this is the transparent render pass
|
||||
// and solid only in solid pass
|
||||
if (transparent == isTransparentPass)
|
||||
{
|
||||
if (transparent == isTransparentPass) {
|
||||
driver->setMaterial(material);
|
||||
driver->drawMeshBuffer(mb);
|
||||
}
|
||||
@ -122,80 +113,68 @@ void CMeshSceneNode::render()
|
||||
}
|
||||
|
||||
// for debug purposes only:
|
||||
if (DebugDataVisible && PassCount==1)
|
||||
{
|
||||
if (DebugDataVisible && PassCount == 1) {
|
||||
video::SMaterial m;
|
||||
m.Lighting = false;
|
||||
m.AntiAliasing=0;
|
||||
m.AntiAliasing = 0;
|
||||
driver->setMaterial(m);
|
||||
|
||||
if (DebugDataVisible & scene::EDS_BBOX)
|
||||
{
|
||||
driver->draw3DBox(Box, video::SColor(255,255,255,255));
|
||||
if (DebugDataVisible & scene::EDS_BBOX) {
|
||||
driver->draw3DBox(Box, video::SColor(255, 255, 255, 255));
|
||||
}
|
||||
if (DebugDataVisible & scene::EDS_BBOX_BUFFERS)
|
||||
{
|
||||
for (u32 g=0; g<Mesh->getMeshBufferCount(); ++g)
|
||||
{
|
||||
if (DebugDataVisible & scene::EDS_BBOX_BUFFERS) {
|
||||
for (u32 g = 0; g < Mesh->getMeshBufferCount(); ++g) {
|
||||
driver->draw3DBox(
|
||||
Mesh->getMeshBuffer(g)->getBoundingBox(),
|
||||
video::SColor(255,190,128,128));
|
||||
Mesh->getMeshBuffer(g)->getBoundingBox(),
|
||||
video::SColor(255, 190, 128, 128));
|
||||
}
|
||||
}
|
||||
|
||||
if (DebugDataVisible & scene::EDS_NORMALS)
|
||||
{
|
||||
if (DebugDataVisible & scene::EDS_NORMALS) {
|
||||
// draw normals
|
||||
const f32 debugNormalLength = 1.f;
|
||||
const video::SColor debugNormalColor = video::SColor(255, 34, 221, 221);
|
||||
const u32 count = Mesh->getMeshBufferCount();
|
||||
|
||||
for (u32 i=0; i != count; ++i)
|
||||
{
|
||||
for (u32 i = 0; i != count; ++i) {
|
||||
driver->drawMeshBufferNormals(Mesh->getMeshBuffer(i), debugNormalLength, debugNormalColor);
|
||||
}
|
||||
}
|
||||
|
||||
// show mesh
|
||||
if (DebugDataVisible & scene::EDS_MESH_WIRE_OVERLAY)
|
||||
{
|
||||
if (DebugDataVisible & scene::EDS_MESH_WIRE_OVERLAY) {
|
||||
m.Wireframe = true;
|
||||
driver->setMaterial(m);
|
||||
|
||||
for (u32 g=0; g<Mesh->getMeshBufferCount(); ++g)
|
||||
{
|
||||
for (u32 g = 0; g < Mesh->getMeshBufferCount(); ++g) {
|
||||
driver->drawMeshBuffer(Mesh->getMeshBuffer(g));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! Removes a child from this scene node.
|
||||
//! Implemented here, to be able to remove the shadow properly, if there is one,
|
||||
//! or to remove attached childs.
|
||||
bool CMeshSceneNode::removeChild(ISceneNode* child)
|
||||
bool CMeshSceneNode::removeChild(ISceneNode *child)
|
||||
{
|
||||
return ISceneNode::removeChild(child);
|
||||
}
|
||||
|
||||
|
||||
//! returns the axis aligned bounding box of this node
|
||||
const core::aabbox3d<f32>& CMeshSceneNode::getBoundingBox() const
|
||||
const core::aabbox3d<f32> &CMeshSceneNode::getBoundingBox() const
|
||||
{
|
||||
return Mesh ? Mesh->getBoundingBox() : Box;
|
||||
}
|
||||
|
||||
|
||||
//! returns the material based on the zero based index i. To get the amount
|
||||
//! of materials used by this scene node, use getMaterialCount().
|
||||
//! This function is needed for inserting the node into the scene hierarchy on a
|
||||
//! optimal position for minimizing renderstate changes, but can also be used
|
||||
//! to directly modify the material of a scene node.
|
||||
video::SMaterial& CMeshSceneNode::getMaterial(u32 i)
|
||||
video::SMaterial &CMeshSceneNode::getMaterial(u32 i)
|
||||
{
|
||||
if (Mesh && ReadOnlyMaterials && i<Mesh->getMeshBufferCount())
|
||||
{
|
||||
if (Mesh && ReadOnlyMaterials && i < Mesh->getMeshBufferCount()) {
|
||||
ReadOnlyMaterial = Mesh->getMeshBuffer(i)->getMaterial();
|
||||
return ReadOnlyMaterial;
|
||||
}
|
||||
@ -206,7 +185,6 @@ video::SMaterial& CMeshSceneNode::getMaterial(u32 i)
|
||||
return Materials[i];
|
||||
}
|
||||
|
||||
|
||||
//! returns amount of materials used by this scene node.
|
||||
u32 CMeshSceneNode::getMaterialCount() const
|
||||
{
|
||||
@ -216,12 +194,10 @@ u32 CMeshSceneNode::getMaterialCount() const
|
||||
return Materials.size();
|
||||
}
|
||||
|
||||
|
||||
//! Sets a new mesh
|
||||
void CMeshSceneNode::setMesh(IMesh* mesh)
|
||||
void CMeshSceneNode::setMesh(IMesh *mesh)
|
||||
{
|
||||
if (mesh)
|
||||
{
|
||||
if (mesh) {
|
||||
mesh->grab();
|
||||
if (Mesh)
|
||||
Mesh->drop();
|
||||
@ -231,18 +207,15 @@ void CMeshSceneNode::setMesh(IMesh* mesh)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CMeshSceneNode::copyMaterials()
|
||||
{
|
||||
Materials.clear();
|
||||
|
||||
if (Mesh)
|
||||
{
|
||||
if (Mesh) {
|
||||
video::SMaterial mat;
|
||||
|
||||
for (u32 i=0; i<Mesh->getMeshBufferCount(); ++i)
|
||||
{
|
||||
IMeshBuffer* mb = Mesh->getMeshBuffer(i);
|
||||
for (u32 i = 0; i < Mesh->getMeshBufferCount(); ++i) {
|
||||
IMeshBuffer *mb = Mesh->getMeshBuffer(i);
|
||||
if (mb)
|
||||
mat = mb->getMaterial();
|
||||
|
||||
@ -251,7 +224,6 @@ void CMeshSceneNode::copyMaterials()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! Sets if the scene node should not copy the materials of the mesh but use them in a read only style.
|
||||
/* In this way it is possible to change the materials a mesh causing all mesh scene nodes
|
||||
referencing this mesh to change too. */
|
||||
@ -260,24 +232,22 @@ void CMeshSceneNode::setReadOnlyMaterials(bool readonly)
|
||||
ReadOnlyMaterials = readonly;
|
||||
}
|
||||
|
||||
|
||||
//! Returns if the scene node should not copy the materials of the mesh but use them in a read only style
|
||||
bool CMeshSceneNode::isReadOnlyMaterials() const
|
||||
{
|
||||
return ReadOnlyMaterials;
|
||||
}
|
||||
|
||||
|
||||
//! Creates a clone of this scene node and its children.
|
||||
ISceneNode* CMeshSceneNode::clone(ISceneNode* newParent, ISceneManager* newManager)
|
||||
ISceneNode *CMeshSceneNode::clone(ISceneNode *newParent, ISceneManager *newManager)
|
||||
{
|
||||
if (!newParent)
|
||||
newParent = Parent;
|
||||
if (!newManager)
|
||||
newManager = SceneManager;
|
||||
|
||||
CMeshSceneNode* nb = new CMeshSceneNode(Mesh, newParent,
|
||||
newManager, ID, RelativeTranslation, RelativeRotation, RelativeScale);
|
||||
CMeshSceneNode *nb = new CMeshSceneNode(Mesh, newParent,
|
||||
newManager, ID, RelativeTranslation, RelativeRotation, RelativeScale);
|
||||
|
||||
nb->cloneMembers(this, newManager);
|
||||
nb->ReadOnlyMaterials = ReadOnlyMaterials;
|
||||
@ -288,7 +258,5 @@ ISceneNode* CMeshSceneNode::clone(ISceneNode* newParent, ISceneManager* newManag
|
||||
return nb;
|
||||
}
|
||||
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
|
Reference in New Issue
Block a user