Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Revert "[MT] Fix some trees drawn even after the feature was destroyed"

This reverts commit 4cb30ed.
  • Loading branch information...
commit 3fc6ebb0496b2e82f8e6ac027de2e496f7ee69b8 1 parent 8155157
authored March 23, 2013
6  rts/Rendering/Env/ITreeDrawer.cpp
@@ -111,12 +111,12 @@ void ITreeDrawer::RenderFeatureMoved(const CFeature* feature, const float3& oldp
111 111
 	}
112 112
 }
113 113
 
114  
-void ITreeDrawer::RenderFeatureDestroyed(const CFeature* feature, const float3& pos) {
  114
+void ITreeDrawer::RenderFeatureDestroyed(const CFeature* feature) {
115 115
 	if (feature->def->drawType >= DRAWTYPE_TREE) {
116  
-		DeleteTree(pos);
  116
+		DeleteTree(feature->pos);
117 117
 
118 118
 		if (feature->speed.SqLength2D() > 0.25f) {
119  
-			AddFallingTree(pos, feature->speed, feature->def->drawType - 1);
  119
+			AddFallingTree(feature->pos, feature->speed, feature->def->drawType - 1);
120 120
 		}
121 121
 	}
122 122
 }
2  rts/Rendering/Env/ITreeDrawer.h
@@ -42,7 +42,7 @@ class ITreeDrawer : public CEventClient
42 42
 			(eventName == "RenderFeatureDestroyed");
43 43
 	}
44 44
 	void RenderFeatureMoved(const CFeature* feature, const float3& oldpos, const float3& newpos);
45  
-	void RenderFeatureDestroyed(const CFeature* feature, const float3& pos);
  45
+	void RenderFeatureDestroyed(const CFeature* feature);
46 46
 
47 47
 	std::vector<GLuint> delDispLists;
48 48
 
2  rts/Rendering/FeatureDrawer.cpp
@@ -111,7 +111,7 @@ void CFeatureDrawer::RenderFeatureCreated(const CFeature* feature)
111 111
 	}
112 112
 }
113 113
 
114  
-void CFeatureDrawer::RenderFeatureDestroyed(const CFeature* feature, const float3& pos)
  114
+void CFeatureDrawer::RenderFeatureDestroyed(const CFeature* feature)
115 115
 {
116 116
 	CFeature* f = const_cast<CFeature*>(feature);
117 117
 
2  rts/Rendering/FeatureDrawer.h
@@ -43,7 +43,7 @@ typedef std::map<int, FeatureSet>::iterator FeatureRenderBinIt;
43 43
 	int GetReadAllyTeam() const { return AllAccessTeam; }
44 44
 
45 45
 	virtual void RenderFeatureCreated(const CFeature* feature);
46  
-	virtual void RenderFeatureDestroyed(const CFeature* feature, const float3& pos);
  46
+	virtual void RenderFeatureDestroyed(const CFeature* feature);
47 47
 	virtual void RenderFeatureMoved(const CFeature* feature, const float3& oldpos, const float3& newpos);
48 48
 
49 49
 #ifdef USE_GML
2  rts/Rendering/Models/ModelDrawer.cpp
@@ -141,7 +141,7 @@ void IModelDrawer::RenderFeatureCreated(const CFeature* f)
141 141
 	#endif
142 142
 }
143 143
 
144  
-void IModelDrawer::RenderFeatureDestroyed(const CFeature* f, const float3& pos)
  144
