////////////////////////////////////////////////////////////////////////////
//
//  Crytek Engine Source File.
//  Copyright (C), Crytek Studios, 2002.
// -------------------------------------------------------------------------
//  File name:   brushplane.h
//  Version:     v1.00
//  Created:     9/7/2002 by Timur.
//  Compilers:   Visual Studio.NET
//  Description: 
// -------------------------------------------------------------------------
//  History: Based on Andrey's Indoor editor.
//
////////////////////////////////////////////////////////////////////////////

#ifndef __brushplane_h__
#define __brushplane_h__

#if _MSC_VER > 1000
#pragma once
#endif

struct SBrushPoly;

struct SBrushPlane
{
  SBrushPlane()
  {
    type = 0;
		dist = 0;
		normal(0,0,0);
  }
	// Makes the palne given 3 points
	void Make( const Vec3 &p1, const Vec3 &p2, const Vec3 &p3)
  {
		normal = (p1 - p2)^(p3 - p2);
		normal.NormalizeSafe();
		dist = normal.Dot(p2);
	}

  void CalcTextureAxis(Vec3& xv, Vec3& yv, bool bTex);
  SBrushPoly *CreatePoly();
  int Equal(SBrushPlane *b, int flip);
  void Invert(SBrushPlane *p)
  {
    normal = Vec3(0,0,0) - p->normal;
    dist = -p->dist;
  }
  _inline bool operator==(const SBrushPlane& p) const
  {
    if ( p.normal.x==normal.x && p.normal.y==normal.y && p.normal.z==normal.z && p.dist==dist)
      return true;
    return false;
  }
  _inline bool operator!=(const SBrushPlane& p) const
  {
    if ( p.normal.x==normal.x && p.normal.y==normal.y && p.normal.z==normal.z && p.dist==dist)
      return false;
    return true;
  }

  Vec3 normal;
  float dist;
  int   type;
};

#endif // __brushplane_h__
