From f22148e80f2d2d2a1eb8725943b00c7908fca431 Mon Sep 17 00:00:00 2001 From: aismann Date: Sat, 8 Oct 2022 00:15:03 +0200 Subject: [PATCH] Improve MeshRenderer #879 thanks @solan-solan (#904) * Update Physics3DTest.cpp Improve #879 thanks @solan-solan * Update CCMeshRenderer.cpp #hope this is fixing #879 --- core/3d/CCMeshRenderer.cpp | 1 + tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.cpp | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/3d/CCMeshRenderer.cpp b/core/3d/CCMeshRenderer.cpp index 477f7c79d1..e2382d2860 100644 --- a/core/3d/CCMeshRenderer.cpp +++ b/core/3d/CCMeshRenderer.cpp @@ -520,6 +520,7 @@ void MeshRenderer::genMaterial(bool useLight) if (oldmaterial) { material->setStateBlock(oldmaterial->getStateBlock()); + material->setTransparent(oldmaterial->isTransparent()); } if (material->getReferenceCount() == 1) diff --git a/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.cpp b/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.cpp index 86d3d0cee6..6bca59e686 100644 --- a/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.cpp +++ b/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.cpp @@ -327,9 +327,11 @@ bool Physics3DKinematicDemo::init() auto component = Physics3DComponent::create(rigidBody); auto sprite = Sprite3D::create(tree1); sprite->addComponent(component); + static_cast(sprite->getChildren().at(1))->getMaterial(0)->setTransparent(true); + static_cast(sprite->getChildren().at(1))->getMaterial(0)->getStateBlock().setCullFaceSide(CullFaceSide::NONE); + sprite->setCameraMask((unsigned short)CameraFlag::USER1 | (unsigned short)CameraFlag::USER2 | (unsigned short)CameraFlag::USER3); sprite->setPosition3D(Vec3(20.0f, 0.0f, 0.0f)); sprite->setScale(scale); - sprite->setCameraMask((unsigned short)CameraFlag::USER1); this->addChild(sprite); } // Issue #879 ENDS HERE