Improve MeshRenderer #879 thanks @solan-solan (#904)

* Update Physics3DTest.cpp

Improve #879  thanks @solan-solan

* Update CCMeshRenderer.cpp

#hope this is fixing #879
This commit is contained in:
aismann 2022-10-08 00:15:03 +02:00 committed by GitHub
parent 7a3314160c
commit f22148e80f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -520,6 +520,7 @@ void MeshRenderer::genMaterial(bool useLight)
if (oldmaterial)
{
material->setStateBlock(oldmaterial->getStateBlock());
material->setTransparent(oldmaterial->isTransparent());
}
if (material->getReferenceCount() == 1)

View File

@ -327,9 +327,11 @@ bool Physics3DKinematicDemo::init()
auto component = Physics3DComponent::create(rigidBody);
auto sprite = Sprite3D::create(tree1);
sprite->addComponent(component);
static_cast<Sprite3D*>(sprite->getChildren().at(1))->getMaterial(0)->setTransparent(true);
static_cast<Sprite3D*>(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