+void IModelDrawer::RenderFeatureDestroyed(const CFeature* f)
145 145
 {
146 146
 	LOG_L(L_DEBUG, "[%s] id=%d", __FUNCTION__, f->id);
147 147
 
2  rts/Rendering/Models/ModelDrawer.h
@@ -30,7 +30,7 @@ class IModelDrawer: public CEventClient {
30 30
 	virtual void RenderUnitDestroyed(const CUnit* u);
31 31
 	virtual void RenderUnitCloakChanged(const CUnit* u, int cloaked);
32 32
 	virtual void RenderFeatureCreated(const CFeature* f);
33  
-	virtual void RenderFeatureDestroyed(const CFeature* f, const float3& pos);
  33
+	virtual void RenderFeatureDestroyed(const CFeature* f);
34 34
 	virtual void RenderProjectileCreated(const CProjectile* p);
35 35
 	virtual void RenderProjectileDestroyed(const CProjectile* p);
36 36
 
4  rts/System/EventBatchHandler.cpp
@@ -33,8 +33,8 @@ void EventBatchHandler::UnitCloakStateChangedEvent::Add(const UAD& u) { if(!u.un
33 33
 void EventBatchHandler::UnitLOSStateChangedEvent::Add(const UAD& u) { if(!u.unit->isDead) eventHandler.RenderUnitLOSChanged(u.unit, u.data, u.status); }
34 34
 void EventBatchHandler::UnitMovedEvent::Add(const UAP& u) { eventHandler.RenderUnitMoved(u.unit, u.newpos); }
35 35
 
36  
-void EventBatchHandler::FeatureCreatedDestroyedEvent::Add(const FP& f) { eventHandler.RenderFeatureCreated(f.feat); }
37  
-void EventBatchHandler::FeatureCreatedDestroyedEvent::Remove(const FP& f) { eventHandler.RenderFeatureDestroyed(f.feat, f.pos); }
  36
+void EventBatchHandler::FeatureCreatedDestroyedEvent::Add(const CFeature* f) { eventHandler.RenderFeatureCreated(f); }
  37
+void EventBatchHandler::FeatureCreatedDestroyedEvent::Remove(const CFeature* f) { eventHandler.RenderFeatureDestroyed(f); }
38 38
 void EventBatchHandler::FeatureMovedEvent::Add(const FAP& f) { eventHandler.RenderFeatureMoved(f.feat, f.oldpos, f.newpos); }
39 39
 
40 40
 EventBatchHandler* EventBatchHandler::GetInstance() {
55  rts/System/EventBatchHandler.h
@@ -22,7 +22,6 @@ struct EventBatchHandler {
22 22
 
23 23
 	typedef ThreadListRender<
24 24
 		const CProjectile*,
25  
-		const CProjectile*,
26 25
 		std::set<const CProjectile*>,
27 26
 		const CProjectile*,
28 27
 		ProjectileCreatedDestroyedEvent
@@ -37,23 +36,12 @@ struct EventBatchHandler {
37 36
 
38 37
 	typedef ThreadListRender<
39 38
 		const CProjectile*,
40  
-		const CProjectile*,
41 39
 		std::set<const CProjectile*>,
42 40
 		const CProjectile*,
43 41
 		UnsyncedProjectileCreatedDestroyedEvent
44 42
 	> UnsyncedProjectileCreatedDestroyedEventBatch;
45 43
 #endif
46 44
 
47  
-public:
48  
-	struct UD {
49  
-		const CUnit* unit;
50  
-		int data;
51  
-
52  
-		UD(const CUnit* u): unit(u), data(0) {}
53  
-		UD(const CUnit* u, int d): unit(u), data(d) {}
54  
-		bool operator==(const UD& u) const { return unit == u.unit; }
55  
-		bool operator<(const UD& u) const { return unit < u.unit; }
56  
-	};
57 45
 	struct UAD {
58 46
 		const CUnit* unit;
59 47
 		int data;
@@ -65,7 +53,16 @@ struct EventBatchHandler {
65 53
 		bool operator==(const CUnit* u) const { return unit == u; }
66 54
 		bool operator==(const UAD& u) const { return unit == u.unit && seqnum == u.seqnum; }
67 55
 		bool operator<(const UAD& u) const { return unit < u.unit || (unit == u.unit && seqnum < u.seqnum); }
  56
+	};
  57
+public:
  58
+	struct UD {
  59
+		const CUnit* unit;
  60
+		int data;
  61
+
  62
+		UD(const CUnit* u): unit(u), data(0) {}
  63
+		UD(const CUnit* u, int d): unit(u), data(d) {}
68 64
 		bool operator==(const UD& u) const { return unit == u.unit; }
  65
+		bool operator<(const UD& u) const { return unit < u.unit; }
69 66
 	};
70 67
 
71 68
 	struct UAP {
@@ -77,7 +74,6 @@ struct EventBatchHandler {
77 74
 		bool operator==(const CUnit* u) const { return unit == u; }
78 75
 		bool operator==(const UAP& u) const { return unit == u.unit && seqnum == u.seqnum; }
79 76
 		bool operator<(const UAP& u) const { return unit < u.unit || (unit == u.unit && seqnum < u.seqnum); }
80  
-		bool operator==(const UD& u) const { return unit == u.unit; }
81 77
 	};
82 78
 
83 79
 private:
@@ -105,25 +101,15 @@ struct EventBatchHandler {
105 101
 		static void Delete(const UAP&) { }
106 102
 	};
107 103
 
108  
-	typedef ThreadListRender<const CUnit *, const CUnit *, std::set<UD>, UD, UnitCreatedDestroyedEvent> UnitCreatedDestroyedEventBatch;
109  
-	typedef ThreadListRender<const CUnit *, UD, std::set<UAD>, UAD, UnitCloakStateChangedEvent> UnitCloakStateChangedEventBatch;
110  
-	typedef ThreadListRender<const CUnit *, UD, std::set<UAD>, UAD, UnitLOSStateChangedEvent> UnitLOSStateChangedEventBatch;
  104
+	typedef ThreadListRender<const CUnit *, std::set<UD>, UD, UnitCreatedDestroyedEvent> UnitCreatedDestroyedEventBatch;
  105
+	typedef ThreadListRender<const CUnit *, std::set<UAD>, UAD, UnitCloakStateChangedEvent> UnitCloakStateChangedEventBatch;
  106
+	typedef ThreadListRender<const CUnit *, std::set<UAD>, UAD, UnitLOSStateChangedEvent> UnitLOSStateChangedEventBatch;
111 107
 	typedef ThreadListRender<
112 108
 		const CUnit*,
113  
-		UD, 
114 109
 		std::set<UAP>,
115 110
 		UAP,
116 111
 		UnitMovedEvent
117 112
 	> UnitMovedEventBatch;
118  
-	struct FP {
119  
-		const CFeature* feat;
120  
-		float3 pos;
121  
-
122  
-		FP(const CFeature* f, const float3& p): feat(f), pos(p) {}
123  
-		bool operator==(const FP& f) const { return feat == f.feat; }
124  
-		bool operator<(const FP& f) const { return feat < f.feat; }
125  
-	};
126  
-
127 113
 	struct FAP {
128 114
 		const CFeature* feat;
129 115
 		boost::int64_t seqnum;
@@ -134,13 +120,12 @@ struct EventBatchHandler {
134 120
 		bool operator==(const CFeature* f) const { return feat == f; }
135 121
 		bool operator==(const FAP& f) const { return feat == f.feat && seqnum == f.seqnum; }
136 122
 		bool operator<(const FAP& f) const { return feat < f.feat || (feat == f.feat && seqnum < f.seqnum); }
137  
-		bool operator==(const FP& f) const { return feat == f.feat; }
138 123
 	};
139 124
 
140 125
 	struct FeatureCreatedDestroyedEvent {
141  
-		static void Add(const FP&);
142  
-		static void Remove(const FP&);
143  
-		static void Delete(const FP&) { }
  126
+		static void Add(const CFeature*);
  127
+		static void Remove(const CFeature*);
  128
+		static void Delete(const CFeature*) { }
144 129
 	};
145 130
 
146 131
 	struct FeatureMovedEvent {
@@ -151,14 +136,12 @@ struct EventBatchHandler {
151 136
 
152 137
 	typedef ThreadListRender<
153 138
 		const CFeature*,
  139
+		std::set<const CFeature*>,
154 140
 		const CFeature*,
155  
-		std::set<FP>,
156  
-		FP,
157 141
 		FeatureCreatedDestroyedEvent
158 142
 	> FeatureCreatedDestroyedEventBatch;
159 143
 	typedef ThreadListRender<
160 144
 		const CFeature*,
161  
-		FP,
162 145
 		std::set<FAP>,
163 146
 		FAP,
164 147
 		FeatureMovedEvent
@@ -208,12 +191,6 @@ struct EventBatchHandler {
208 191
 	void EnqueueUnitMovedEvent(const CUnit* unit, const float3& newpos) {
209 192
 		unitMovedEventBatch.enqueue(UAP(unit, newpos));
210 193
 	}
211  
-	void EnqueueFeatureCreatedEvent(const CFeature* feature, const float3& pos) {
212  
-		featureCreatedDestroyedEventBatch.enqueue(FP(feature, pos));
213  
-	}
214  
-	void EnqueueFeatureDestroyedEvent(const CFeature* feature, const float3& pos) {
215  
-		featureCreatedDestroyedEventBatch.dequeue(FP(feature, pos));
216  
-	}
217 194
 	void EnqueueFeatureMovedEvent(const CFeature* feature, const float3& oldpos, const float3& newpos) {
218 195
 		featureMovedEventBatch.enqueue(FAP(feature, oldpos, newpos));
219 196
 	}
2  rts/System/EventClient.h
@@ -142,7 +142,7 @@ class CEventClient
142 142
 		virtual void FeatureMoved(const CFeature* feature) {}
143 143
 
144 144
 		virtual void RenderFeatureCreated(const CFeature* feature) {}
145  
-		virtual void RenderFeatureDestroyed(const CFeature* feature, const float3& pos) {}
  145
+		virtual void RenderFeatureDestroyed(const CFeature* feature) {}
146 146
 		virtual void RenderFeatureMoved(const CFeature* feature, const float3& oldpos, const float3& newpos) {}
147 147
 
148 148
 		virtual void ProjectileCreated(const CProjectile* proj) {}
10  rts/System/EventHandler.h
@@ -113,7 +113,7 @@ class CEventHandler
113 113
 		void FeatureMoved(const CFeature* feature, const float3& oldpos);
114 114
 
115 115
 		void RenderFeatureCreated(const CFeature* feature);
116  
-		void RenderFeatureDestroyed(const CFeature* feature, const float3& pos);
  116
+		void RenderFeatureDestroyed(const CFeature* feature);
117 117
 		void RenderFeatureMoved(const CFeature* feature, const float3& oldpos, const float3& newpos);
118 118
 
119 119
 		void UpdateFeatures();
@@ -720,7 +720,7 @@ inline void CEventHandler::RenderUnitMoved(const CUnit* unit, const float3& newp
720 720
 
721 721
 inline void CEventHandler::FeatureCreated(const CFeature* feature)
722 722
 {
723  
-	eventBatchHandler->EnqueueFeatureCreatedEvent(feature, feature->pos);
  723
+	(eventBatchHandler->GetFeatureCreatedDestroyedEventBatch()).enqueue(feature);
724 724
 
725 725
 	const int featureAllyTeam = feature->allyteam;
726 726
 	const int count = listFeatureCreated.size();
@@ -735,7 +735,7 @@ inline void CEventHandler::FeatureCreated(const CFeature* feature)
735 735
 
736 736
 inline void CEventHandler::FeatureDestroyed(const CFeature* feature)
737 737
 {
738  
-	eventBatchHandler->EnqueueFeatureDestroyedEvent(feature, feature->pos);
  738
+	(eventBatchHandler->GetFeatureCreatedDestroyedEventBatch()).dequeue(feature);
739 739
 
740 740
 	const int featureAllyTeam = feature->allyteam;
741 741
 	const int count = listFeatureDestroyed.size();
@@ -774,12 +774,12 @@ inline void CEventHandler::RenderFeatureCreated(const CFeature* feature)
774 774
 	}
775 775
 }
776 776
 
777  
-inline void CEventHandler::RenderFeatureDestroyed(const CFeature* feature, const float3& pos)
  777
+inline void CEventHandler::RenderFeatureDestroyed(const CFeature* feature)
778 778
 {
779 779
 	const int count = listRenderFeatureDestroyed.size();
780 780
 	for (int i = 0; i < count; i++) {
781 781
 		CEventClient* ec = listRenderFeatureDestroyed[i];
782  
-		ec->RenderFeatureDestroyed(feature, pos);
  782
+		ec->RenderFeatureDestroyed(feature);
783 783
 	}
784 784
 }
785 785
 
42  rts/lib/gml/ThreadSafeContainers.h
@@ -173,7 +173,7 @@ class ThreadListSimRender {
173 173
 
174 174
 
175 175
 
176  
-template <class C, class X, class R, class T, class D>
  176
+template <class C, class R, class T, class D>
177 177
 class ThreadListRender {
178 178
 private:
179 179
 	typedef typename std::set<T>::const_iterator constSetIT;
@@ -246,7 +246,7 @@ class ThreadListRender {
246 246
 		return NULL;
247 247
 	}
248 248
 
249  
-	void dequeue(const T& x) {
  249
+	void dequeue(const C& x) {
250 250
 		D::Remove(x);
251 251
 	}
252 252
 
@@ -709,7 +709,7 @@ class ThreadVectorSimRender {
709 709
 
710 710
 
711 711
 
712  
-template <class C, class X, class R, class T, class D>
  712
+template <class C, class R, class T, class D>
713 713
 class ThreadListRender {
714 714
 private:
715 715
 	typedef typename std::set<T>::const_iterator constSetIT;
@@ -717,7 +717,6 @@ class ThreadListRender {
717 717
 	typedef typename std::vector<T>::const_iterator VecIT;
718 718
 	typedef typename std::vector<C>::const_iterator VecITC;
719 719
 	typedef typename std::vector<T>::iterator VecITT;
720  
-	typedef typename std::vector<X>::iterator VecITX;
721 720
 
722 721
 public:
723 722
 	CR_DECLARE_STRUCT(ThreadListRender);
@@ -823,31 +822,14 @@ class ThreadListRender {
823 822
 	}
824 823
 
825 824
 	void clean() {
826  
-		cleandef(&simDelQueue);
  825
+		clean(&simDelQueue);
827 826
 	}
828 827
 
829  
-	void cleandef(std::vector<T> *delQueue) {
830  
-		delay();
831  
-		for (VecITT it = sharedQueue.begin(); it != sharedQueue.end(); ) {
832  
-			bool found = false;
833  
-			for (VecITT it2 = delQueue->begin(); it2 != delQueue->end(); ++it2) {
834  
-				if(*it == *it2) {
835  
-					found = true;
836  
-					break;
837  
-				}
838  
-			}
839  
-			if(found)
840  
-				it = sharedQueue.erase(it);
841  
-			else
842  
-				++it;
843  
-		}
844  
-	}
845  
-
846  
-	void clean(std::vector<X> *delQueue) {
  828
+	void clean(std::vector<C> *delQueue) {
847 829
 		delay();
848 830
 		for (VecITT it = sharedQueue.begin(); it != sharedQueue.end(); ) {
849 831
 			bool found = false;
850  
-			for (VecITX it2 = delQueue->begin(); it2 != delQueue->end(); ++it2) {
  832
+			for (VecITC it2 = delQueue->begin(); it2 != delQueue->end(); ++it2) {
851 833
 				if(*it == *it2) {
852 834
 					found = true;
853 835
 					break;
@@ -860,27 +842,27 @@ class ThreadListRender {
860 842
 		}
861 843
 	}
862 844
 
863  
-	std::vector<T> *to_destroy() {
  845
+	std::vector<C> *to_destroy() {
864 846
 		return &simDelQueue;
865 847
 	}
866 848
 
867  
-	void dequeue(const T& x) {
  849
+	void dequeue(const C& x) {
868 850
 		simDelQueue.push_back(x);
869 851
 	}
870 852
 
871  
-	void dequeue_synced(const T& x) {
  853
+	void dequeue_synced(const C& x) {
872 854
 		simDelQueue.push_back(x);
873 855
 	}
874 856
 
875 857
 	void destroy() {
876  
-		for (VecITT it = simDelQueue.begin(); it != simDelQueue.end(); ++it) {
  858
+		for (VecITC it = simDelQueue.begin(); it != simDelQueue.end(); ++it) {
877 859
 			D::Remove(*it);
878 860
 		}
879 861
 		simDelQueue.clear();
880 862
 	}
881 863
 
882 864
 	void destroy_synced() {
883  
-		for (VecITT it = simDelQueue.begin(); it != simDelQueue.end(); ++it) {
  865
+		for (VecITC it = simDelQueue.begin(); it != simDelQueue.end(); ++it) {
884 866
 			D::Remove(*it);
885 867
 		}
886 868
 		simDelQueue.clear();
@@ -889,7 +871,7 @@ class ThreadListRender {
889 871
 private:
890 872
 	std::vector<T> simQueue;
891 873
 	std::vector<T> sharedQueue;
892  
-	std::vector<T> simDelQueue;
  874
+	std::vector<C> simDelQueue;
893 875
 
894 876
 	std::set<T> preAddRender;
895 877
 	std::set<T> addRender;

0 notes on commit 3fc6ebb

Please sign in to comment.
Something went wrong with that request. Please try again.