| 850 | } |
| 851 | |
| 852 | bool TSShape::removeObject(const String& name) |
| 853 | { |
| 854 | // Find the object |
| 855 | S32 objIndex = findObject(name); |
| 856 | if (objIndex < 0) |
| 857 | { |
| 858 | Con::errorf("TSShape::removeObject: Could not find object '%s'", name.c_str()); |
| 859 | return false; |
| 860 | } |
| 861 | |
| 862 | // Need to make everything editable since node indexes etc will change |
| 863 | makeEditable(); |
| 864 | |
| 865 | // Destroy all meshes in the object |
| 866 | TSShape::Object& obj = objects[objIndex]; |
| 867 | while ( obj.numMeshes ) |
| 868 | { |
| 869 | destructInPlace(meshes[obj.startMeshIndex + obj.numMeshes - 1]); |
| 870 | removeMeshFromObject(objIndex, obj.numMeshes - 1); |
| 871 | } |
| 872 | |
| 873 | // Remove the object from the shape |
| 874 | objects.erase(objIndex); |
| 875 | S32 subShapeIndex = getSubShapeForObject(objIndex); |
| 876 | subShapeNumObjects[subShapeIndex]--; |
| 877 | for (S32 i = subShapeIndex + 1; i < subShapeFirstObject.size(); i++) |
| 878 | subShapeFirstObject[i]--; |
| 879 | |
| 880 | // Remove the object from all sequences |
| 881 | for (S32 i = 0; i < sequences.size(); i++) |
| 882 | { |
| 883 | TSShape::Sequence& seq = sequences[i]; |
| 884 | |
| 885 | TSIntegerSet objMatters(seq.frameMatters); |
| 886 | objMatters.overlap(seq.matFrameMatters); |
| 887 | objMatters.overlap(seq.visMatters); |
| 888 | |
| 889 | if (objMatters.test(objIndex)) |
| 890 | eraseStates(objectStates, objMatters, seq.baseObjectState, seq.numKeyframes, objIndex); |
| 891 | |
| 892 | seq.frameMatters.erase(objIndex); |
| 893 | seq.matFrameMatters.erase(objIndex); |
| 894 | seq.visMatters.erase(objIndex); |
| 895 | } |
| 896 | |
| 897 | // Remove the object name if it is no longer in use |
| 898 | removeName(name); |
| 899 | |
| 900 | // Update smallest visible detail |
| 901 | updateSmallestVisibleDL(); |
| 902 | |
| 903 | initObjects(); |
| 904 | |
| 905 | return true; |
| 906 | } |
| 907 | |
| 908 | //----------------------------------------------------------------------------- |
| 909 |
no test coverage detected