Browse Source

fix DirectX lighting some more

David Rose 20 years ago
parent
commit
856a53bd5c

+ 7 - 2
panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx

@@ -4060,14 +4060,19 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) {
   alight.dvRange =  D3DLIGHT_RANGE_MAX;
   alight.dvFalloff =  1.0f;
   alight.dvTheta =  0.0f;
-  alight.dvPhi =  lens->get_hfov();
+  alight.dvPhi = deg_2_rad(lens->get_hfov());
 
   const LVecBase3f &att = light_obj->get_attenuation();
   alight.dvAttenuation0 = (D3DVALUE)att[0];
   alight.dvAttenuation1 = (D3DVALUE)att[1];
   alight.dvAttenuation2 = (D3DVALUE)att[2];
 
-  HRESULT res = _pScrn->pD3DDevice->SetLight(light_id, &alight);
+  HRESULT hr = _pScrn->pD3DDevice->SetLight(light_id, &alight);
+  if (FAILED(hr)) {
+    wdxdisplay7_cat.warning() 
+      << "Could not set light properties for " << light 
+      << " to id " << light_id << "\n";
+  }
 }
 
 #if 0

+ 3 - 3
panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx

@@ -4328,7 +4328,7 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) {
   alight.Range =  __D3DLIGHT_RANGE_MAX;
   alight.Falloff =  1.0f;
   alight.Theta =  0.0f;
-  alight.Phi =  lens->get_hfov();
+  alight.Phi = deg_2_rad(lens->get_hfov());
 
   const LVecBase3f &att = light_obj->get_attenuation();
   alight.Attenuation0 = att[0];
@@ -4667,7 +4667,7 @@ do_auto_rescale_normal() {
 ////////////////////////////////////////////////////////////////////
 bool DXGraphicsStateGuardian8::
 slot_new_light(int light_id) {
-  return (light_id < _max_lights);
+  return ((unsigned int)light_id < _max_lights);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -4734,7 +4734,7 @@ enable_light(int light_id, bool enable) {
 ////////////////////////////////////////////////////////////////////
 bool DXGraphicsStateGuardian8::
 slot_new_clip_plane(int plane_id) {
-  return (plane_id < _max_clip_planes);
+  return ((unsigned int)plane_id < _max_clip_planes);
 }
 
 ////////////////////////////////////////////////////////////////////

+ 2 - 2
panda/src/dxgsg8/dxGraphicsStateGuardian8.h

@@ -307,8 +307,8 @@ protected:
   D3DBLEND _blend_source_func;
   D3DBLEND _blend_dest_func;
 
-  int _max_lights;
-  int _max_clip_planes;
+  unsigned int _max_lights;
+  unsigned int _max_clip_planes;
 
   bool _line_smooth_enabled;
   bool _color_material_enabled;

+ 1 - 1
panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx

@@ -3500,7 +3500,7 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) {
   alight.Range =  __D3DLIGHT_RANGE_MAX;
   alight.Falloff =  1.0f;
   alight.Theta =  0.0f;
-  alight.Phi =  lens->get_hfov();
+  alight.Phi = deg_2_rad(lens->get_hfov());
 
   const LVecBase3f &att = light_obj->get_attenuation();
   alight.Attenuation0 = att[0];