MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / init

Method init

Engine/source/scene/reflectionMatHook.cpp:48–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48void ReflectionMaterialHook::init( BaseMatInstance *inMat )
49{
50 if( !inMat->isValid() )
51 return;
52
53 Material *reflectMat = (Material*)inMat->getMaterial();
54 if ( inMat->isCustomMaterial() )
55 {
56 // This is a custom material... who knows what it really does...do something
57 // smart here later.
58 }
59
60 // We may want to disable some states that the material might enable for us.
61 GFXStateBlockDesc refractState = inMat->getUserStateBlock();
62
63 // Always z-read, and z-write if the material isn't translucent
64 refractState.setZReadWrite( true, reflectMat->isTranslucent() ? false : true );
65
66 // Create reflection material instance.
67 BaseMatInstance *newMat = new ReflectionMatInstance( reflectMat );
68 newMat->setUserObject( inMat->getUserObject() );
69 newMat->getFeaturesDelegate().bind( &ReflectionMaterialHook::_overrideFeatures );
70 newMat->addStateBlockDesc( refractState );
71 if( !newMat->init( inMat->getFeatures(), inMat->getVertexFormat() ) )
72 {
73 SAFE_DELETE( newMat );
74 newMat = MATMGR->createWarningMatInstance();
75 }
76
77 mReflectMat = newMat;
78}
79
80void ReflectionMaterialHook::_overrideFeatures( ProcessedMaterial *mat,
81 U32 stageNum,

Callers

nothing calls this directly

Calls 12

isCustomMaterialMethod · 0.80
setZReadWriteMethod · 0.80
isTranslucentMethod · 0.80
getUserObjectMethod · 0.80
isValidMethod · 0.45
getMaterialMethod · 0.45
setUserObjectMethod · 0.45
bindMethod · 0.45
addStateBlockDescMethod · 0.45
getFeaturesMethod · 0.45
getVertexFormatMethod · 0.45

Tested by

no test coverage detected