Skip to content

Commit 7342cd9

Browse files
committed
Fiw Google Earth import
1 parent 650804d commit 7342cd9

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

blender/MapsModelsImporter/google_maps.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
MSG_INCORRECT_RDC = """Invalid RDC capture file. Please make sure that:
3838
1. You are using the recommended RenderDoc Version for this AddOn
3939
- RenderDoc Version 1.5 - 1.9 for MapsModelsImporter <= 0.3.2
40-
- RenderDoc Version 1.10 for MapsModelsImporter >= 0.3.3
41-
- RenderDoc Version 1.11 & 1.12 don't work at the moment (latest MapsModelsImporter is 0.3.5). But it probably will work in a future Version.
40+
- RenderDoc Version >= 1.10 for MapsModelsImporter >= 0.3.3
4241
2. You are importing from Google Maps or Google Earth web
4342
3. You were MOVING in the 3D view while taking the capture (you can use the "Capture after delay"-button in RenderDoc).
4443
@@ -259,7 +258,7 @@ def filesToBlender(context, prefix, max_blocks=200, globalScale=1.0/256.0):
259258
# Make triangles from triangle strip index buffer
260259
n = len(indices)
261260
if constants["DrawCall"]["topology"] == 'TRIANGLE_STRIP':
262-
tris = [ [ indices[i+j] for j in [[0,1,2],[0,2,1]][i%2] ] for i in range(n - 2)]
261+
tris = [ [ indices[i+j] for j in [[0,1,2],[0,2,1]][i%2] ] for i in range(n - 3)]
263262
tris = [ t for t in tris if t[0] != t[1] and t[0] != t[2] and t[1] != t[2] ]
264263
else:
265264
tris = [ [ indices[3*i+j] for j in range(3) ] for i in range(n//3) ]

blender/MapsModelsImporter/google_maps_rd.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def hasUniform(self, draw, uniform):
132132
constants = self.getVertexShaderConstants(draw)
133133
return uniform in constants['$Globals']
134134

135-
def extractRelevantCalls(self, drawcalls, _strategy=0):
135+
def extractRelevantCalls(self, drawcalls, _strategy=4):
136136
"""List the drawcalls related to drawing the 3D meshes thank to a ad hoc heuristic
137137
It may different in RenderDoc UI and in Python module, for some reason
138138
"""
@@ -160,9 +160,12 @@ def extractRelevantCalls(self, drawcalls, _strategy=0):
160160
last_call = ""
161161
drawcall_prefix = "DrawIndexed"
162162
capture_type = "Google Earth"
163-
skipped_drawcalls, min_drawcall = self.findDrawcallBatch(drawcalls, first_call, drawcall_prefix, last_call)
164-
if not skipped_drawcalls or not self.hasUniform(skipped_drawcalls[0], "_uProjModelviewMatrix"):
165-
first_call = "INVALID CASE, SKIP ME"
163+
min_drawcall = 0
164+
while True:
165+
skipped_drawcalls, new_min_drawcall = self.findDrawcallBatch(drawcalls[min_drawcall:], first_call, drawcall_prefix, last_call)
166+
if self.hasUniform(skipped_drawcalls[0], "_uMeshToWorldMatrix"):
167+
break
168+
min_drawcall += new_min_drawcall
166169
elif _strategy == 6:
167170
# Actually sometimes there's only one batch
168171
first_call = "DrawIndexed"
@@ -181,7 +184,7 @@ def extractRelevantCalls(self, drawcalls, _strategy=0):
181184
print("Error: Could not find the beginning of the relevant 3D draw calls")
182185
return [], "none"
183186

184-
print(f"Trying scrapping strategy #{_strategy}...")
187+
print(f"Trying scraping strategy #{_strategy}...")
185188
relevant_drawcalls, _ = self.findDrawcallBatch(
186189
drawcalls[min_drawcall:],
187190
first_call,
@@ -200,13 +203,19 @@ def extractRelevantCalls(self, drawcalls, _strategy=0):
200203
else:
201204
capture_type = "Google Earth"
202205

206+
if capture_type == "Google Earth":
207+
relevant_drawcalls = [
208+
call for call in relevant_drawcalls
209+
if self.hasUniform(call, "_uMeshToWorldMatrix")
210+
]
211+
203212
return relevant_drawcalls, capture_type
204213

205214
def run(self):
206215
controller = self.controller
207216
drawcalls = controller.GetDrawcalls()
208217
relevant_drawcalls, capture_type = self.extractRelevantCalls(drawcalls)
209-
print(f"Scrapping capture from {capture_type}...")
218+
print(f"Scraping capture from {capture_type}...")
210219

211220
if MAX_BLOCKS <= 0:
212221
max_drawcall = len(relevant_drawcalls)

0 commit comments

Comments
 (0)