Skip to content

Commit

Permalink
Merge pull request #183 from Simarilius-uk/OS_support
Browse files Browse the repository at this point in the history
Checks for things that might be nonetype
  • Loading branch information
Simarilius-uk authored Nov 14, 2024
2 parents 3f19105 + 7bc9fe0 commit 54790aa
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 27 deletions.
51 changes: 27 additions & 24 deletions i_scene_cp77_gltf/importers/entity_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,9 @@ def importEnt(with_materials, filepath='', appearances=[], exclude_meshes=[], in
print('interior_02')
bindpt=[cmp for cmp in comps if cmp['name']['$value']==bindname]
if bindpt and len(bindpt)==1:
if c['localTransform']['Position']['x']['Bits']==0 and c['localTransform']['Position']['y']['Bits']==0 and c['localTransform']['Position']['z']['Bits']==0:
if c['localTransform']['Position']['x']['Bits']==0 and c['localTransform']['Position']['y']['Bits']==0 and c['localTransform']['Position']['z']['Bits']==0 and 'localTransform' in bindpt[0]:
c['localTransform']['Position']=bindpt[0]['localTransform']['Position']
if c['localTransform']['Orientation']['i']==0 and c['localTransform']['Orientation']['j']==0 and c['localTransform']['Orientation']['k']==0 and c['localTransform']['Orientation']['r']==1:
if c['localTransform']['Orientation']['i']==0 and c['localTransform']['Orientation']['j']==0 and c['localTransform']['Orientation']['k']==0 and c['localTransform']['Orientation']['r']==1 and 'localTransform' in bindpt[0]:
c['localTransform']['Orientation']=bindpt[0]['localTransform']['Orientation']


Expand All @@ -461,28 +461,31 @@ def importEnt(with_materials, filepath='', appearances=[], exclude_meshes=[], in
for o in comps:
if o['name']['$value']==bindname:
pT=o['parentTransform']
x=o['localTransform']['Position']['x']['Bits']/131072
y=o['localTransform']['Position']['y']['Bits']/131072
z=o['localTransform']['Position']['z']['Bits']/131072
pT_HId=pT['HandleRefId']
#print(bindname, 'pT_HId = ',pT_HId)
chunk_pt = 0
for chunk in chunks:
if 'parentTransform' in chunk.keys() and isinstance( chunk['parentTransform'], dict):
if 'HandleId' in chunk['parentTransform'].keys():
if chunk['parentTransform']['HandleId']==pT_HId:
chunk_pt=chunk['parentTransform']
#print('HandleId found',chunk['parentTransform']['HandleId'])
if chunk_pt:
#print('in chunk pt processing')
bindname=chunk_pt['Data']['bindName']['$value']
if bindname=='vehicle_slots':
if vehicle_slots:
slotname=chunk_pt['Data']['slotName']['$value']
for slot in vehicle_slots:
if slot['slotName']['$value']==slotname:
bindname=slot['boneName']['$value']

if pT:

x=o['localTransform']['Position']['x']['Bits']/131072
y=o['localTransform']['Position']['y']['Bits']/131072
z=o['localTransform']['Position']['z']['Bits']/131072

pT_HId=pT['HandleRefId']
#print(bindname, 'pT_HId = ',pT_HId)
chunk_pt = 0
for chunk in chunks:
if 'parentTransform' in chunk.keys() and isinstance( chunk['parentTransform'], dict):
if 'HandleId' in chunk['parentTransform'].keys():
if chunk['parentTransform']['HandleId']==pT_HId:
chunk_pt=chunk['parentTransform']
#print('HandleId found',chunk['parentTransform']['HandleId'])
if chunk_pt:
#print('in chunk pt processing')
bindname=chunk_pt['Data']['bindName']['$value']
if bindname=='vehicle_slots':
if vehicle_slots:
slotname=chunk_pt['Data']['slotName']['$value']
for slot in vehicle_slots:
if slot['slotName']['$value']==slotname:
bindname=slot['boneName']['$value']

######
if bindname in bones.keys():
#print('bindname in bones')
Expand Down
5 changes: 4 additions & 1 deletion i_scene_cp77_gltf/importers/sector_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,10 @@ def importSectors( filepath, with_mats, remap_depot, want_collisions, am_modding
o['nodeIndex']=i
o['debugName']=e['Data']['debugName']['$value']
o['sectorName']=sectorName
o['workspot']=e['Data']['spot']['Data']['resource']['DepotPath']['$value']
if e['Data']['spot']:
o['workspot']=e['Data']['spot']['Data']['resource']['DepotPath']['$value']
else:
o['workspot']='None'
if e['Data']['markings']:
o['markings']=e['Data']['markings'][0]['$value']
o.empty_display_size = 0.2
Expand Down
8 changes: 6 additions & 2 deletions i_scene_cp77_gltf/jsontool.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ def jsonload(filepath):
return 'CANCELLED'

ent_apps= data['Data']['RootChunk']['appearances']
ent_components= data['Data']['RootChunk']['components']
ent_component_data= data['Data']['RootChunk']['compiledData']['Data']['Chunks']
ent_components=[]
if data['Data']['RootChunk']['components']!=None:
ent_components= data['Data']['RootChunk']['components']
ent_component_data=[]
if data['Data']['RootChunk']['compiledData']!=None:
ent_component_data= data['Data']['RootChunk']['compiledData']['Data']['Chunks']
res = data['Data']['RootChunk']['resolvedDependencies']
ent_default = data['Data']['RootChunk']['defaultAppearance']['$value']
# Do something for .ent.json
Expand Down

0 comments on commit 54790aa

Please sign in to comment.