mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
force_normals
This commit is contained in:
parent
27d85ea8a6
commit
db74d39f8e
@ -161,6 +161,39 @@ clear(DisplayRegion *dr) {
|
|||||||
pop_display_region(old_dr);
|
pop_display_region(old_dr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: GraphicsStateGuardian::force_normals
|
||||||
|
// Access: Public
|
||||||
|
// Description: Temporarily forces the GSG to issue normals to the
|
||||||
|
// graphics pipe. Normally, the GSG will issue normals
|
||||||
|
// only if lighting is on.
|
||||||
|
//
|
||||||
|
// This call must be matched with exactly one call to
|
||||||
|
// undo_force_normals().
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE int GraphicsStateGuardian::
|
||||||
|
force_normals() {
|
||||||
|
nassertr(_force_normals >= 0, _force_normals);
|
||||||
|
_force_normals++;
|
||||||
|
return _force_normals;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: GraphicsStateGuardian::undo_force_normals
|
||||||
|
// Access: Public
|
||||||
|
// Description: Undoes the effect of a previous call to
|
||||||
|
// force_normals().
|
||||||
|
//
|
||||||
|
// This call must be matched with one-to-one with a
|
||||||
|
// previous call to force_normals().
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE int GraphicsStateGuardian::
|
||||||
|
undo_force_normals() {
|
||||||
|
_force_normals--;
|
||||||
|
nassertr(_force_normals >= 0, _force_normals);
|
||||||
|
return _force_normals;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: GraphicsStateGuardian::reset_if_new
|
// Function: GraphicsStateGuardian::reset_if_new
|
||||||
// Access: Public
|
// Access: Public
|
||||||
|
@ -114,7 +114,7 @@ reset() {
|
|||||||
_depth_clear_value = 1.0f;
|
_depth_clear_value = 1.0f;
|
||||||
_stencil_clear_value = 0.0f;
|
_stencil_clear_value = 0.0f;
|
||||||
_accum_clear_value.set(0.0f, 0.0f, 0.0f, 0.0f);
|
_accum_clear_value.set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
_normals_enabled = false;
|
_force_normals = 0;
|
||||||
|
|
||||||
//Color and alpha transform variables
|
//Color and alpha transform variables
|
||||||
_color_transform_enabled = 0;
|
_color_transform_enabled = 0;
|
||||||
@ -420,7 +420,7 @@ end_frame() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
bool GraphicsStateGuardian::
|
bool GraphicsStateGuardian::
|
||||||
wants_normals() const {
|
wants_normals() const {
|
||||||
return _normals_enabled;
|
return (_lighting_enabled || (_force_normals != 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -107,7 +107,8 @@ public:
|
|||||||
virtual void prepare_display_region()=0;
|
virtual void prepare_display_region()=0;
|
||||||
virtual bool prepare_lens();
|
virtual bool prepare_lens();
|
||||||
|
|
||||||
INLINE void enable_normals(bool val) { _normals_enabled = val; }
|
INLINE int force_normals();
|
||||||
|
INLINE int undo_force_normals();
|
||||||
|
|
||||||
virtual bool begin_frame();
|
virtual bool begin_frame();
|
||||||
virtual bool begin_scene();
|
virtual bool begin_scene();
|
||||||
@ -236,8 +237,10 @@ protected:
|
|||||||
CPT(DisplayRegion) _current_display_region;
|
CPT(DisplayRegion) _current_display_region;
|
||||||
CPT(Lens) _current_lens;
|
CPT(Lens) _current_lens;
|
||||||
|
|
||||||
// This is used by wants_normals()
|
// This is used by wants_normals(). It's used as a semaphore:
|
||||||
bool _normals_enabled;
|
// increment it to enable normals, and decrement it when you're
|
||||||
|
// done. The graphics engine will apply normals if it is nonzero.
|
||||||
|
int _force_normals;
|
||||||
|
|
||||||
CoordinateSystem _coordinate_system;
|
CoordinateSystem _coordinate_system;
|
||||||
|
|
||||||
|
@ -426,7 +426,6 @@ dx_init( void) {
|
|||||||
_pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_EDGEANTIALIAS, false);
|
_pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_EDGEANTIALIAS, false);
|
||||||
|
|
||||||
_color_material_enabled = false;
|
_color_material_enabled = false;
|
||||||
_normals_enabled = false;
|
|
||||||
|
|
||||||
_depth_test_enabled = D3DZB_FALSE;
|
_depth_test_enabled = D3DZB_FALSE;
|
||||||
_pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
|
_pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
|
||||||
@ -4240,16 +4239,6 @@ end_frame() {
|
|||||||
GraphicsStateGuardian::end_frame();
|
GraphicsStateGuardian::end_frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: DXGraphicsStateGuardian7::wants_normals
|
|
||||||
// Access: Public, Virtual
|
|
||||||
// Description:
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE bool DXGraphicsStateGuardian7::
|
|
||||||
wants_normals() const {
|
|
||||||
return (_lighting_enabled || _normals_enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DXGraphicsStateGuardian7::wants_texcoords
|
// Function: DXGraphicsStateGuardian7::wants_texcoords
|
||||||
// Access: Public, Virtual
|
// Access: Public, Virtual
|
||||||
|
@ -129,7 +129,6 @@ public:
|
|||||||
virtual void end_scene();
|
virtual void end_scene();
|
||||||
virtual void end_frame();
|
virtual void end_frame();
|
||||||
|
|
||||||
virtual bool wants_normals(void) const;
|
|
||||||
virtual bool wants_texcoords(void) const;
|
virtual bool wants_texcoords(void) const;
|
||||||
|
|
||||||
virtual bool depth_offset_decals();
|
virtual bool depth_offset_decals();
|
||||||
|
@ -555,7 +555,6 @@ dx_init(void) {
|
|||||||
_pD3DDevice->SetRenderState(D3DRS_EDGEANTIALIAS, false);
|
_pD3DDevice->SetRenderState(D3DRS_EDGEANTIALIAS, false);
|
||||||
|
|
||||||
_color_material_enabled = false;
|
_color_material_enabled = false;
|
||||||
_normals_enabled = false;
|
|
||||||
|
|
||||||
_depth_test_enabled = D3DZB_FALSE;
|
_depth_test_enabled = D3DZB_FALSE;
|
||||||
_pD3DDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
|
_pD3DDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
|
||||||
@ -4065,16 +4064,6 @@ end_frame() {
|
|||||||
GraphicsStateGuardian::end_frame();
|
GraphicsStateGuardian::end_frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: DXGraphicsStateGuardian8::wants_normals
|
|
||||||
// Access: Public, Virtual
|
|
||||||
// Description:
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE bool DXGraphicsStateGuardian8::
|
|
||||||
wants_normals() const {
|
|
||||||
return (_lighting_enabled || _normals_enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DXGraphicsStateGuardian8::wants_texcoords
|
// Function: DXGraphicsStateGuardian8::wants_texcoords
|
||||||
// Access: Public, Virtual
|
// Access: Public, Virtual
|
||||||
|
@ -134,7 +134,6 @@ public:
|
|||||||
virtual void end_scene();
|
virtual void end_scene();
|
||||||
virtual void end_frame();
|
virtual void end_frame();
|
||||||
|
|
||||||
virtual bool wants_normals(void) const;
|
|
||||||
virtual bool wants_texcoords(void) const;
|
virtual bool wants_texcoords(void) const;
|
||||||
|
|
||||||
virtual bool depth_offset_decals();
|
virtual bool depth_offset_decals();
|
||||||
|
@ -556,7 +556,6 @@ dx_init(void) {
|
|||||||
_pD3DDevice->SetRenderState(D3DRS_ANTIALIASEDLINEENABLE, false);
|
_pD3DDevice->SetRenderState(D3DRS_ANTIALIASEDLINEENABLE, false);
|
||||||
|
|
||||||
_color_material_enabled = false;
|
_color_material_enabled = false;
|
||||||
_normals_enabled = false;
|
|
||||||
|
|
||||||
_depth_test_enabled = D3DZB_FALSE;
|
_depth_test_enabled = D3DZB_FALSE;
|
||||||
_pD3DDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
|
_pD3DDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
|
||||||
@ -4069,16 +4068,6 @@ end_frame() {
|
|||||||
GraphicsStateGuardian::end_frame();
|
GraphicsStateGuardian::end_frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: DXGraphicsStateGuardian9::wants_normals
|
|
||||||
// Access: Public, Virtual
|
|
||||||
// Description:
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE bool DXGraphicsStateGuardian9::
|
|
||||||
wants_normals() const {
|
|
||||||
return (_lighting_enabled || _normals_enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DXGraphicsStateGuardian9::wants_texcoords
|
// Function: DXGraphicsStateGuardian9::wants_texcoords
|
||||||
// Access: Public, Virtual
|
// Access: Public, Virtual
|
||||||
|
@ -134,7 +134,6 @@ public:
|
|||||||
virtual void end_scene();
|
virtual void end_scene();
|
||||||
virtual void end_frame();
|
virtual void end_frame();
|
||||||
|
|
||||||
virtual bool wants_normals(void) const;
|
|
||||||
virtual bool wants_texcoords(void) const;
|
virtual bool wants_texcoords(void) const;
|
||||||
|
|
||||||
virtual bool depth_offset_decals();
|
virtual bool depth_offset_decals();
|
||||||
|
@ -1418,7 +1418,6 @@ draw_tristrip(GeomTristrip *geom, GeomContext *gc) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef DO_PSTATS
|
#ifdef DO_PSTATS
|
||||||
// PStatTimer timer(_draw_primitive_pcollector);
|
// PStatTimer timer(_draw_primitive_pcollector);
|
||||||
// Using PStatTimer may cause a compiler crash.
|
// Using PStatTimer may cause a compiler crash.
|
||||||
@ -1500,6 +1499,7 @@ draw_tristrip(GeomTristrip *geom, GeomContext *gc) {
|
|||||||
}
|
}
|
||||||
GLP(End)();
|
GLP(End)();
|
||||||
}
|
}
|
||||||
|
|
||||||
report_my_gl_errors();
|
report_my_gl_errors();
|
||||||
DO_PSTATS_STUFF(_draw_primitive_pcollector.stop());
|
DO_PSTATS_STUFF(_draw_primitive_pcollector.stop());
|
||||||
}
|
}
|
||||||
@ -1811,9 +1811,8 @@ prepare_geom(Geom *geom) {
|
|||||||
|
|
||||||
// We need to temporarily force normals and UV's on, so the display
|
// We need to temporarily force normals and UV's on, so the display
|
||||||
// list will have them built in.
|
// list will have them built in.
|
||||||
bool old_normals_enabled = _normals_enabled;
|
|
||||||
bool old_texturing_enabled = _texturing_enabled;
|
bool old_texturing_enabled = _texturing_enabled;
|
||||||
_normals_enabled = true;
|
force_normals();
|
||||||
_texturing_enabled = true;
|
_texturing_enabled = true;
|
||||||
|
|
||||||
#ifdef DO_PSTATS
|
#ifdef DO_PSTATS
|
||||||
@ -1842,7 +1841,7 @@ prepare_geom(Geom *geom) {
|
|||||||
ggc->_num_verts = (int)(num_verts + 0.5);
|
ggc->_num_verts = (int)(num_verts + 0.5);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_normals_enabled = old_normals_enabled;
|
undo_force_normals();
|
||||||
_texturing_enabled = old_texturing_enabled;
|
_texturing_enabled = old_texturing_enabled;
|
||||||
|
|
||||||
report_my_gl_errors();
|
report_my_gl_errors();
|
||||||
@ -2543,16 +2542,6 @@ bind_light(Spotlight *light, int light_id) {
|
|||||||
report_my_gl_errors();
|
report_my_gl_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: CLP(GraphicsStateGuardian)::wants_normals
|
|
||||||
// Access: Public, Virtual
|
|
||||||
// Description:
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
bool CLP(GraphicsStateGuardian)::
|
|
||||||
wants_normals() const {
|
|
||||||
return (_lighting_enabled || _normals_enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: CLP(GraphicsStateGuardian)::wants_texcoords
|
// Function: CLP(GraphicsStateGuardian)::wants_texcoords
|
||||||
// Access: Public, Virtual
|
// Access: Public, Virtual
|
||||||
|
@ -110,7 +110,6 @@ public:
|
|||||||
virtual void bind_light(DirectionalLight *light, int light_id);
|
virtual void bind_light(DirectionalLight *light, int light_id);
|
||||||
virtual void bind_light(Spotlight *light, int light_id);
|
virtual void bind_light(Spotlight *light, int light_id);
|
||||||
|
|
||||||
virtual bool wants_normals(void) const;
|
|
||||||
virtual bool wants_texcoords(void) const;
|
virtual bool wants_texcoords(void) const;
|
||||||
|
|
||||||
virtual bool depth_offset_decals();
|
virtual bool depth_offset_decals();
|
||||||
|
@ -99,7 +99,7 @@ apply(Node *node, const AllAttributesWrapper &init_state,
|
|||||||
|
|
||||||
// Turn lighting off - we still want to issue normals, though
|
// Turn lighting off - we still want to issue normals, though
|
||||||
trans.set_transition(new LightTransition(LightTransition::all_off()));
|
trans.set_transition(new LightTransition(LightTransition::all_off()));
|
||||||
gsg->enable_normals(true);
|
gsg->force_normals();
|
||||||
|
|
||||||
// Do some extra work if we're doing the 2-pass version (e.g. the
|
// Do some extra work if we're doing the 2-pass version (e.g. the
|
||||||
// object we are shading is textured)
|
// object we are shading is textured)
|
||||||
@ -124,7 +124,7 @@ apply(Node *node, const AllAttributesWrapper &init_state,
|
|||||||
DirectRenderTraverser drt(gsg, RenderRelation::get_class_type());
|
DirectRenderTraverser drt(gsg, RenderRelation::get_class_type());
|
||||||
gsg->render_subgraph(&drt, node, init_state, trans);
|
gsg->render_subgraph(&drt, node, init_state, trans);
|
||||||
|
|
||||||
gsg->enable_normals(false);
|
gsg->undo_force_normals();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user