Refactored ScriptInstance recreation when the ScriptFile is reloaded. Now it uses events. Same system used also for CollisionShapes and Models to ensure proper reloading.
Added possibility to get primitive & batchcount from the Pipeline. This will only include the actual 3D scene statistics, not UI or debug geometry. Fixed import of model in the editor in case the Models subdirectory did not exist yet. Fixes to handling of root derived transforms in AssetImporter. Renamed the NinjaSnowWar scene.
This commit is contained in:
parent
c593231dae
commit
bdf76d2445
@ -260,8 +260,8 @@ void setupStatsBarText(Text@ text, Font@ font, int x, int y, HorizontalAlignment
|
||||
void updateStats(float timeStep)
|
||||
{
|
||||
renderStatsText.setText(
|
||||
"Tris: " + renderer.getNumPrimitives() +
|
||||
" Batches: " + renderer.getNumBatches() +
|
||||
"Tris: " + pipeline.getNumPrimitives() +
|
||||
" Batches: " + pipeline.getNumBatches() +
|
||||
" Lights: " + pipeline.getNumLights(true) +
|
||||
" Shadowmaps: " + pipeline.getNumShadowMaps(true) +
|
||||
" Occluders: " + (pipeline.getNumOccluders(true) + pipeline.getNumShadowOccluders(true))
|
||||
|
@ -8,6 +8,8 @@ void importModel(const string& in fileName)
|
||||
string outFileName = sceneResourcePath + modelName;
|
||||
string materialListName = sceneResourcePath + "_tempmatlist_.txt";
|
||||
|
||||
createDirectory(sceneResourcePath + "Models");
|
||||
|
||||
array<string> args;
|
||||
args.push("model");
|
||||
args.push("\"" + fileName + "\"");
|
||||
|
@ -175,11 +175,6 @@ void reloadResources()
|
||||
uint numResources = sceneResources.size();
|
||||
for (uint i = 0; i < numResources; ++i)
|
||||
{
|
||||
// For now, skip physics for safety
|
||||
// (Rigidbodies would need to be informed of the ODE collisionshape being blown away from under their feet)
|
||||
if (sceneResources[i].getTypeName() == "CollisionShape")
|
||||
continue;
|
||||
|
||||
// Material textures are not listed by getResourceRefs(), so have to handle them manually
|
||||
Material@ mat = cast<Material>(sceneResources[i]);
|
||||
if (mat !is null)
|
||||
|
@ -6484,6 +6484,50 @@
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="397" netflags="0" netdistance="0" groupflags="0">
|
||||
<component type="AnimatedModel" netflags="0">
|
||||
<transform pos="20 20 50" rot="0 0 0" scale="0.01 0.01 0.01" />
|
||||
<parent id="0" type="" name="" />
|
||||
<render castshadows="false" occluder="false" visible="true" />
|
||||
<lod drawdistance="0" shadowdistance="0" viewmask="-1" lightmask="-1" lodbias="1" animlodbias="1" invisiblelodfactor="0" localanimation="false" />
|
||||
<model name="Models/cat.mdl" />
|
||||
<material name="" />
|
||||
<animation name="Models/cat_Anim1.ani" startbone="root" looped="true" weight="1" time="0" priority="0" nlerp="false" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="398" netflags="0" netdistance="0" groupflags="0">
|
||||
<component type="AnimatedModel" netflags="0">
|
||||
<transform pos="30 20 50" rot="0 0 0" scale="0.01 0.01 0.01" />
|
||||
<parent id="0" type="" name="" />
|
||||
<render castshadows="false" occluder="false" visible="true" />
|
||||
<lod drawdistance="0" shadowdistance="0" viewmask="-1" lightmask="-1" lodbias="1" animlodbias="1" invisiblelodfactor="0" localanimation="false" />
|
||||
<model name="Models/neko.mdl" />
|
||||
<material name="" />
|
||||
<animation name="Models/neko_Anim1.ani" startbone="root" looped="true" weight="1" time="0" priority="0" nlerp="false" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="399" netflags="0" netdistance="0" groupflags="0">
|
||||
<component type="AnimatedModel" netflags="0">
|
||||
<transform pos="20 20 70" rot="0 0 0" scale="0.005 0.005 0.005" />
|
||||
<parent id="0" type="" name="" />
|
||||
<render castshadows="false" occluder="false" visible="true" />
|
||||
<lod drawdistance="0" shadowdistance="0" viewmask="-1" lightmask="-1" lodbias="1" animlodbias="1" invisiblelodfactor="0" localanimation="false" />
|
||||
<model name="Models/scout.mdl" />
|
||||
<material name="" />
|
||||
<animation name="Models/scout_Anim1.ani" startbone="scout_rigged_max" looped="true" weight="1" time="0" priority="0" nlerp="false" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="400" netflags="0" netdistance="0" groupflags="0">
|
||||
<component type="AnimatedModel" netflags="0">
|
||||
<transform pos="30 20 70" rot="0 0 0" scale="0.005 0.005 0.005" />
|
||||
<parent id="0" type="" name="" />
|
||||
<render castshadows="false" occluder="false" visible="true" />
|
||||
<lod drawdistance="0" shadowdistance="0" viewmask="-1" lightmask="-1" lodbias="1" animlodbias="1" invisiblelodfactor="0" localanimation="false" />
|
||||
<model name="Models/scoutmodel.mdl" />
|
||||
<material name="" />
|
||||
<animation name="Models/scoutmodelAnim1.ani" startbone="scout_rigged_max" looped="true" weight="1" time="0" priority="0" nlerp="false" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="401" netflags="0" netdistance="0" groupflags="0">
|
||||
<component type="BillboardSet" netflags="0">
|
||||
<transform pos="8.22144 16.6862 67.0898" rot="0 0 0" scale="1 1 1" />
|
||||
<parent id="0" type="" name="" />
|
||||
@ -6508,7 +6552,7 @@
|
||||
<billboard enabled="true" pos="-2.61749 3.82642 -2.41425" size="3.77332 4.60217" uv="0 0 1 1" color="1 1 1 1" rot="144.415" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="398" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="402" netflags="0" netdistance="0" groupflags="0">
|
||||
<component type="BillboardSet" netflags="0">
|
||||
<transform pos="-64.1479 19.2584 -76.0437" rot="0 0 0" scale="1 1 1" />
|
||||
<parent id="0" type="" name="" />
|
||||
@ -6533,7 +6577,7 @@
|
||||
<billboard enabled="true" pos="1.02173 0.658203 -4.82574" size="4.75275 3.3028" uv="0 0 1 1" color="1 1 1 1" rot="174.76" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="399" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="403" netflags="0" netdistance="0" groupflags="0">
|
||||
<component type="BillboardSet" netflags="0">
|
||||
<transform pos="35.2905 11.0631 -63.8672" rot="0 0 0" scale="1 1 1" />
|
||||
<parent id="0" type="" name="" />
|
||||
@ -6558,7 +6602,7 @@
|
||||
<billboard enabled="true" pos="1.00708 -0.253174 -4.77951" size="4.93286 4.30548" uv="0 0 1 1" color="1 1 1 1" rot="239.37" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="400" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="404" netflags="0" netdistance="0" groupflags="0">
|
||||
<component type="BillboardSet" netflags="0">
|
||||
<transform pos="67.7185 10.6213 -80.481" rot="0 0 0" scale="1 1 1" />
|
||||
<parent id="0" type="" name="" />
|
||||
@ -6583,7 +6627,7 @@
|
||||
<billboard enabled="true" pos="4.58267 2.65552 -4.57855" size="4.26135 4.65717" uv="0 0 1 1" color="1 1 1 1" rot="0.911865" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="401" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="405" netflags="0" netdistance="0" groupflags="0">
|
||||
<component type="BillboardSet" netflags="0">
|
||||
<transform pos="-55.0049 17.2488 75.2319" rot="0 0 0" scale="1 1 1" />
|
||||
<parent id="0" type="" name="" />
|
||||
@ -6608,7 +6652,7 @@
|
||||
<billboard enabled="true" pos="2.67929 3.9751 -0.112152" size="4.5166 4.95605" uv="0 0 1 1" color="1 1 1 1" rot="268.11" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="402" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="406" netflags="0" netdistance="0" groupflags="0">
|
||||
<component type="BillboardSet" netflags="0">
|
||||
<transform pos="72.2473 16.7027 -56.9824" rot="0 0 0" scale="1 1 1" />
|
||||
<parent id="0" type="" name="" />
|
||||
@ -6633,7 +6677,7 @@
|
||||
<billboard enabled="true" pos="-0.524597 -2.44775 5.36453" size="4.06592 3.43811" uv="0 0 1 1" color="1 1 1 1" rot="191.788" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="403" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="407" netflags="0" netdistance="0" groupflags="0">
|
||||
<component type="BillboardSet" netflags="0">
|
||||
<transform pos="3.28369 8.30551 -59.8877" rot="0 0 0" scale="1 1 1" />
|
||||
<parent id="0" type="" name="" />
|
||||
@ -6658,7 +6702,7 @@
|
||||
<billboard enabled="true" pos="2.94388 3.34937 0.166626" size="3.67584 3.85736" uv="0 0 1 1" color="1 1 1 1" rot="318.219" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="404" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="408" netflags="0" netdistance="0" groupflags="0">
|
||||
<component type="BillboardSet" netflags="0">
|
||||
<transform pos="96.344 5.06271 -71.0144" rot="0 0 0" scale="1 1 1" />
|
||||
<parent id="0" type="" name="" />
|
||||
@ -6683,7 +6727,7 @@
|
||||
<billboard enabled="true" pos="-5.99762 -0.247803 2.84637" size="3.88116 4.22003" uv="0 0 1 1" color="1 1 1 1" rot="237.294" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="405" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="409" netflags="0" netdistance="0" groupflags="0">
|
||||
<component type="BillboardSet" netflags="0">
|
||||
<transform pos="19.9585 6.45523 -99.7864" rot="0 0 0" scale="1 1 1" />
|
||||
<parent id="0" type="" name="" />
|
||||
@ -6708,7 +6752,7 @@
|
||||
<billboard enabled="true" pos="-6.26312 -2.34912 -1.41861" size="4.30457 3.07739" uv="0 0 1 1" color="1 1 1 1" rot="56.6016" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="406" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="410" netflags="0" netdistance="0" groupflags="0">
|
||||
<component type="BillboardSet" netflags="0">
|
||||
<transform pos="74.7925 18.3827 45.5566" rot="0 0 0" scale="1 1 1" />
|
||||
<parent id="0" type="" name="" />
|
||||
@ -6733,7 +6777,7 @@
|
||||
<billboard enabled="true" pos="-0.553436 1.45361 0.637665" size="3.37384 4.15625" uv="0 0 1 1" color="1 1 1 1" rot="1.5271" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="407" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="411" netflags="0" netdistance="0" groupflags="0">
|
||||
<component type="BillboardSet" netflags="0">
|
||||
<transform pos="-77.7832 7.90222 20.9778" rot="0 0 0" scale="1 1 1" />
|
||||
<parent id="0" type="" name="" />
|
||||
@ -6758,7 +6802,7 @@
|
||||
<billboard enabled="true" pos="-2.10388 -3.15894 2.33002" size="3.966 4.0589" uv="0 0 1 1" color="1 1 1 1" rot="340.071" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="408" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="412" netflags="0" netdistance="0" groupflags="0">
|
||||
<component type="BillboardSet" netflags="0">
|
||||
<transform pos="-13.0493 6.50192 92.2852" rot="0 0 0" scale="1 1 1" />
|
||||
<parent id="0" type="" name="" />
|
||||
@ -6783,7 +6827,7 @@
|
||||
<billboard enabled="true" pos="5.45517 -1.25659 1.54953" size="3.83032 3.95679" uv="0 0 1 1" color="1 1 1 1" rot="297.433" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="409" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="413" netflags="0" netdistance="0" groupflags="0">
|
||||
<component type="BillboardSet" netflags="0">
|
||||
<transform pos="-47.5403 14.7032 47.467" rot="0 0 0" scale="1 1 1" />
|
||||
<parent id="0" type="" name="" />
|
||||
@ -6808,7 +6852,7 @@
|
||||
<billboard enabled="true" pos="6.40778 -0.440186 2.13455" size="3.73175 4.19666" uv="0 0 1 1" color="1 1 1 1" rot="294.258" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="410" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="414" netflags="0" netdistance="0" groupflags="0">
|
||||
<component type="BillboardSet" netflags="0">
|
||||
<transform pos="30.9937 15.0525 -18.1946" rot="0 0 0" scale="1 1 1" />
|
||||
<parent id="0" type="" name="" />
|
||||
@ -6833,7 +6877,7 @@
|
||||
<billboard enabled="true" pos="0.817566 -0.959961 3.49228" size="3.41296 4.52454" uv="0 0 1 1" color="1 1 1 1" rot="139.57" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="411" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="415" netflags="0" netdistance="0" groupflags="0">
|
||||
<component type="BillboardSet" netflags="0">
|
||||
<transform pos="-36.6638 18.1145 30.7129" rot="0 0 0" scale="1 1 1" />
|
||||
<parent id="0" type="" name="" />
|
||||
@ -6858,7 +6902,7 @@
|
||||
<billboard enabled="true" pos="-0.578156 0.484863 -4.29245" size="3.16223 3.47162" uv="0 0 1 1" color="1 1 1 1" rot="267.363" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="412" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="416" netflags="0" netdistance="0" groupflags="0">
|
||||
<component type="BillboardSet" netflags="0">
|
||||
<transform pos="-29.3457 5.55893 11.5417" rot="0 0 0" scale="1 1 1" />
|
||||
<parent id="0" type="" name="" />
|
||||
@ -6883,7 +6927,7 @@
|
||||
<billboard enabled="true" pos="-5.93033 -2.68457 -1.42593" size="4.3429 3.96954" uv="0 0 1 1" color="1 1 1 1" rot="303.333" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="413" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="417" netflags="0" netdistance="0" groupflags="0">
|
||||
<component type="BillboardSet" netflags="0">
|
||||
<transform pos="-64.8438 11.5341 -0.3479" rot="0 0 0" scale="1 1 1" />
|
||||
<parent id="0" type="" name="" />
|
||||
@ -6908,7 +6952,7 @@
|
||||
<billboard enabled="true" pos="-2.68524 2.09668 7.37274" size="4.97467 3.12653" uv="0 0 1 1" color="1 1 1 1" rot="14.0735" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="414" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="418" netflags="0" netdistance="0" groupflags="0">
|
||||
<component type="BillboardSet" netflags="0">
|
||||
<transform pos="72.1985 17.8156 -83.7524" rot="0 0 0" scale="1 1 1" />
|
||||
<parent id="0" type="" name="" />
|
||||
@ -6933,7 +6977,7 @@
|
||||
<billboard enabled="true" pos="-5.37689 3.41772 -3.95782" size="3.83221 3.22809" uv="0 0 1 1" color="1 1 1 1" rot="55.2612" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="415" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="419" netflags="0" netdistance="0" groupflags="0">
|
||||
<component type="BillboardSet" netflags="0">
|
||||
<transform pos="95.8008 19.7926 20.7397" rot="0 0 0" scale="1 1 1" />
|
||||
<parent id="0" type="" name="" />
|
||||
@ -6958,7 +7002,7 @@
|
||||
<billboard enabled="true" pos="-4.22195 1.47925 -1.55914" size="3.16589 3.29425" uv="0 0 1 1" color="1 1 1 1" rot="244.973" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="416" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="420" netflags="0" netdistance="0" groupflags="0">
|
||||
<component type="BillboardSet" netflags="0">
|
||||
<transform pos="-46.9299 12.7513 -7.33032" rot="0 0 0" scale="1 1 1" />
|
||||
<parent id="0" type="" name="" />
|
||||
@ -6983,7 +7027,7 @@
|
||||
<billboard enabled="true" pos="0.329132 -1.66455 6.67191" size="4.86145 4.42084" uv="0 0 1 1" color="1 1 1 1" rot="53.4705" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="417" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="421" netflags="0" netdistance="0" groupflags="0">
|
||||
<property hash="44830" type="Quaternion" value="0.809479 0.436766 0.3924 -0" sync="false" />
|
||||
<component type="Light" netflags="0">
|
||||
<transform pos="4.78821 53.898 22.7097" rot="45 63.9514 28.9965" scale="1 1 1" />
|
||||
@ -6999,7 +7043,7 @@
|
||||
<shapetexture name="" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="418" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="422" netflags="0" netdistance="0" groupflags="0">
|
||||
<property hash="44830" type="Quaternion" value="0.383172 0.922701 -0.0424472 0" sync="false" />
|
||||
<component type="Light" netflags="0">
|
||||
<transform pos="-27.9099 44.8636 70.7199" rot="45 -177.363 -173.64" scale="1 1 1" />
|
||||
@ -7015,7 +7059,7 @@
|
||||
<shapetexture name="" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="419" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="423" netflags="0" netdistance="0" groupflags="0">
|
||||
<property hash="44830" type="Quaternion" value="0.632069 0.559358 0.536289 -0" sync="false" />
|
||||
<component type="Light" netflags="0">
|
||||
<transform pos="-16.4063 40.9113 74.6521" rot="45 106.512 58.0452" scale="1 1 1" />
|
||||
@ -7031,7 +7075,7 @@
|
||||
<shapetexture name="" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="420" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="424" netflags="0" netdistance="0" groupflags="0">
|
||||
<property hash="44830" type="Quaternion" value="0.672071 0.526065 0.521129 -0" sync="false" />
|
||||
<component type="Light" netflags="0">
|
||||
<transform pos="-21.9131 49.9155 -22.3206" rot="45 97.8552 50.842" scale="1 1 1" />
|
||||
@ -7047,7 +7091,7 @@
|
||||
<shapetexture name="" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="421" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="425" netflags="0" netdistance="0" groupflags="0">
|
||||
<property hash="44830" type="Quaternion" value="0.915743 0.386084 0.111153 -0" sync="false" />
|
||||
<component type="Light" netflags="0">
|
||||
<transform pos="19.1208 34.5978 58.0765" rot="45 16.7322 6.97176" scale="1 1 1" />
|
||||
@ -7063,7 +7107,7 @@
|
||||
<shapetexture name="" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="422" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="426" netflags="0" netdistance="0" groupflags="0">
|
||||
<property hash="44830" type="Quaternion" value="0.499425 0.707921 0.499422 -0" sync="false" />
|
||||
<component type="Light" netflags="0">
|
||||
<transform pos="48.5046 52.8479 57.5912" rot="45 135.132 90.1867" scale="1 1 1" />
|
||||
@ -7079,7 +7123,7 @@
|
||||
<shapetexture name="" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="423" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="427" netflags="0" netdistance="0" groupflags="0">
|
||||
<property hash="44830" type="Quaternion" value="0.796545 0.443858 0.410494 -0" sync="false" />
|
||||
<component type="Light" netflags="0">
|
||||
<transform pos="52.9587 56.7654 43.2312" rot="45 67.6428 31.0204" scale="1 1 1" />
|
||||
@ -7095,7 +7139,7 @@
|
||||
<shapetexture name="" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="424" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="428" netflags="0" netdistance="0" groupflags="0">
|
||||
<property hash="44830" type="Quaternion" value="0.440873 0.801939 -0.403143 0" sync="false" />
|
||||
<component type="Light" netflags="0">
|
||||
<transform pos="-5.4245 33.0139 -50.7889" rot="45 -149.821 -113.877" scale="1 1 1" />
|
||||
@ -7111,7 +7155,7 @@
|
||||
<shapetexture name="" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="425" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="429" netflags="0" netdistance="0" groupflags="0">
|
||||
<property hash="44830" type="Quaternion" value="0.91203 0.387655 -0.133881 0" sync="false" />
|
||||
<component type="Light" netflags="0">
|
||||
<transform pos="-21.7255 37.9651 51.6174" rot="45 -20.2038 -8.44122" scale="1 1 1" />
|
||||
@ -7127,7 +7171,7 @@
|
||||
<shapetexture name="" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="426" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="430" netflags="0" netdistance="0" groupflags="0">
|
||||
<property hash="44830" type="Quaternion" value="0.632532 0.558949 -0.53617 0" sync="false" />
|
||||
<component type="Light" netflags="0">
|
||||
<transform pos="10.8856 42.9465 63.0981" rot="45 -106.414 -57.9578" scale="1 1 1" />
|
||||
@ -7143,7 +7187,7 @@
|
||||
<shapetexture name="" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="427" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="431" netflags="0" netdistance="0" groupflags="0">
|
||||
<property hash="44830" type="Quaternion" value="0.731892 0.483068 0.480603 -0" sync="false" />
|
||||
<component type="Light" netflags="0">
|
||||
<transform pos="-68.7561 43.3301 -29.2236" rot="45 84.2102 41.0455" scale="1 1 1" />
|
||||
@ -7159,7 +7203,7 @@
|
||||
<shapetexture name="" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="428" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="432" netflags="0" netdistance="0" groupflags="0">
|
||||
<property hash="44830" type="Quaternion" value="0.803278 0.440138 0.401277 -0" sync="false" />
|
||||
<component type="Light" netflags="0">
|
||||
<transform pos="56.9595 56.5768 -43.721" rot="45 65.7422 29.9702" scale="1 1 1" />
|
||||
@ -7175,7 +7219,7 @@
|
||||
<shapetexture name="" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="429" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="433" netflags="0" netdistance="0" groupflags="0">
|
||||
<property hash="44830" type="Quaternion" value="0.54353 0.650477 0.530524 -0" sync="false" />
|
||||
<component type="Light" netflags="0">
|
||||
<transform pos="36.7722 57.6196 49.0997" rot="45 125.354 77.4407" scale="1 1 1" />
|
||||
@ -7191,7 +7235,7 @@
|
||||
<shapetexture name="" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="430" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="434" netflags="0" netdistance="0" groupflags="0">
|
||||
<property hash="44830" type="Quaternion" value="0.407388 0.867854 0.284367 -0" sync="false" />
|
||||
<component type="Light" netflags="0">
|
||||
<transform pos="-53.5309 59.3408 55.2933" rot="45 160.873 135.731" scale="1 1 1" />
|
||||
@ -7207,7 +7251,7 @@
|
||||
<shapetexture name="" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="431" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="435" netflags="0" netdistance="0" groupflags="0">
|
||||
<property hash="44830" type="Quaternion" value="0.884829 0.399572 -0.239622 0" sync="false" />
|
||||
<component type="Light" netflags="0">
|
||||
<transform pos="-8.4549 41.4111 -28.5141" rot="45 -36.8481 -15.7126" scale="1 1 1" />
|
||||
@ -7223,7 +7267,7 @@
|
||||
<shapetexture name="" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="432" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="436" netflags="0" netdistance="0" groupflags="0">
|
||||
<property hash="44830" type="Quaternion" value="0.679191 0.520551 0.517423 -0" sync="false" />
|
||||
<component type="Light" netflags="0">
|
||||
<transform pos="-33.2108 49.4943 16.3101" rot="45 96.2842 49.6252" scale="1 1 1" />
|
||||
@ -7239,7 +7283,7 @@
|
||||
<shapetexture name="" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="433" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="437" netflags="0" netdistance="0" groupflags="0">
|
||||
<property hash="44830" type="Quaternion" value="0.508116 0.695813 -0.507605 0" sync="false" />
|
||||
<component type="Light" netflags="0">
|
||||
<transform pos="-10.8444 45.6335 -41.8854" rot="45 -133.154 -87.4314" scale="1 1 1" />
|
||||
@ -7255,7 +7299,7 @@
|
||||
<shapetexture name="" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="434" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="438" netflags="0" netdistance="0" groupflags="0">
|
||||
<property hash="44830" type="Quaternion" value="0.76716 0.46086 -0.446177 0" sync="false" />
|
||||
<component type="Light" netflags="0">
|
||||
<transform pos="-25.415 35.0858 19.0567" rot="45 -75.4981 -35.5628" scale="1 1 1" />
|
||||
@ -7271,7 +7315,7 @@
|
||||
<shapetexture name="" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="435" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="439" netflags="0" netdistance="0" groupflags="0">
|
||||
<property hash="44830" type="Quaternion" value="0.85721 0.412447 0.308349 -0" sync="false" />
|
||||
<component type="Light" netflags="0">
|
||||
<transform pos="52.2537 37.6208 -48.1796" rot="45 48.3838 21.0826" scale="1 1 1" />
|
||||
@ -7287,7 +7331,7 @@
|
||||
<shapetexture name="" />
|
||||
</component>
|
||||
</entity>
|
||||
<entity id="436" netflags="0" netdistance="0" groupflags="0">
|
||||
<entity id="440" netflags="0" netdistance="0" groupflags="0">
|
||||
<property hash="44830" type="Quaternion" value="0.891534 0.396568 -0.218865 0" sync="false" />
|
||||
<component type="Light" netflags="0">
|
||||
<transform pos="64.9155 47.5919 -2.99835" rot="45 -33.4973 -14.2109" scale="1 1 1" />
|
||||
|
@ -35,7 +35,7 @@
|
||||
<MouseSensitivity>0.125</MouseSensitivity>
|
||||
</Controls>
|
||||
<Game>
|
||||
<LevelName>TestLevel.xml</LevelName>
|
||||
<LevelName>NinjaSnowWarScene.xml</LevelName>
|
||||
<PlayerHealth>20</PlayerHealth>
|
||||
<PlayerStart>0 90 0</PlayerStart>
|
||||
<Enemies>5</Enemies>
|
||||
|
@ -91,7 +91,7 @@ void initScene()
|
||||
engine.setDefaultScene(gameScene);
|
||||
engine.setDefaultScriptFile(scriptFile);
|
||||
|
||||
File@ levelFile = cache.getFile("TestLevel.xml");
|
||||
File@ levelFile = cache.getFile("NinjaSnowWarScene.xml");
|
||||
gameScene.loadXML(levelFile);
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,8 @@
|
||||
DebugHud::DebugHud(Engine* engine) :
|
||||
mEngine(engine),
|
||||
mProfilerInterval(1.0f),
|
||||
mProfilerTimer(0.0f)
|
||||
mProfilerTimer(0.0f),
|
||||
mUsePipelineStats(false)
|
||||
{
|
||||
if (!mEngine)
|
||||
EXCEPTION("Null Engine for Debug HUD");
|
||||
@ -87,6 +88,18 @@ void DebugHud::update(float timeStep)
|
||||
if ((!pipeline) || (!renderer))
|
||||
return;
|
||||
|
||||
unsigned primitives, batches;
|
||||
if (!mUsePipelineStats)
|
||||
{
|
||||
primitives = renderer->getNumPrimitives();
|
||||
batches = renderer->getNumBatches();
|
||||
}
|
||||
else
|
||||
{
|
||||
primitives = pipeline->getNumPrimitives();
|
||||
batches = pipeline->getNumBatches();
|
||||
}
|
||||
|
||||
if (mStatsText->isVisible())
|
||||
{
|
||||
std::string stats =
|
||||
@ -226,6 +239,11 @@ void DebugHud::setProfilerInterval(float interval)
|
||||
mProfilerInterval = max(interval, 0.0f);
|
||||
}
|
||||
|
||||
void DebugHud::setUsePipelineStats(bool enable)
|
||||
{
|
||||
mUsePipelineStats = enable;
|
||||
}
|
||||
|
||||
void DebugHud::toggle(unsigned mode)
|
||||
{
|
||||
setMode(getMode() ^ mode);
|
||||
|
@ -53,6 +53,8 @@ public:
|
||||
void setMode(unsigned mode);
|
||||
//! Set profiler accumulation interval
|
||||
void setProfilerInterval(float interval);
|
||||
//! Set whether to show 3D geometry primitive/batch count only. Default false
|
||||
void setUsePipelineStats(bool enable);
|
||||
//! Toggle elements
|
||||
void toggle(unsigned mode);
|
||||
//! Toggle all elements
|
||||
@ -70,6 +72,8 @@ public:
|
||||
unsigned getMode() const;
|
||||
//! Return profiler accumulation interval
|
||||
float getProfilerInterval() const { return mProfilerInterval; }
|
||||
//! Return whether showing 3D geometry primitive/batch count only
|
||||
bool getUsePipelineStats() const { return mUsePipelineStats; }
|
||||
|
||||
private:
|
||||
//! Engine
|
||||
@ -86,6 +90,8 @@ private:
|
||||
float mProfilerInterval;
|
||||
//! Profiler accumulation timer
|
||||
float mProfilerTimer;
|
||||
//! Show 3D geometry primitive/batch count flag
|
||||
bool mUsePipelineStats;
|
||||
};
|
||||
|
||||
DebugHud* getDebugHud();
|
||||
|
@ -573,9 +573,6 @@ static int SystemRun(const std::string& fileName, CScriptArray* srcArguments)
|
||||
for (unsigned i = 0; i < numArguments; ++i)
|
||||
destArguments[i] = *(static_cast<std::string*>(srcArguments->At(i)));
|
||||
|
||||
LOGINFO("Systemrun: " + fileName);
|
||||
for (unsigned i = 0; i < destArguments.size(); ++i)
|
||||
LOGINFO(destArguments[i]);
|
||||
return systemRun(fileName, destArguments);
|
||||
}
|
||||
|
||||
|
@ -402,6 +402,7 @@ static void registerDebugHud(asIScriptEngine* engine)
|
||||
engine->RegisterObjectMethod("DebugHud", "void setStyle(XMLFile@+)", asMETHOD(DebugHud, setStyle), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("DebugHud", "void setMode(uint)", asMETHOD(DebugHud, setMode), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("DebugHud", "void setProfilerInterval(float)", asMETHOD(DebugHud, setProfilerInterval), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("DebugHud", "void setUsePipelineStats(bool)", asMETHOD(DebugHud, setUsePipelineStats), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("DebugHud", "void toggle(uint)", asMETHOD(DebugHud, toggle), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("DebugHud", "void toggleAll()", asMETHOD(DebugHud, toggleAll), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("DebugHud", "XMLFile@+ getStyle() const", asMETHOD(DebugHud, getStyle), asCALL_THISCALL);
|
||||
|
@ -915,6 +915,8 @@ static void registerPipeline(asIScriptEngine* engine)
|
||||
engine->RegisterObjectMethod("Pipeline", "int getOcclusionBufferSize() const", asMETHOD(Pipeline, getOcclusionBufferSize), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("Pipeline", "float getOccluderSizeThreshold() const", asMETHOD(Pipeline, getOccluderSizeThreshold), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("Pipeline", "const EdgeFilterParameters& getEdgeFilter() const", asMETHOD(Pipeline, getEdgeFilter), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("Pipeline", "uint getNumPrimitives() const", asMETHOD(Pipeline, getNumPrimitives), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("Pipeline", "uint getNumBatches() const", asMETHOD(Pipeline, getNumBatches), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("Pipeline", "uint getNumViews() const", asMETHOD(Pipeline, getNumViews), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("Pipeline", "uint getNumGeometries(bool) const", asMETHOD(Pipeline, getNumGeometries), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("Pipeline", "uint getNumLights(bool) const", asMETHOD(Pipeline, getNumLights), asCALL_THISCALL);
|
||||
|
@ -25,6 +25,7 @@
|
||||
#define PHYSICS_COLLISIONSHAPE_H
|
||||
|
||||
#include "BoundingBox.h"
|
||||
#include "EventListener.h"
|
||||
#include "Quaternion.h"
|
||||
#include "PhysicsDefs.h"
|
||||
#include "Resource.h"
|
||||
@ -122,7 +123,7 @@ struct CollisionSubShape
|
||||
};
|
||||
|
||||
//! Physics collision shape resource
|
||||
class CollisionShape : public Resource
|
||||
class CollisionShape : public Resource, public EventListener
|
||||
{
|
||||
DEFINE_TYPE(CollisionShape);
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "PhysicsWorld.h"
|
||||
#include "ReplicationUtils.h"
|
||||
#include "ResourceCache.h"
|
||||
#include "ResourceEvents.h"
|
||||
#include "RigidBody.h"
|
||||
#include "StringUtils.h"
|
||||
#include "XMLElement.h"
|
||||
@ -441,6 +442,18 @@ void RigidBody::setCollisionShape(CollisionShape* shape)
|
||||
if (shape == mCollisionShape)
|
||||
return;
|
||||
|
||||
// Unsubscribe from the reload event of previous collision shape (if any), then subscribe to the new
|
||||
if (mCollisionShape)
|
||||
{
|
||||
unsubscribeFromEvent(mCollisionShape, EVENT_RELOADSTARTED);
|
||||
unsubscribeFromEvent(mCollisionShape, EVENT_RELOADFINISHED);
|
||||
}
|
||||
if (shape)
|
||||
{
|
||||
subscribeToEvent(shape, EVENT_RELOADSTARTED, EVENT_HANDLER(RigidBody, handleCollisionShapeReload));
|
||||
subscribeToEvent(shape, EVENT_RELOADFINISHED, EVENT_HANDLER(RigidBody, handleCollisionShapeReloadFinished));
|
||||
}
|
||||
|
||||
mCollisionShape = shape;
|
||||
updateGeometries();
|
||||
}
|
||||
@ -1149,3 +1162,13 @@ void RigidBody::setTempDisabled(bool disable)
|
||||
setActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
void RigidBody::handleCollisionShapeReload(StringHash eventType, VariantMap& eventData)
|
||||
{
|
||||
removeGeometries();
|
||||
}
|
||||
|
||||
void RigidBody::handleCollisionShapeReloadFinished(StringHash eventType, VariantMap& eventData)
|
||||
{
|
||||
updateGeometries();
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
#define PHYSICS_RIGIDBODY_H
|
||||
|
||||
#include "CollisionShape.h"
|
||||
#include "EventListener.h"
|
||||
#include "Node.h"
|
||||
#include "PhysicsDefs.h"
|
||||
|
||||
@ -42,7 +43,7 @@ enum PhysicsMode
|
||||
};
|
||||
|
||||
//! Rigid body scene node
|
||||
class RigidBody : public Node
|
||||
class RigidBody : public Node, public EventListener
|
||||
{
|
||||
DEFINE_TYPE(RigidBody);
|
||||
|
||||
@ -193,6 +194,10 @@ private:
|
||||
void updateMass();
|
||||
//! Set temporary disable for optimizing client-side prediction
|
||||
void setTempDisabled(bool disable);
|
||||
//! Handle collision shape reload start
|
||||
void handleCollisionShapeReload(StringHash eventType, VariantMap& eventData);
|
||||
//! Handle collision shape reload finished
|
||||
void handleCollisionShapeReloadFinished(StringHash eventType, VariantMap& eventData);
|
||||
|
||||
//! Physics world
|
||||
SharedPtr<PhysicsWorld> mWorld;
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "Renderer.h"
|
||||
#include "ReplicationUtils.h"
|
||||
#include "ResourceCache.h"
|
||||
#include "ResourceEvents.h"
|
||||
#include "Scene.h"
|
||||
#include "VertexBuffer.h"
|
||||
|
||||
@ -640,6 +641,12 @@ void AnimatedModel::setModel(Model* model)
|
||||
if (!model)
|
||||
return;
|
||||
|
||||
// Unsubscribe from the reload event of previous model (if any), then subscribe to the new
|
||||
if (mModel)
|
||||
unsubscribeFromEvent(mModel, EVENT_RELOADFINISHED);
|
||||
if (model)
|
||||
subscribeToEvent(model, EVENT_RELOADFINISHED, EVENT_HANDLER(AnimatedModel, handleModelReloadFinished));
|
||||
|
||||
mModel = model;
|
||||
|
||||
// Copy the subgeometry & LOD level structure
|
||||
@ -1302,3 +1309,10 @@ void AnimatedModel::removeExtraAnimations(const std::set<StringHash>& animations
|
||||
if (removedAny)
|
||||
markAnimationDirty();
|
||||
}
|
||||
|
||||
void AnimatedModel::handleModelReloadFinished(StringHash eventType, VariantMap& eventData)
|
||||
{
|
||||
Model* currentModel = mModel;
|
||||
mModel = 0; // Set null to allow to be re-set
|
||||
setModel(currentModel);
|
||||
}
|
||||
|
@ -171,6 +171,8 @@ private:
|
||||
void applyMorph(VertexBuffer* buffer, void* lockedMorphRange, const VertexBufferMorph& morph, float weight);
|
||||
//! Remove unnecessary animations after a load or network update
|
||||
void removeExtraAnimations(const std::set<StringHash>& animations);
|
||||
//! Handle model reload finished
|
||||
void handleModelReloadFinished(StringHash eventType, VariantMap& eventData);
|
||||
|
||||
//! Skeleton
|
||||
Skeleton mSkeleton;
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "Renderer.h"
|
||||
#include "ReplicationUtils.h"
|
||||
#include "ResourceCache.h"
|
||||
#include "ResourceEvents.h"
|
||||
#include "VertexBuffer.h"
|
||||
#include "XMLElement.h"
|
||||
|
||||
@ -555,6 +556,12 @@ void InstancedModel::setModel(Model* model)
|
||||
if (!model)
|
||||
return;
|
||||
|
||||
// Unsubscribe from the reload event of previous model (if any), then subscribe to the new
|
||||
if (mModel)
|
||||
unsubscribeFromEvent(mModel, EVENT_RELOADFINISHED);
|
||||
if (model)
|
||||
subscribeToEvent(model, EVENT_RELOADFINISHED, EVENT_HANDLER(InstancedModel, handleModelReloadFinished));
|
||||
|
||||
mModel = model;
|
||||
mOriginalGeometries.clear();
|
||||
|
||||
@ -1067,3 +1074,10 @@ void InstancedModel::calculateLodLevels()
|
||||
|
||||
mLodLevelsDirty = false;
|
||||
}
|
||||
|
||||
void InstancedModel::handleModelReloadFinished(StringHash eventType, VariantMap& eventData)
|
||||
{
|
||||
Model* currentModel = mModel;
|
||||
mModel = 0; // Set null to allow to be re-set
|
||||
setModel(currentModel);
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
#ifndef RENDERER_INSTANCEDMODEL_H
|
||||
#define RENDERER_INSTANCEDMODEL_H
|
||||
|
||||
#include "EventListener.h"
|
||||
#include "GeometryNode.h"
|
||||
#include "Matrix4x3.h"
|
||||
|
||||
@ -45,7 +46,7 @@ struct Instance
|
||||
};
|
||||
|
||||
//! Scene node that defines instanced geometry
|
||||
class InstancedModel : public GeometryNode
|
||||
class InstancedModel : public GeometryNode, public EventListener
|
||||
{
|
||||
DEFINE_TYPE(InstancedModel);
|
||||
|
||||
@ -147,6 +148,8 @@ private:
|
||||
void resetLodLevels();
|
||||
//! Choose LOD levels based on distance
|
||||
void calculateLodLevels();
|
||||
//! Handle model reload finished
|
||||
void handleModelReloadFinished(StringHash eventType, VariantMap& eventData);
|
||||
|
||||
//! Create a duplicated vertex buffer copy for instancing
|
||||
static const SharedPtr<VertexBuffer>& createInstanceVertexBuffer(VertexBuffer* original, unsigned instanceCount);
|
||||
|
@ -25,6 +25,7 @@
|
||||
#define RENDERER_MODEL_H
|
||||
|
||||
#include "BoundingBox.h"
|
||||
#include "EventListener.h"
|
||||
#include "Skeleton.h"
|
||||
#include "Resource.h"
|
||||
#include "SharedPtr.h"
|
||||
@ -64,7 +65,7 @@ struct ModelMorph
|
||||
};
|
||||
|
||||
//! Model resource
|
||||
class Model : public Resource
|
||||
class Model : public Resource, public EventListener
|
||||
{
|
||||
DEFINE_TYPE(Model);
|
||||
|
||||
|
@ -615,6 +615,8 @@ bool Pipeline::render()
|
||||
// If no views, just clear the screen
|
||||
if (!mNumViews)
|
||||
{
|
||||
mNumPrimitives = 0;
|
||||
mNumBatches = 0;
|
||||
mRenderer->setAlphaTest(false);
|
||||
mRenderer->setBlendMode(BLEND_REPLACE);
|
||||
mRenderer->setColorWrite(true);
|
||||
@ -635,6 +637,9 @@ bool Pipeline::render()
|
||||
mRenderer->setStencilTest(false);
|
||||
mRenderer->resetStreamFrequencies();
|
||||
|
||||
// Copy the number of batches & primitives from Renderer so that we can account for 3D geometry only
|
||||
mNumPrimitives = mRenderer->getNumPrimitives();
|
||||
mNumBatches = mRenderer->getNumBatches();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -161,6 +161,10 @@ public:
|
||||
const EdgeFilterParameters& getEdgeFilter() const { return mEdgeFilter; }
|
||||
//! Return number of views rendered
|
||||
unsigned getNumViews() const { return mNumViews; }
|
||||
//! Return number of primitives rendered
|
||||
unsigned getNumPrimitives() const { return mNumPrimitives; }
|
||||
//! Return number of batches rendered
|
||||
unsigned getNumBatches() const { return mNumBatches; }
|
||||
//! Return number of geometries rendered
|
||||
unsigned getNumGeometries(bool allViews = false) const;
|
||||
//! Return number of lights rendered
|
||||
@ -293,6 +297,10 @@ private:
|
||||
unsigned mNumViews;
|
||||
//! Number of split lights
|
||||
unsigned mNumSplitLights;
|
||||
//! Number of primitives (3D geometry only)
|
||||
unsigned mNumPrimitives;
|
||||
//! Number of batches (3D geometry only)
|
||||
unsigned mNumBatches;
|
||||
//! Elapsed time
|
||||
float mElapsedTime;
|
||||
//! Specular lighting flag
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "Profiler.h"
|
||||
#include "ReplicationUtils.h"
|
||||
#include "ResourceCache.h"
|
||||
#include "ResourceEvents.h"
|
||||
#include "StaticModel.h"
|
||||
#include "XMLElement.h"
|
||||
|
||||
@ -320,6 +321,12 @@ void StaticModel::setModel(Model* model)
|
||||
if (!model)
|
||||
return;
|
||||
|
||||
// Unsubscribe from the reload event of previous model (if any), then subscribe to the new
|
||||
if (mModel)
|
||||
unsubscribeFromEvent(mModel, EVENT_RELOADFINISHED);
|
||||
if (model)
|
||||
subscribeToEvent(model, EVENT_RELOADFINISHED, EVENT_HANDLER(StaticModel, handleModelReloadFinished));
|
||||
|
||||
mModel = model;
|
||||
|
||||
// Copy the subgeometry & LOD level structure
|
||||
@ -403,3 +410,10 @@ void StaticModel::calculateLodLevels()
|
||||
|
||||
mLodLevelsDirty = false;
|
||||
}
|
||||
|
||||
void StaticModel::handleModelReloadFinished(StringHash eventType, VariantMap& eventData)
|
||||
{
|
||||
Model* currentModel = mModel;
|
||||
mModel = 0; // Set null to allow to be re-set
|
||||
setModel(currentModel);
|
||||
}
|
||||
|
@ -24,12 +24,13 @@
|
||||
#ifndef RENDERER_STATICMODEL_H
|
||||
#define RENDERER_STATICMODEL_H
|
||||
|
||||
#include "EventListener.h"
|
||||
#include "GeometryNode.h"
|
||||
|
||||
class Model;
|
||||
|
||||
//! A static model scene node
|
||||
class StaticModel : public GeometryNode
|
||||
class StaticModel : public GeometryNode, public EventListener
|
||||
{
|
||||
DEFINE_TYPE(StaticModel);
|
||||
|
||||
@ -107,6 +108,10 @@ protected:
|
||||
BoundingBox mBoundingBox;
|
||||
//! Model
|
||||
SharedPtr<Model> mModel;
|
||||
|
||||
private:
|
||||
//! Handle model reload finished
|
||||
void handleModelReloadFinished(StringHash eventType, VariantMap& eventData);
|
||||
};
|
||||
|
||||
#endif // RENDERER_STATICMODEL_H
|
||||
|
@ -24,6 +24,7 @@
|
||||
#ifndef RESOURCE_RESOURCE_H
|
||||
#define RESOURCE_RESOURCE_H
|
||||
|
||||
#include "EventListener.h"
|
||||
#include "HashedType.h"
|
||||
#include "Timer.h"
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "Log.h"
|
||||
#include "PackageFile.h"
|
||||
#include "ResourceCache.h"
|
||||
#include "ResourceEvents.h"
|
||||
#include "ResourceFactory.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
@ -269,16 +270,29 @@ bool ResourceCache::reloadResource(Resource* resource)
|
||||
if (!resource)
|
||||
return false;
|
||||
|
||||
// Some resources are event senders/listeners, and can notify that they are being reloaded
|
||||
EventListener* listener = dynamic_cast<EventListener*>(resource);
|
||||
|
||||
try
|
||||
{
|
||||
if (listener)
|
||||
listener->sendEvent(EVENT_RELOADSTARTED);
|
||||
|
||||
SharedPtr<File> file = getFile(resource->getName());
|
||||
resource->load(*(file.getPtr()), this);
|
||||
resource->resetUseTimer();
|
||||
updateResourceGroup(resource->getType());
|
||||
|
||||
if (listener)
|
||||
listener->sendEvent(EVENT_RELOADFINISHED);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (listener)
|
||||
listener->sendEvent(EVENT_RELOADFAILED);
|
||||
|
||||
releaseResource(resource->getType(), resource->getNameHash());
|
||||
return false;
|
||||
}
|
||||
|
44
Engine/Resource/ResourceEvents.h
Normal file
44
Engine/Resource/ResourceEvents.h
Normal file
@ -0,0 +1,44 @@
|
||||
//
|
||||
// Urho3D Engine
|
||||
// Copyright (c) 2008-2011 Lasse Öörni
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
#ifndef RESOURCE_RESOURCEVENTS_H
|
||||
#define RESOURCE_RESOURCEVENTS_H
|
||||
|
||||
#include "Event.h"
|
||||
|
||||
//! Resource reloading started
|
||||
DEFINE_EVENT(EVENT_RELOADSTARTED, ReloadStarted)
|
||||
{
|
||||
}
|
||||
|
||||
//! Resource reloading finished successfully
|
||||
DEFINE_EVENT(EVENT_RELOADFINISHED, ReloadFinished)
|
||||
{
|
||||
}
|
||||
|
||||
//! Resource reloading failed
|
||||
DEFINE_EVENT(EVENT_RELOADFAILED, ReloadFailed)
|
||||
{
|
||||
}
|
||||
|
||||
#endif // RESOURCE_RESOURCEVENTS_H
|
@ -53,6 +53,8 @@ ScriptEngine::ScriptEngine() :
|
||||
mAngelScriptEngine->SetUserData(this);
|
||||
mAngelScriptEngine->SetEngineProperty(asEP_USE_CHARACTER_LITERALS, true);
|
||||
mAngelScriptEngine->SetEngineProperty(asEP_ALLOW_UNSAFE_REFERENCES, true);
|
||||
mAngelScriptEngine->SetEngineProperty(asEP_ALLOW_IMPLICIT_HANDLE_TYPES, true);
|
||||
mAngelScriptEngine->SetEngineProperty(asEP_BUILD_WITHOUT_LINE_CUES, true);
|
||||
mAngelScriptEngine->SetMessageCallback(asFUNCTION(messageCallback), this, asCALL_CDECL);
|
||||
|
||||
// Register the array and string types, but leave it for the script engine instantiator to install the rest of the API
|
||||
|
@ -60,10 +60,6 @@ void ScriptFile::load(Deserializer& source, ResourceCache* cache)
|
||||
{
|
||||
PROFILE(Script_Load);
|
||||
|
||||
// If script instances have created objects from this file, release them now
|
||||
// Make a copy of the vector because the script instances will remove themselves from the member vector
|
||||
std::vector<ScriptInstance*> instances = mScriptInstances;
|
||||
|
||||
releaseModule();
|
||||
|
||||
// Create the module. Discard previous module if there was one
|
||||
@ -91,10 +87,6 @@ void ScriptFile::load(Deserializer& source, ResourceCache* cache)
|
||||
LOGINFO("Compiled script module " + getName());
|
||||
mCompiled = true;
|
||||
moduleToFile[mScriptModule] = this;
|
||||
|
||||
// Now let the script instances recreate their objects
|
||||
for (std::vector<ScriptInstance*>::iterator i = instances.begin(); i != instances.end(); ++i)
|
||||
(*i)->createObject();
|
||||
}
|
||||
|
||||
void ScriptFile::addEventHandler(StringHash eventType, const std::string& handlerName)
|
||||
@ -330,23 +322,6 @@ asIScriptFunction* ScriptFile::getMethod(asIScriptObject* object, const std::str
|
||||
return function;
|
||||
}
|
||||
|
||||
void ScriptFile::addScriptInstance(ScriptInstance* instance)
|
||||
{
|
||||
mScriptInstances.push_back(instance);
|
||||
}
|
||||
|
||||
void ScriptFile::removeScriptInstance(ScriptInstance* instance)
|
||||
{
|
||||
for (std::vector<ScriptInstance*>::iterator i = mScriptInstances.begin(); i != mScriptInstances.end(); ++i)
|
||||
{
|
||||
if ((*i) == instance)
|
||||
{
|
||||
mScriptInstances.erase(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptFile::addScriptSection(asIScriptEngine* engine, Deserializer& source, ResourceCache* cache)
|
||||
{
|
||||
unsigned dataSize = source.getSize();
|
||||
@ -523,11 +498,6 @@ void ScriptFile::releaseModule()
|
||||
{
|
||||
if (mScriptModule)
|
||||
{
|
||||
// Release script instances if any exist
|
||||
std::vector<ScriptInstance*> instances = mScriptInstances;
|
||||
for (std::vector<ScriptInstance*>::iterator i = instances.begin(); i != instances.end(); ++i)
|
||||
(*i)->releaseObject();
|
||||
|
||||
// Clear search caches, event handlers and function-to-file mappings
|
||||
mAllIncludeFiles.clear();
|
||||
mCheckedClasses.clear();
|
||||
|
@ -84,11 +84,6 @@ public:
|
||||
//! Return whether script compiled successfully
|
||||
bool isCompiled() const { return mCompiled; }
|
||||
|
||||
//! Add script instance to keep track of in case of script reload
|
||||
void addScriptInstance(ScriptInstance* instance);
|
||||
//! Remove script instance to keep track of
|
||||
void removeScriptInstance(ScriptInstance* instance);
|
||||
|
||||
private:
|
||||
//! Add a script section, checking for includes recursively
|
||||
void addScriptSection(asIScriptEngine* engine, Deserializer& source, ResourceCache* cache);
|
||||
@ -113,8 +108,6 @@ private:
|
||||
std::map<std::string, asIScriptFunction*> mFunctions;
|
||||
//! Search cache for methods
|
||||
std::map<asIObjectType*, std::map<std::string, asIScriptFunction*> > mMethods;
|
||||
//! ScriptInstances that have created objects from this script file
|
||||
std::vector<ScriptInstance*> mScriptInstances;
|
||||
};
|
||||
|
||||
//! Get currently executing script file
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "RegisterArray.h"
|
||||
#include "ReplicationUtils.h"
|
||||
#include "ResourceCache.h"
|
||||
#include "ResourceEvents.h"
|
||||
#include "Scene.h"
|
||||
#include "SceneEvents.h"
|
||||
#include "ScriptEngine.h"
|
||||
@ -360,6 +361,18 @@ bool ScriptInstance::setScriptClass(ScriptFile* scriptFile, const std::string& c
|
||||
|
||||
releaseObject();
|
||||
|
||||
// Unsubscribe from the reload event of previous script file (if any), then subscribe to the new
|
||||
if (mScriptFile)
|
||||
{
|
||||
unsubscribeFromEvent(mScriptFile, EVENT_RELOADSTARTED);
|
||||
unsubscribeFromEvent(mScriptFile, EVENT_RELOADFINISHED);
|
||||
}
|
||||
if (scriptFile)
|
||||
{
|
||||
subscribeToEvent(scriptFile, EVENT_RELOADSTARTED, EVENT_HANDLER(ScriptInstance, handleScriptFileReload));
|
||||
subscribeToEvent(scriptFile, EVENT_RELOADFINISHED, EVENT_HANDLER(ScriptInstance, handleScriptFileReloadFinished));
|
||||
}
|
||||
|
||||
mScriptFile = scriptFile;
|
||||
mClassName = className;
|
||||
|
||||
@ -484,7 +497,6 @@ bool ScriptInstance::createObject()
|
||||
mScriptObject = mScriptFile->createObject(mClassName);
|
||||
if (mScriptObject)
|
||||
{
|
||||
mScriptFile->addScriptInstance(this);
|
||||
objectToInstance[(void*)mScriptObject] = this;
|
||||
getSupportedMethods();
|
||||
if (mMethods[METHOD_START])
|
||||
@ -514,8 +526,6 @@ void ScriptInstance::releaseObject()
|
||||
mScriptObject = 0;
|
||||
|
||||
objectToInstance.erase((void*)mScriptObject);
|
||||
|
||||
mScriptFile->removeScriptInstance(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -701,3 +711,14 @@ ScriptEventListener* getScriptContextEventListener()
|
||||
ScriptFile* file = getScriptContextFile();
|
||||
return file;
|
||||
}
|
||||
|
||||
void ScriptInstance::handleScriptFileReload(StringHash eventType, VariantMap& eventData)
|
||||
{
|
||||
releaseObject();
|
||||
}
|
||||
|
||||
void ScriptInstance::handleScriptFileReloadFinished(StringHash eventType, VariantMap& eventData)
|
||||
{
|
||||
if (!mClassName.empty())
|
||||
createObject();
|
||||
}
|
||||
|
@ -158,6 +158,10 @@ private:
|
||||
void handlePhysicsPostStep(StringHash eventType, VariantMap& eventData);
|
||||
//! Handle an event in script
|
||||
void handleScriptEvent(StringHash eventType, VariantMap& eventData);
|
||||
//! Handle script file reload start
|
||||
void handleScriptFileReload(StringHash eventType, VariantMap& eventData);
|
||||
//! Handle script file reload finished
|
||||
void handleScriptFileReloadFinished(StringHash eventType, VariantMap& eventData);
|
||||
|
||||
//! Script engine
|
||||
SharedPtr<ScriptEngine> mScriptEngine;
|
||||
|
@ -132,7 +132,7 @@ void getMeshesUnderNode(std::vector<std::pair<aiNode*, aiMesh*> >& meshes, aiNod
|
||||
unsigned getMeshIndex(aiMesh* mesh);
|
||||
unsigned getBoneIndex(ExportModel& model, const std::string& boneName);
|
||||
aiBone* getMeshBone(ExportModel& model, const std::string& boneName);
|
||||
Matrix4x3 getOffsetMatrix(ExportModel& model, const std::string& boneName, bool useMeshTransform);
|
||||
Matrix4x3 getOffsetMatrix(ExportModel& model, const std::string& boneName);
|
||||
void getBlendData(ExportModel& model, aiMesh* mesh, std::vector<unsigned>& boneMappings, std::vector<std::vector<unsigned char> >&
|
||||
blendIndices, std::vector<std::vector<float> >& blendWeights);
|
||||
std::string getMeshMaterialName(aiMesh* mesh);
|
||||
@ -147,6 +147,7 @@ unsigned getElementMask(aiMesh* mesh);
|
||||
aiNode* findNode(const std::string& name, aiNode* rootNode, bool caseSensitive = true);
|
||||
aiMatrix4x4 getDerivedTransform(aiNode* node, aiNode* rootNode);
|
||||
aiMatrix4x4 getDerivedTransform(aiMatrix4x4 transform, aiNode* node, aiNode* rootNode);
|
||||
aiMatrix4x4 getMeshBakingTransform(aiNode* meshNode, aiNode* modelRootNode);
|
||||
void getPosRotScale(const aiMatrix4x4& transform, Vector3& pos, Quaternion& rot, Vector3& scale);
|
||||
|
||||
std::string toStdString(const aiString& str);
|
||||
@ -440,7 +441,7 @@ void dumpNodes(aiNode* rootNode, unsigned level)
|
||||
|
||||
Vector3 pos, scale;
|
||||
Quaternion rot;
|
||||
aiMatrix4x4 transform = getDerivedTransform(rootNode, 0);
|
||||
aiMatrix4x4 transform = getDerivedTransform(rootNode, gRootNode);
|
||||
getPosRotScale(transform, pos, rot, scale);
|
||||
|
||||
std::cout << indent << "Node " << toStdString(rootNode->mName) << " pos " << toString(pos) << std::endl;
|
||||
@ -683,14 +684,12 @@ void buildAndSaveModel(ExportModel& model)
|
||||
std::cout << "Writing separate buffers" << std::endl;
|
||||
for (unsigned i = 0; i < model.mMeshes.size(); ++i)
|
||||
{
|
||||
// Get the world transform of the mesh for baking into the vertices (model mode only)
|
||||
// Get the world transform of the mesh for baking into the vertices
|
||||
Matrix4x3 vertexTransform;
|
||||
Matrix3 normalTransform;
|
||||
Vector3 pos(Vector3::sZero);
|
||||
Quaternion rot(Quaternion::sIdentity);
|
||||
Vector3 scale(Vector3::sUnity);
|
||||
if (gCommand == CMD_MODEL)
|
||||
getPosRotScale(getDerivedTransform(model.mMeshNodes[i], model.mRootNode), pos, rot, scale);
|
||||
Vector3 pos, scale;
|
||||
Quaternion rot;
|
||||
getPosRotScale(getMeshBakingTransform(model.mMeshNodes[i], model.mRootNode), pos, rot, scale);
|
||||
vertexTransform.define(pos, rot, scale);
|
||||
normalTransform = rot.getRotationMatrix();
|
||||
|
||||
@ -768,14 +767,12 @@ void buildAndSaveModel(ExportModel& model)
|
||||
|
||||
for (unsigned i = 0; i < model.mMeshes.size(); ++i)
|
||||
{
|
||||
// Get the world transform of the mesh for baking into the vertices (model mode only)
|
||||
// Get the world transform of the mesh for baking into the vertices
|
||||
Matrix4x3 vertexTransform;
|
||||
Matrix3 normalTransform;
|
||||
Vector3 pos(Vector3::sZero);
|
||||
Quaternion rot(Quaternion::sIdentity);
|
||||
Vector3 scale(Vector3::sUnity);
|
||||
if (gCommand == CMD_MODEL)
|
||||
getPosRotScale(getDerivedTransform(model.mMeshNodes[i], model.mRootNode), pos, rot, scale);
|
||||
Vector3 pos, scale;
|
||||
Quaternion rot;
|
||||
getPosRotScale(getMeshBakingTransform(model.mMeshNodes[i], model.mRootNode), pos, rot, scale);
|
||||
vertexTransform.define(pos, rot, scale);
|
||||
normalTransform = rot.getRotationMatrix();
|
||||
|
||||
@ -854,7 +851,7 @@ void buildAndSaveModel(ExportModel& model)
|
||||
getPosRotScale(transform, pos, rot, scale);
|
||||
|
||||
// Get offset information if exists
|
||||
srcBones[i]->setOffsetMatrix(getOffsetMatrix(model, boneName, gCommand == CMD_MODEL));
|
||||
srcBones[i]->setOffsetMatrix(getOffsetMatrix(model, boneName));
|
||||
|
||||
srcBones[i]->setInitialTransform(pos, rot, scale);
|
||||
srcBones[i]->setRadius(model.mBoneRadii[i]);
|
||||
@ -1155,7 +1152,7 @@ void buildAndSaveScene(ExportScene& scene)
|
||||
// Set a flattened transform
|
||||
Vector3 pos, scale;
|
||||
Quaternion rot;
|
||||
getPosRotScale(getDerivedTransform(scene.mNodes[i], 0), pos, rot, scale);
|
||||
getPosRotScale(getDerivedTransform(scene.mNodes[i], gRootNode), pos, rot, scale);
|
||||
staticModel->setTransform(pos, rot, scale);
|
||||
// Set materials if they are known
|
||||
for (unsigned j = 0; j < model.mMeshes.size(); ++j)
|
||||
@ -1409,7 +1406,7 @@ aiBone* getMeshBone(ExportModel& model, const std::string& boneName)
|
||||
return 0;
|
||||
}
|
||||
|
||||
Matrix4x3 getOffsetMatrix(ExportModel& model, const std::string& boneName, bool useMeshTransform)
|
||||
Matrix4x3 getOffsetMatrix(ExportModel& model, const std::string& boneName)
|
||||
{
|
||||
for (unsigned i = 0; i < model.mMeshes.size(); ++i)
|
||||
{
|
||||
@ -1421,12 +1418,9 @@ Matrix4x3 getOffsetMatrix(ExportModel& model, const std::string& boneName, bool
|
||||
if (toStdString(bone->mName) == boneName)
|
||||
{
|
||||
aiMatrix4x4 offset = bone->mOffsetMatrix;
|
||||
if (useMeshTransform)
|
||||
{
|
||||
aiMatrix4x4 nodeDerivedInverse = getDerivedTransform(node, model.mRootNode);
|
||||
nodeDerivedInverse.Inverse();
|
||||
offset *= nodeDerivedInverse;
|
||||
}
|
||||
aiMatrix4x4 nodeDerivedInverse = getMeshBakingTransform(node, model.mRootNode);
|
||||
nodeDerivedInverse.Inverse();
|
||||
offset *= nodeDerivedInverse;
|
||||
Matrix4x3 ret;
|
||||
memcpy(&ret.m00, &offset.a1, sizeof(Matrix4x3));
|
||||
return ret;
|
||||
@ -1645,6 +1639,14 @@ aiMatrix4x4 getDerivedTransform(aiMatrix4x4 transform, aiNode* node, aiNode* roo
|
||||
return transform;
|
||||
}
|
||||
|
||||
aiMatrix4x4 getMeshBakingTransform(aiNode* meshNode, aiNode* modelRootNode)
|
||||
{
|
||||
if (meshNode == modelRootNode)
|
||||
return aiMatrix4x4();
|
||||
else
|
||||
return getDerivedTransform(meshNode, modelRootNode);
|
||||
}
|
||||
|
||||
void getPosRotScale(const aiMatrix4x4& transform, Vector3& pos, Quaternion& rot, Vector3& scale)
|
||||
{
|
||||
aiVector3D aiPos;
|
||||
|
Loading…
Reference in New Issue
Block a user